Пример #1
0
int main(void)
{

    int done=0;
    srand(time(NULL));
    initXWindows();
    init_opengl();
    //declare game object
    Game game;
    //start animation
    while(!done) {
        while(XPending(dpy)) {
            XEvent e;
            XNextEvent(dpy, &e);
            check_mouse(&e, &game);
            done = check_keys(&e, &game);
        }
        movement(&game);
        render(&game);
        glXSwapBuffers(dpy, win);
    }
    cleanupXWindows();
    cleanup_fonts();
    return 0;
}
Пример #2
0
int main(void)
{
	logOpen();
	initXWindows();
	init_opengl();
	Game game;
	init(&game);
	srand(time(NULL));
	clock_gettime(CLOCK_REALTIME, &timePause);
	clock_gettime(CLOCK_REALTIME, &timeStart);
	int done=0;
	while (!done) {
		while (XPending(dpy)) {
			XEvent e;
			XNextEvent(dpy, &e);
			check_resize(&e);
			check_mouse(&e);
			done = check_keys(&e);
		}
		clock_gettime(CLOCK_REALTIME, &timeCurrent);
		timeSpan = timeDiff(&timeStart, &timeCurrent);
		timeCopy(&timeStart, &timeCurrent);
		physicsCountdown += timeSpan;
		while (physicsCountdown >= physicsRate) {
			physics(&game);
			physicsCountdown -= physicsRate;
		}
		render(&game);
		glXSwapBuffers(dpy, win);
	}
	cleanupXWindows();
	cleanup_fonts();
	logClose();
	return 0;
}
Пример #3
0
int main(void)
{
	int done = 0;
	srand(time(NULL));
	initXWindows();
	init_opengl();
	//declare game object
	Game game;
	game.n = 0;

	//declare a box shape
	//game.box.width = 100;
	//game.box.height = 10;
	//game.box.center.x = 120 + 5*65;
	//game.box.center.y = 500 - 5*60;

	//start animation
	while (!done) {
		while (XPending(dpy)) {
			XEvent e;
			XNextEvent(dpy, &e);
			check_mouse(&e, &game);
			done = check_keys(&e);
		}
		movement(&game);
		render(&game);
		bubbles(&game);
		glXSwapBuffers(dpy, win);
	}
	cleanupXWindows();
	return 0;
}
Пример #4
0
int
main(int argc, char **argv)
{
    glutInit(&argc, argv);

    if (--argc != 1)
    {
        printf("Usage: %s file.scn\n", argv[0]);
        exit(-1);
    }

    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);

    glutInitWindowSize(framebuffer_width, framebuffer_height);

    glutInitWindowPosition(20, 100);
    glutCreateWindow("Ray tracing");

    glutDisplayFunc(&draw_scene);
    glutIdleFunc(&draw_scene);
    glutReshapeFunc(&resize);
    //glutSpecialFunc(&specialKeyPressed);
    glutKeyboardFunc(&key_pressed);
    glutMouseFunc(&mouse_func);
    glutMotionFunc(&motion_func);

	read_scene(argv[1]);

    init_opengl();
    init_noise();

    glutMainLoop();

    return 1;
}
Пример #5
0
bool has_glx_video_sync_support(const QString &glx_ext)
{
    init_opengl();

    if (!glx_ext.contains("GLX_SGI_video_sync"))
        return false;

    return gMythGLXGetVideoSyncSGI && gMythGLXWaitVideoSyncSGI;
}
Пример #6
0
int main(int argc, char **argv) {
    init_sdl();
    init_opengl();

    while (1) {
        render_frame();
        handle_input();
    }
    
    return 0;
}
Пример #7
0
int main(void)
{
        int done=0;
        srand(time(NULL));
        initXWindows();
        init_opengl();
        //declare game object
        Game game;
        game.n=0;
	
	clock_gettime(CLOCK_REALTIME, &timePause);
	clock_gettime(CLOCK_REALTIME, &timeStart);

        //declare a box shape
	for(int i = 0; i<5; i++)
	{
        	game.box[i].width = 100;
        	game.box[i].height = 15;
       		
		game.box[i].center.x = 120 + (60*i);
       		game.box[i].center.y = 500 - (100*i);
	}

	game.circle.radius = .5;
        game.circle.center.x = 60 + 9*65;
        game.circle.center.y = 450- 8*60;


        //start animation
        while(!done) {
                while(XPending(dpy)) {
                        XEvent e;
                        XNextEvent(dpy, &e);
                        check_mouse(&e, &game);
                        done = check_keys(&e, &game);
		}

		clock_gettime(CLOCK_REALTIME, &timeCurrent);
		timeSpan = timeDiff(&timeStart, &timeCurrent);
		timeCopy(&timeStart, &timeCurrent);
		physicsCountdown += timeSpan;
		
		while(physicsCountdown >= physicsRate) {
			physics(&game);
			physicsCountdown -= physicsRate;
		}
                movement(&game);
                render(&game);
                glXSwapBuffers(dpy, win);
        }
        cleanupXWindows();
        return 0;
}
Пример #8
0
/**********************************************************************
 *	     dibdrv_wine_get_wgl_driver
 */
