最近计算机图形学老师让我们在TC下图形编程[就是画圆,直线...]
在Linux下该用什么替换呀,安装SDL?怎么配置呀...?
Help
我现在有 build-essential 了..
[问题]安装SDL?
- weilichun
- 帖子: 218
- 注册时间: 2007-09-09 15:41
- 来自: Beijing
- 联系:
- weilichun
- 帖子: 218
- 注册时间: 2007-09-09 15:41
- 来自: Beijing
- 联系:
- weilichun
- 帖子: 218
- 注册时间: 2007-09-09 15:41
- 来自: Beijing
- 联系:
这是网上找的...
代码: 全选
#include <stdlib.h>
#include <SDL/SDL.h>
int main() {
SDL_Surface *screen;
Uint32 color;
if ( SDL_Init( SDL_INIT_VIDEO) < 0 ) {
fprintf(stderr, "无法初始化SDL: %s\n", SDL_GetError());
exit(1);
}
screen = SDL_SetVideoMode(1280, 800, 24, SDL_SWSURFACE); /*640 X 480 X 16位色*/
if ( screen == NULL ) {
fprintf(stderr, "无法设置640x480x16位色的视频模式:%s\n", SDL_GetError());
exit(1);
}
atexit(SDL_Quit);
int i;
int width,height;
for ( i = 0; i < 256; i++) {
width=rand()%1280;
height=rand()%800;
color = SDL_MapRGB(screen->format, rand()%256, (i*i)%256, rand()%256); /*蓝色*/
SDL_FillRect(screen, &screen->clip_rect, color); /*整个屏幕填充颜色*/
SDL_UpdateRect(screen, width,height,rand()%1280, rand()%800); /*update screen*/
/*
SDL_Delay(5);
*/
printf("%d\n",i);
}
//SDL_Delay(5000); /*Delay for 5 seconds*/
}
- weilichun
- 帖子: 218
- 注册时间: 2007-09-09 15:41
- 来自: Beijing
- 联系: