Example #1
0
int main()
{
    int frameCnt = 0;
    struct timeval curTime;
    float dSecond = 0;
    float dSecondSum = 0; /* droped if more than 0.5 sec */

    timeval_diff_replace(&curTime);

    flags.pause = GL_FALSE;
    flags.vsync = GL_TRUE;

    scene = newScene(flags.vsync);

    setupGLFWCallbacks();
    glfwSetMousePos(scene->context->w / 2, scene->context->h / 2);

    while (running)
    {
        if (glfwGetWindowParam(GLFW_OPENED) == GL_FALSE)
        {
            running = GL_FALSE;
            break;
        }

        processKeyboardEvents(dSecond * BASE_FPS);
        processMouseEvents(dSecond * BASE_FPS);

        ++frameCnt;
        dSecond = timeval_diff_replace(&curTime);
        dSecondSum += dSecond;

        if (dSecondSum > 0.5f)
        {
            viewFps(frameCnt, dSecondSum);
            frameCnt = 0;
            dSecondSum = 0.0f;
        }

        if (!flags.pause)
        {
            modifyWaterMesh(scene->water, dSecond);
        }

        draw();
        glfwSwapBuffers();
    }

    freeScene(scene);

    return EXIT_SUCCESS;
}
Example #2
0
gxGraphics::~gxGraphics(){
	if( _gamma ) _gamma->Release();
#ifdef PRO
	while( scene_set.size() ) freeScene( *scene_set.begin() );
#endif
	while( movie_set.size() ) closeMovie( *movie_set.begin() );
	while( font_set.size() ) freeFont( *font_set.begin() );
	while( canvas_set.size() ) freeCanvas( *canvas_set.begin() );

	set<string>::iterator it;
	for( it=font_res.begin();it!=font_res.end();++it ) RemoveFontResource( (*it).c_str() );
	font_res.clear();

	delete back_canvas;
	delete front_canvas;

	ds_dirDraw->Release();

	dirDraw->RestoreDisplayMode();
	dirDraw->Release();
}