本文整理汇总了C++中Render::init_GL方法的典型用法代码示例。如果您正苦于以下问题:C++ Render::init_GL方法的具体用法?C++ Render::init_GL怎么用?C++ Render::init_GL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Render
的用法示例。
在下文中一共展示了Render::init_GL方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
//Make sure the program waits for a quit
bool running = true;
bool step = false;
bool quit = false;
SDL_MouseMotionEvent mme;
init();
Render *pRender = Render::GetInstance();
pRender->init_GL();
// We grab the input so that we receive mouse movement
// even when the mouse is beyond the edge of the screen
SDL_ShowCursor(0);
SDL_WM_GrabInput( SDL_GRAB_ON );
#if TWEAK_MENU
TwInit(TW_OPENGL, NULL);
TwWindowSize(SCREEN_W, SCREEN_H);
myBar = TwNewBar("Tweak");
#endif // TWEAK_MENU
// Initialize the FPS tracking variables
Uint32 nextFPSCount = SDL_GetTicks() + 1000;
int frames = 0;
int prevTime = SDL_GetTicks();
Simulation *pSimulation = Simulation::GetSimulation();
pSimulation->Init();
while( quit == false )
{
while( SDL_PollEvent( &event ) )
{
#if TWEAK_MENU
int handled = TwEventSDL(&event, SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
if( handled )
continue;
#endif // TWEAK_MENU
switch( event.type )
{
case SDL_QUIT:
quit = true;
break;
case SDL_MOUSEMOTION:
mme = event.motion;
pSimulation->UpdateMouseMotion( mme );
break;
case SDL_KEYDOWN:
pSimulation->UpdateKeys(event.key.keysym.sym, true);
switch( event.key.keysym.sym )
{
case SDLK_1:
break;
case SDLK_RIGHT:
step = true;
break;
case SDLK_ESCAPE:
quit=true;
break;
}
break;
case SDL_KEYUP:
pSimulation->UpdateKeys(event.key.keysym.sym, false);
switch( event.key.keysym.sym )
{
case SDLK_RIGHT:
break;
}
break;
}
}
if( running || step )
{
step = false;
StartFrame();
int newTime = SDL_GetTicks();
float elapsed = (float)(newTime - prevTime) / 1000.0f;
if( elapsed > 0.05f )
elapsed = 0.05f; // Clamp long dt's down
if( elapsed < 0.001f)
continue; // dt too short. Skip to next frame (without updating prevTime so dt grows).
prevTime = newTime;
pSimulation->DrawFrame(); // Render all sprites
const int subSteps = 1;
for( int i=0; i<subSteps; i++ )
{
pSimulation->SimulateOneFrame(elapsed / subSteps); // Logic update for Simulation
}
#if TWEAK_MENU
TwDraw();
#endif // TWEAK_MENU
EndFrame();
//.........这里部分代码省略.........