本文整理汇总了C++中OnRender函数的典型用法代码示例。如果您正苦于以下问题:C++ OnRender函数的具体用法?C++ OnRender怎么用?C++ OnRender使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了OnRender函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
/**
* @brief Called on keypresses, clicks, etc.
*
* @param[in] event Describes the event that occurred.
*/
void MazeSolverApp::OnEvent(SDL_Event* event)
{
if(event->type == SDL_QUIT)
{
running = false;
}
else if (event->type == SDL_KEYDOWN)
{
if (event->key.keysym.unicode == 'd')
{
/* Solve the maze with a depth-first search. */
if (solver)
{
delete solver;
solver = NULL;
}
solver = (MazeSolverBase *) new DepthFirstSolver(this);
solver->solve(maze);
OnRender();
}
else if (event->key.keysym.unicode == 'b')
{
/* Solve the maze with a breadth-first search. */
if (solver)
{
delete solver;
solver = NULL;
}
solver = (MazeSolverBase *) new BreadthFirstSolver(this);
solver->solve(maze);
OnRender();
}
else if (event->key.keysym.unicode == 'r')
{
/* Reset the maze. */
if (solver)
{
delete solver;
solver = NULL;
}
rb->create_maze();
OnRender();
}
else if (event->key.keysym.unicode == 'q')
{
running = false;
}
}
}
示例2: while
//------------------------------------------------------------------------------
int CApp::OnExecute() {
if(OnInit() == false) {
return -1;
}
SDL_Event Event;
while(Running) {
if(AIenabled && CurrentPlayer && GameState == GAME_STATE_RUNNING)
{
GameClick(AIMove());
}
while(SDL_PollEvent(&Event)) {
OnEvent(&Event);
}
OnLoop();
OnRender();
}
OnCleanup();
return 0;
}
示例3: while
int SampleApp::MainLoop()
{
MSG msg = { 0 };
while (WM_QUIT != msg.message)
{
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
LARGE_INTEGER pc;
QueryPerformanceCounter(&pc);
if (pc.QuadPart - prevCounter.QuadPart >= counterPerFrame)
{
LONGLONG elapsed = pc.QuadPart - prevCounter.QuadPart;
prevCounter = pc;
OnUpdate(elapsed);
OnRender();
}
}
}
return (int)msg.wParam;
}
示例4: main
int main(int argc,char ** argv)
{
// start GL context and O/S window using the GLFW helper library
appDelegate.AppWillStart();
FPS_Helper fpsHelper;
fpsHelper.SetFixedFPS(30);
InitOpenGL();
appDelegate.AppDidStart();
while (!glfwWindowShouldClose (mainWnd.window))
{
// wipe the drawing surface clear
static double timer_last = 0;
double curr_time = glfwGetTime();
if(curr_time - timer_last > 0.2)
{
timer_last = timer_last + 0.02;
OnTimer();
}
if(fpsHelper.Tick())
{
OnRender();
// update other events like input handling
glfwPollEvents ();
// put the stuff we've been drawing onto the display
glfwSwapBuffers (mainWnd.window);
}
}
// close GL context and any other GLFW resources
appDelegate.AppWillTerminate();
glfwTerminate();
return 0;
}
示例5: while
//Holds game logic together
int Game::OnStart() {
//Initialize the game
if (OnInit() == false) {
return -1;
}
SDL_Event Event;
//While game is running
while (running) {
while (gameType == 0 && running) {
while (SDL_PollEvent(&Event)) {
OnEvent(&Event);
}
//meanwhile show menu
showMenu();
}
while (SDL_PollEvent(&Event)) {
//Handle user input
OnEvent(&Event);
}
OnLoop();
OnRender();
}
OnCleanUp();
return 0;
};
示例6: SDL_Delay
void ConvexHullApp::add_to_hull(Tuple *p)
{
hull.push_back(p);
SDL_Delay(ANIMATION_DELAY);
OnRender();
}
示例7: WndProc
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
if ((message >= WM_MOUSEFIRST && message <= WM_MOUSELAST) ||
(message >= WM_KEYFIRST && message <= WM_KEYLAST) ||
(message >= WM_TOUCH && message <= WM_POINTERWHEEL))
{
GetCurrentInputMessageSource(&g_inputSource);
InvalidateRect(g_hwnd, NULL, FALSE);
}
switch (message)
{
case WM_PAINT:
case WM_DISPLAYCHANGE:
{
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hwnd, &ps);
OnRender(hdc, ps.rcPaint);
EndPaint(hwnd, &ps);
}
return 0;
case WM_DESTROY:
{
PostQuitMessage(0);
}
return 1;
}
return DefWindowProc(hwnd, message, wParam, lParam);
}
示例8: while
int Main::OnExecute(CL_ParamList* pCL_Params)
{
if(!OnInit(pCL_Params))
return -1;
SDL_Event Event;
Uint32 t1,t2;
float fTime = 0.0f;
while(Running)
{
t1 = SDL_GetTicks();
while(SDL_PollEvent(&Event))
{
if(Event.type == SDL_QUIT)
Running = false;
else OnEvent(&Event);
}
OnMove(fTime);
OnRender();
t2 = SDL_GetTicks();
fTime = (float)(t2-t1)/1000.0f;
}
OnExit();
return 1;
}
示例9: CreateAsteroid
void Game::OnExecute()
{
if (m_state != GameState::INIT_SUCCESSFUL)
{
std::cerr << "Game INIT was not successful." << std::endl;
return;
}
m_state = GameState::RUNNING;
CreateAsteroid(Asteroids::Asteroid::AsteroidSize::BIG, 1);
SDL_Event event;
while (m_state == GameState::RUNNING)
{
// Input polling
//
while (SDL_PollEvent(&event))
{
OnEvent(&event);
}
//
OnUpdate();
OnRender();
}
}
示例10: OnRender
// Called whenever the client area needs to be drawn
HRESULT FirstTry::OnPaint()
{
// Update the animation manager with the current time
UI_ANIMATION_SECONDS secondsNow;
HRESULT hr = m_pAnimationTimer->GetTime(&secondsNow);
if (SUCCEEDED(hr))
{
hr = m_pAnimationManager->Update(secondsNow);
// Read the values of the animation variables and draw the client area
hr = OnRender();
if (SUCCEEDED(hr))
{
// Continue redrawing the client area as long as there are animations scheduled.
UI_ANIMATION_MANAGER_STATUS status;
hr = m_pAnimationManager->GetStatus(&status);
if (SUCCEEDED(hr))
{
if (status == UI_ANIMATION_MANAGER_BUSY)
{
InvalidateRect(m_hwnd, NULL, FALSE);
}
}
}
}
return hr;
}
示例11: if
/**
* @brief Called on keypresses, clicks, etc.
*
* @param[in] event Describes the event that occurred.
*/
void LineApp::OnEvent(SDL_Event* event)
{
if(event->type == SDL_QUIT)
{
running = false;
}
else if (event->type == SDL_KEYDOWN)
{
if (event->key.keysym.unicode == 'q')
{
running = false;
}
else if (event->key.keysym.unicode == 'l')
{
DoLineAlg();
}
else if (event->key.keysym.unicode == 'c')
{
delete_all();
}
}
else if (event->type == SDL_MOUSEBUTTONDOWN)
{
if (event->button.state == SDL_PRESSED)
{
int x = event->button.x;
int y = event->button.y;
points.push_back(new Tuple(x, y));
}
OnRender();
}
}
示例12: while
void MainGameLoop::Run()
{
FrameCounter fc;
// main game loop
while (!m_bExitLoop)
{
OnTick();
ProcessEvents();
if (m_bExitLoop)
break;
if (!m_bAppActive)
{
// as we're not visible, just wait for next event
SDL_WaitEvent(NULL);
continue;
}
// render the scene
{
OpenGL::ResetPolycount();
OnRender();
fc.OnNextFrame();
}
// count ticks for fps
double dFramesPerSecond;
if (m_bUpdateFrameCount && fc.GetUpdatedCount(dFramesPerSecond))
UpdateCaption(dFramesPerSecond);
}
}
示例13: while
void CApplication::MainLoop()
{
SDL_Event event;
Uint32 startTime, elapsedTime;
while( !m_Quit )
{
// Le temps avant l'éxécution
startTime = SDL_GetTicks();
// Tant qu'il y a des messages, les traiter
while( SDL_PollEvent(&event) )
{
OnEvent(event);
}
// Mise à jour de la scène
OnUpdate();
// Démarrer le rendu
m_Renderer.BeginScene();
OnRender();
m_Renderer.EndScene();
// Si on a mis moins de temps que le nombre de FPS demandé, on attend
// permet de limiter les fps et de gagner du temps de process CPU
if( (elapsedTime = SDL_GetTicks()-startTime) < m_FPSLimit )
{
SDL_Delay(m_FPSLimit - elapsedTime);
}
}
}
示例14: while
int App::OnExecute()
{
if(OnInit() == false)
{
return -1;
}
controller->Initialize();
SDL_Event Event;
while(running)
{
Scene* scene = controller->GetCurrentScene();
if (scene == NULL)
{
break;
}
if(SDL_PollEvent(&Event))
{
OnEvent(scene, &Event);
}
OnLoop(scene);
OnRender(scene);
}
OnCleanup();
return 0;
}
示例15: while
int CApp::OnExecute(){
if (OnInit() == false){
return -1;
}
SDL_Event Event;
while(Running){
while(SDL_PollEvent(&Event)){
OnEvent(&Event);
}
OnLoop();
OnRender();
}
OnCleanup();
return 0;
}