struct opengl_funcs *dibdrv_wine_get_wgl_driver( PHYSDEV dev, UINT version )
{
    if (version != WINE_WGL_DRIVER_VERSION)
    {
        ERR( "version mismatch, opengl32 wants %u but dibdrv has %u\n", version, WINE_WGL_DRIVER_VERSION );
        return NULL;
    }

    if (!init_opengl()) return (void *)-1;

    return &opengl_funcs;
}
Пример #9
0
int main(void)
{
	logOpen();
	initXWindows();
	init_opengl();
	init();
	init_sounds();
	clock_gettime(CLOCK_REALTIME, &timePause);
	clock_gettime(CLOCK_REALTIME, &timeStart);
	while(!done) {
		while(XPending(dpy)) {
			XEvent e;
			XNextEvent(dpy, &e);
			check_resize(&e);
			check_mouse(&e);
			check_keys(&e);
		}
		//
		//Below is a process to apply physics at a consistent rate.
		//1. Get the time right now.
		clock_gettime(CLOCK_REALTIME, &timeCurrent);
		//2. How long since we were here last?
		timeSpan = timeDiff(&timeStart, &timeCurrent);
		//3. Save the current time as our new starting time.
		timeCopy(&timeStart, &timeCurrent);
		//4. Add time-span to our countdown amount.
		physicsCountdown += timeSpan;
		//5. Has countdown gone beyond our physics rate? 
		//       if yes,
		//           In a loop...
		//              Apply physics
		//              Reducing countdown by physics-rate.
		//              Break when countdown < physics-rate.
		//       if no,
		//           Apply no physics this frame.
		while(physicsCountdown >= physicsRate) {
			//6. Apply physics
			physics();
			//7. Reduce the countdown by our physics-rate
			physicsCountdown -= physicsRate;
		}
		//Always render every frame.
		render();
		glXSwapBuffers(dpy, win);
	}
	cleanupXWindows();
	cleanup_fonts();
	#ifdef USE_SOUND
	fmod_cleanup();
	#endif //USE_SOUND
	logClose();
	return 0;
}
Пример #10
0
int main(void)
{
	int done=0;
	srand(time(NULL));
	initXWindows();
	init_opengl();
	//declare game object
	Game game;
	game.n=0;
	game.bubble = 0;

	//declare a box shape
	game.box[0].width = 100;
	game.box[0].height = 15;
	game.box[0].center.x = 150;
	game.box[0].center.y = 500;
	game.box[1].width = 100;
	game.box[1].height = 15;
	game.box[1].center.x = 250;
	game.box[1].center.y = 425;
	game.box[2].width = 100;
	game.box[2].height = 15;
	game.box[2].center.x = 350;
	game.box[2].center.y = 350;
	game.box[3].width = 100;
	game.box[3].height = 15;
	game.box[3].center.x = 450;
	game.box[3].center.y = 275;
	game.box[4].width = 100;
	game.box[4].height = 15;
	game.box[4].center.x = 550;
	game.box[4].center.y = 200;
	game.circle.center.x = 700;
	game.circle.center.y = 50;
	game.circle.radius = 125;
	

	//start animation
	while(!done) {
		while(XPending(dpy)) {
			XEvent e;
			XNextEvent(dpy, &e);
			check_mouse(&e, &game);
			done = check_keys(&e, &game);
		}
		movement(&game);
		render(&game);
		glXSwapBuffers(dpy, win);
	}
	cleanupXWindows();
	return 0;
}
  renderer_opengl() {
    // Init member variables so realloc'll work
    screen   = NULL;
    vertexes = NULL;
    fg       = NULL;
    bg       = NULL;
    tex      = NULL;
    zoom_steps = forced_steps = 0;
    
    // Disable key repeat
    SDL_EnableKeyRepeat(0, 0);
    // Set window title/icon.
    SDL_WM_SetCaption(GAME_TITLE_STRING, NULL);
    SDL_Surface *icon = IMG_Load("data/art/icon.png");
    if (icon != NULL) {
      SDL_WM_SetIcon(icon, NULL);
      // The icon's surface doesn't get used past this point.
      SDL_FreeSurface(icon); 
    }
    
    // Find the current desktop resolution if fullscreen resolution is auto
    if (init.display.desired_fullscreen_width  == 0 ||
        init.display.desired_fullscreen_height == 0) {
      const struct SDL_VideoInfo *info = SDL_GetVideoInfo();
      init.display.desired_fullscreen_width = info->current_w;
      init.display.desired_fullscreen_height = info->current_h;
    }

    // Initialize our window
    bool worked = init_video(enabler.is_fullscreen() ?
                             init.display.desired_fullscreen_width :
                             init.display.desired_windowed_width,
                             enabler.is_fullscreen() ?
                             init.display.desired_fullscreen_height :
                             init.display.desired_windowed_height);

    // Fallback to windowed mode if fullscreen fails
    if (!worked && enabler.is_fullscreen()) {
      enabler.fullscreen = false;
      report_error("SDL initialization failure, trying windowed mode", SDL_GetError());
      worked = init_video(init.display.desired_windowed_width,
                          init.display.desired_windowed_height);
    }
    // Quit if windowed fails
    if (!worked) {
      report_error("SDL initialization failure", SDL_GetError());
      exit(EXIT_FAILURE);
    }

    // Initialize opengl
    init_opengl();
  }
Пример #12
0
bool has_gl_fbuffer_object_support(const QString &ext)
{
    init_opengl();

    if (!ext.contains("GL_EXT_framebuffer_object"))
        return false;

    return (gMythGLGenFramebuffersEXT      &&
            gMythGLBindFramebufferEXT      &&
            gMythGLFramebufferTexture2DEXT &&
            gMythGLDeleteFramebuffersEXT   &&
            gMythGLCheckFramebufferStatusEXT);
}
Пример #13
0
int get_gl_texture_rect_type(const QString &ext)
{
    init_opengl();

    if (ext.contains("GL_NV_texture_rectangle"))
        return GL_TEXTURE_RECTANGLE_NV;
    else if (ext.contains("GL_ARB_texture_rectangle"))
        return GL_TEXTURE_RECTANGLE_ARB;
    else if (ext.contains("GL_EXT_texture_rectangle"))
        return GL_TEXTURE_RECTANGLE_EXT;

    return 0;
}
Пример #14
0
int main(void)
{
	int done=0;
	srand(time(NULL));
	initXWindows();
	init_opengl();
	//declare game object
	Game game;
	game.n=0;

	//declare a box shape
	game.box[0].width = 100;
	game.box[0].height = 10;
	game.box[0].center.x = 270 + 5*65;
	game.box[0].center.y = 500 - 5*60;
    game.box[1].width = 100;
    game.box[1].height = 10;
    game.box[1].center.x = 270 + 5*65 - 75;
    game.box[1].center.y = 500 - 5*60 + 45;
    game.box[2].width = 100;
    game.box[2].height = 10;
    game.box[2].center.x = 270 + 5*65 - 150;
    game.box[2].center.y = 500 - 5*60 + 90;
    game.box[3].width = 100;
    game.box[3].height = 10;
    game.box[3].center.x = 270 + 5*65 - 225;
    game.box[3].center.y = 500 - 5*60 + 135;
    game.box[4].width = 100;
    game.box[4].height = 10;
    game.box[4].center.x = 270 + 5*65 - 300;
    game.box[4].center.y = 500 - 5*60 + 180;
	game.circle.center.x = 760;
	game.circle.center.y = -25;
	game.circle.radius = 100;

	//start animation
	while(!done) {
		while(XPending(dpy)) {
			XEvent e;
			XNextEvent(dpy, &e);
			check_mouse(&e, &game);
			done = check_keys(&e, &game);
		}
		movement(&game);
		render(&game);
		glXSwapBuffers(dpy, win);
	}
	cleanupXWindows();
	cleanup_fonts();
	return 0;
}
Пример #15
0
bool has_gl_fragment_program_support(const QString &ext)
{
    init_opengl();

    if (!ext.contains("GL_ARB_fragment_program"))
        return false;

    return (gMythGLGenProgramsARB    &&
            gMythGLBindProgramARB    &&
            gMythGLProgramStringARB  &&
            gMythGLDeleteProgramsARB &&
            gMythGLGetProgramivARB   &&
            gMythGLProgramEnvParameter4fARB);
}
// realize_main: Called when map_area is realized
// ------------------------------------------- >>
static void realize_main(GtkWidget *widget, gpointer data)
{
	//GdkGLContext *glcontext = gtk_widget_get_gl_context(widget);
	GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable(widget);

	if (!gdk_gl_drawable_gl_begin(gldrawable, glcontext))
		return;

	vid_width = widget->allocation.width;
	vid_height = widget->allocation.height;
	init_opengl();
	update_map();
	update_grid();

	gdk_gl_drawable_gl_end (gldrawable);
}
Пример #17
0
void check_keys(XEvent *e)
{
	//Was there input from the keyboard?
	if (e->type == KeyPress) {
		int key = XLookupKeysym(&e->xkey, 0);
		switch(key) {
			case XK_1:
				lesson_num = 1;
				init_opengl();
				break;
			case XK_3:
				lesson_num = 3;
				init_opengl();
				break;
			case XK_4:
				lesson_num = 4;
				init_opengl();
				break;
			case XK_5:
				lesson_num = 5;
				init_opengl();
				break;
			case XK_6:
				lesson_num = 6;
				init_opengl();
				break;
			case XK_7:
				lesson_num = 7;
				init_opengl();
				break;
			case XK_8:
				lesson_num = 8;
				init_opengl();
				break;
            case XK_9:
                lesson_num = 9;
                init_opengl();
                break;
			case XK_Escape:
				done=1;
				break;
		}
	}
}
Пример #18
0
int main(int argc, char* argv[]) {
	std::cout << "Raytracer Starting ..." << std::endl;

	// Setup OpenGL and CUDA
	std::cout << "Setting up CUDA" << std::endl;
	setup_cuda(argc, argv);
	std::cout << "Initializing OpenGL" << std::endl;
 	init_opengl(argc, argv);
 	std::cout << "Initializing Scene and Camera" << std::endl;
 	if (argc == 2) {
 		initialize_tracer(argv[1]);
 	} else {
 		initialize_tracer((char*)"meshes/two_triangles.obj");
 	}
 	std::cout << "Beginning Raytracer Execution Loop" << std::endl;
 	glutMainLoop();
}
Пример #19
0
render_context_type *render_init(void *machine_context, void *process_context)
{
	render_context_type *rc;
	rc=malloc(sizeof(render_context_type));
	rc->machine_context=machine_context;
	rc->process_context=process_context;
	rc->no_signal_flag=0;
	rc->no_device_flag=0;
	if (SDL_Init (SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0)
    {
      printf ("Unable to init SDL: %s\n", SDL_GetError ());
      exit (1);
    }
    machine_get_area(rc->machine_context,&rc->tx0,&rc->ty0,&rc->tx1,&rc->ty1);
	init_opengl(rc);
	return rc;
}
Пример #20
0
void canvashdl::swap_buffers()
{
	if (!initialized)
		init_opengl();

	if (last_reshape_time > 0.0 && get_time() - last_reshape_time > 0.125)
		resize(reshape_width, reshape_height);

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glUseProgram(screen_shader);
	check_error(__FILE__, __LINE__);

	glActiveTexture(GL_TEXTURE0);
	check_error(__FILE__, __LINE__);
	glBindTexture(GL_TEXTURE_2D, screen_texture);
	check_error(__FILE__, __LINE__);
	glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, color_buffer);
	check_error(__FILE__, __LINE__);
	glUniform1i(glGetUniformLocation(screen_shader, "tex"), 0);
	check_error(__FILE__, __LINE__);

	glBindBuffer(GL_ARRAY_BUFFER, screen_geometry);
	check_error(__FILE__, __LINE__);
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
	check_error(__FILE__, __LINE__);
	glEnableClientState(GL_VERTEX_ARRAY);
	check_error(__FILE__, __LINE__);

	glTexCoordPointer(2, GL_FLOAT, sizeof(GLfloat)*4, (float*)(sizeof(GLfloat)*2));
	check_error(__FILE__, __LINE__);
	glVertexPointer(2, GL_FLOAT, sizeof(GLfloat)*4, NULL);
	check_error(__FILE__, __LINE__);

	glDrawArrays(GL_TRIANGLES, 0, 6);
	check_error(__FILE__, __LINE__);

	glDisableClientState(GL_VERTEX_ARRAY);
	check_error(__FILE__, __LINE__);
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
	check_error(__FILE__, __LINE__);

	glutSwapBuffers();
	check_error(__FILE__, __LINE__);
}
Пример #21
0
int main(int argc, const char * argv[])
{
  glutInitDisplayString("rgba>=8 depth double");
  glutInitWindowSize(768, 768);
  glutInit( &argc, (char **) argv);
  glutCreateWindow( "gbsd" );

  init_opengl();
  gbsdSize = std::min( gbsdSize, int(1<<24)-gbsdOffset );

  
  glutDisplayFunc( display );
  glutReshapeFunc( reshape );
  glutKeyboardFunc( keyboard );
  glutMainLoop();
  
  return 0;
}
// configure_event: Called when the map area is resized or initialised
// ---------------------------------------------------------------- >>
gboolean configure_event(GtkWidget *widget, GdkEventConfigure *event)
{
	GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable(widget);

	if (!gdk_gl_drawable_gl_begin(gldrawable, glcontext))
		return FALSE;

	glViewport(0, 0, widget->allocation.width, widget->allocation.height);
	vid_width = widget->allocation.width;
	vid_height = widget->allocation.height;
	init_opengl();
	
	force_map_redraw(true, true);

	gdk_gl_drawable_gl_end (gldrawable);

	return true;
}
Пример #23
0
int main(void)
{
	int done=0;
	srand(time(NULL));
	initXWindows();
	init_opengl();
	//declare game object
	Game game;
	game.n=0;

	//set bubbler to false
	game.bubbler = false;

	// circle coordinates
	game.circle.radius = RADIUS;
	game.circle.center.x = 460.0;
	game.circle.center.y = 1.0;

	//declare boxes
	for(int x = 0; x < 5; ++x)
	{
		game.box[x].width = BOX_WIDTH;
		game.box[x].height = BOX_HEIGHT;
		game.box[x].center.x = 100 + 50*x;
		game.box[x].center.y = 600 - 5*60 - 50*x;
	}

	//start animation
	while(!done) {
		while(XPending(dpy)) {
			XEvent e;
			XNextEvent(dpy, &e);
			check_mouse(&e, &game);
			done = check_keys(&e, &game);
		}
		movement(&game);
		render(&game);
		glXSwapBuffers(dpy, win);
	}
	cleanupXWindows();
	return 0;
}
Пример #24
0
int main(void)
{
    int done=0;
    srand(time(NULL));
    initXWindows();
    init_opengl();
    init_sounds();

    clock_gettime(CLOCK_REALTIME, &timePause);
    clock_gettime(CLOCK_REALTIME, &timeStart);
    //declare game object
    Game game;

    fmod_playsound(1);
    //start animation
    while(!done) {
	while(XPending(dpy)) {
	    XEvent e;
	    XNextEvent(dpy, &e);
	    check_resize(&e);
	    check_mouse(&e, &game);
	    done = check_keys(&e, &game);
	}
	clock_gettime(CLOCK_REALTIME, &timeCurrent);
	timeSpan = timeDiff(&timeStart, &timeCurrent);
	timeCopy(&timeStart, &timeCurrent);
	movementCountdown += timeSpan;
	while(movementCountdown >= movementRate)
	{
	    movement(&game);
	    movementCountdown -= movementRate;
	}
	render(&game);
	glXSwapBuffers(dpy, win);
    }
    cleanupXWindows();
    cleanup_fonts();
#ifdef USE_SOUND
    fmod_cleanup();
#endif //USE_SOUND
    return 0;
}
Пример #25
0
int main(void)
{
    int done=0;
    srand(time(NULL));
    initXWindows();
    init_opengl();


    //declare game object
    Game game;
    game.n=0;

    // used to check if jumped, already in the air
    game.space = false; // deny jumping til collision on floor


    //declare a box shape
    game.box.width = BOX_WIDTH;
    game.box.height = BOX_HEIGHT;
    game.box.center.x = 20;//120 + 5*65;
    game.box.center.y = 10;//500 - 5*60;
    game.box.velocity.y = 0;
    game.box.velocity.x = 0;
    //start animation
    while(!done) {
        while(XPending(dpy)) {
            XEvent e;
            XNextEvent(dpy, &e);
            check_mouse(&e, &game);
            check_resize(&e);
            done = check_keys(&e, &game);
        }

        movement(&game);
        render(&game);
        glXSwapBuffers(dpy, win);
    }


    cleanupXWindows();
    return 0;
}
Пример #26
0
void				connection()
{
	extern t_client		t;
	struct sockaddr_in	sin;

	t.s = socket(PF_INET, SOCK_STREAM, 0);
	sin.sin_family = AF_INET;
	sin.sin_port = htons(t.port);
	sin.sin_addr.s_addr = inet_addr(t.adresse);
	connect(t.s, (struct sockaddr *)&sin, sizeof (sin));
	t.buf = malloc(4096 * sizeof(*t.buf));
	t.size = recv(t.s, t.buf, 256, 0);
	t.buf[t.size] = '\0';
	t.x_position = 0;
	t.y_position = 0;
	t.z_position = 0;
	if (my_strcmp(t.buf, "BIENVENUE\n") == 0)
	{
		t.equipe = my_strcat(t.equipe, "\n");
		send(t.s, t.equipe, my_strlen(t.equipe), 0);
		t.size = recv(t.s, t.buf, 256, 0);
		t.buf[t.size] = '\0';
		if (my_getnbr(t.buf) >= 1)
		{
			get_sizemap();
			init_opengl();
			get_map();
			t.cam_flag = 0;
			t.continuer = 1;
			while (t.continuer)
			{
				camera();
				draw_map();
				/*get_map();*/
			}
			SDL_EnableKeyRepeat(0, 0);
			SDL_Quit();
		}
	}
	close(t.s);
}
Пример #27
0
int main(void)
{
    logOpen();
    initXWindows();
    init_opengl();
    init();
    //buttonsInit();------------------------------------------------------------------
    init_sounds();
    clock_gettime(CLOCK_REALTIME, &timePause);
    clock_gettime(CLOCK_REALTIME, &timeStart);
    while(!done) {
        while(XPending(dpy)) {
            XEvent e;
            XNextEvent(dpy, &e);
            check_resize(&e);
            check_mouse(&e);
            GOcheck_mouse(&e);
            check_keys(&e);

        }
        clock_gettime(CLOCK_REALTIME, &timeCurrent);
        timeSpan = timeDiff(&timeStart, &timeCurrent);
        timeCopy(&timeStart, &timeCurrent);
        physicsCountdown += timeSpan;
        while(physicsCountdown >= physicsRate) {
            physics();
            physicsCountdown -= physicsRate;
        }
        render();
        glXSwapBuffers(dpy, win);
    }
    cleanupXWindows();
    cleanup_fonts();
#ifdef USE_SOUND
    fmod_cleanup();
#endif //USE_SOUND
    logClose();
    return 0;
}
Пример #28
0
int main(void)
{
    int done=0;
    srand(time(NULL));
    initXWindows();
    init_opengl();
    //declare game object
    Game game;
    game.n=0;

    //declare a box shape

    for (int i = 0; i < 5; i++) {
	game.box[i].width = 70 + i*5;
	game.box[i].height = 10;
	game.box[i].center.x = 120 + (i*80);
	game.box[i].center.y = 500 - (i*70);
    }

    game.circle.center.x = 700;
    game.circle.center.y = 0;
    game.circle.radius = 200;

    //start animation
    while(!done) {
	while(XPending(dpy)) {
	    XEvent e;
	    XNextEvent(dpy, &e);
	    //check_mouse(&e, &game);
	    done = check_keys(&e, &game);
	}
	makeParticle(&game,35,550);
	movement(&game);
	render(&game);
	glXSwapBuffers(dpy, win);
    }
    cleanupXWindows();
    return 0;
}
Пример #29
0
int main(void)
{
    int done=0;
    srand(time(NULL));
    initXWindows();
    Game game;
    DefineRagdoll(&game);
    init_opengl(&game);
    create_sounds();
    play();
    //declare game object
    init_keys();
    clock_gettime(CLOCK_REALTIME, &timePause);
    clock_gettime(CLOCK_REALTIME, &timeStart);

    //start animation
    while(!done) {
	while(XPending(dpy)) {
	    XEvent e;
	    XNextEvent(dpy, &e);
	    check_mouse(&e, &game);
	    check_resize(&game, &e);
	    done = check_keys(&e);
	}
	clock_gettime(CLOCK_REALTIME, &timeCurrent);
	timeSpan = timeDiff(&timeStart, &timeCurrent);
	timeCopy(&timeStart, &timeCurrent);
	physicsCountdown += timeSpan;
	while(physicsCountdown >= physicsRate) {
	    movement(&game);
	    physicsCountdown -= physicsRate;
	}
	render(&game);
	glXSwapBuffers(dpy, win);
    }
    cleanupXWindows();
    cleanup_fonts();
    return 0;
}
 // Parameters: window size
 void resize(int w, int h) {
   // (Re)calculate grid-size
   dispx = enabler.is_fullscreen() ?
     init.font.large_font_dispx :
     init.font.small_font_dispx;
   dispy = enabler.is_fullscreen() ?
     init.font.large_font_dispy :
     init.font.small_font_dispy;
   natural_w = MAX(w / dispx,1);
   natural_h = MAX(h / dispy,1);
   // Compute forced_steps so we satisfy our grid-size limits
   compute_forced_zoom();
   // Force a full display cycle
   gps.force_full_display_count = 1;
   enabler.flag |= ENABLERFLAG_RENDER;
   // Reinitialize the video
   uninit_opengl();
   init_video(w, h);
   init_opengl();
   // Only reshape if we're free to pick grid size
   if (enabler.overridden_grid_sizes.size() == 0)
     reshape(compute_zoom());
 }