void HandleKeyPressEvent(SDL_keysym * keysym) { switch(keysym -> sym) // which key have we got { case SDLK_F1 : // if it is F1 ToggleFullScreen(); // toggle between fullscreen and windowed mode break; case SDLK_ESCAPE: // if it is ESCAPE Quit(0); // quit after cleaning up case SDLK_UP : // If we hit the UP arrow Key g_Camera.MoveCamera(kSpeed); // Move Camera by a forward positive speed RenderScene(); // Redraw the scene to reflect changes break; case SDLK_DOWN : // If we hit the Down arrow Key g_Camera.MoveCamera(-kSpeed); // Move Camera backward by a negative speed RenderScene(); // Redraw the scene to reflect changes break; default: // any other key break; // nothing to do } }
void Menu(int value) { switch (value) { case GL_CULL_FACE: iCull = !iCull; glutSetWindowTitle("Stozek - GL_CULL_FACE"); RenderScene(); break; case GL_DEPTH_TEST: iDepth = !iDepth; glutSetWindowTitle("Stozek - GL_DEPTH_TEST"); RenderScene(); break; case GL_LINE: iOutline = true; glutSetWindowTitle("Stozek - GL_LINE"); RenderScene(); break; case GL_FILL: iOutline = false; glutSetWindowTitle("Stozek - GL_LINE"); RenderScene(); break; case EXIT: exit(0); } }
LRESULT CALLBACK WinProc(HWND hWnd,UINT uMsg, WPARAM wParam, LPARAM lParam) { LONG lRet = 0; PAINTSTRUCT ps; switch (uMsg) { case WM_SIZE: // If the window is resized if(!g_bFullScreen) // Do this only if we are in window mode { SizeOpenGLScreen(LOWORD(lParam),HIWORD(lParam));// LoWord=Width, HiWord=Height GetClientRect(hWnd, &g_rRect); // Get the window rectangle } break; case WM_PAINT: // If we need to repaint the scene BeginPaint(hWnd, &ps); // Init the paint struct EndPaint(hWnd, &ps); // EndPaint, Clean up break; case WM_KEYDOWN: //////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** //////////////////// switch(wParam) { // Check if we hit a key case VK_ESCAPE: PostQuitMessage(0); // Send a QUIT message break; case VK_UP: // If we hit the UP arrow key g_Camera.MoveCamera(kSpeed); // Move our camera forward by a positive speed RenderScene(); // Redraw the screen to reflect changes break; case VK_DOWN: // If we hit the DOWN arrow key g_Camera.MoveCamera(-kSpeed); // Move our camera backward by a negative speed RenderScene(); // Redraw the screen to reflect changes break; } break; //////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** //////////////////// case WM_CLOSE: // If the window is being closed PostQuitMessage(0); // Post a QUIT message to the window; // Release memory and restore settings break; default: // Return by default lRet = DefWindowProc (hWnd, uMsg, wParam, lParam); break; } return lRet; // Return by default }
static void Render(int frameNumber) { PixBufT *umap; int du = 2 * frameNumber; int dv = 4 * frameNumber; { MatrixStack3D *ms = GetObjectTranslation(scene, "Object"); StackReset(ms); PushScaling3D(ms, 1.25f, 1.25f, 1.25f); PushRotation3D(ms, 0, (float)(-frameNumber * 2), frameNumber); PushTranslation3D(ms, 0.0f, 0.0f, -2.0f); } if (effectNum == 0) { umap = NewPixBufWrapper(WIDTH, HEIGHT, uvmap->map.fast.u); PROFILE(PixBufClear) PixBufClear(shades); PROFILE(RenderScene) RenderScene(scene, shades); PixBufSetBlitMode(shades, BLIT_ADDITIVE); PixBufBlit(umap, 0, 0, orig, NULL); PixBufBlit(umap, 0, 0, shades, NULL); UVMapSetOffset(uvmap, du, dv); UVMapRender(uvmap, canvas); MemUnref(umap); } else { UVMapSetOffset(uvmap, du, dv); UVMapRender(uvmap, canvas); PROFILE(PixBufClear) PixBufClear(shades); PROFILE(RenderScene) RenderScene(scene, shades); PixBufSetColorMap(shades, colorMap); PixBufSetBlitMode(shades, BLIT_COLOR_MAP); PixBufBlit(canvas, 0, 0, shades, NULL); } c2p1x1_8_c5_bm(canvas->data, GetCurrentBitMap(), WIDTH, HEIGHT, 0, 0); }
void COpenGLView::OnDraw(CDC* pDC) { COpenGLViewClassDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // TODO: add draw code for native data here ::glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); PreRenderScene(); ::glPushMatrix(); RenderStockScene(); ::glPopMatrix(); ::glPushMatrix(); RenderScene(); ::glPopMatrix(); ::glFinish(); if ( FALSE == ::SwapBuffers( m_pDC->GetSafeHdc() ) ) { SetError(7); } }
bool Application::AppLoopFunc() { MSG msg; ZeroMemory(&msg,sizeof(MSG)); do {// Обработка всех сообщений while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { if (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } } ProcessKBInput(); switch (Globals.ERS.d) { case ERS::Draw::SCENE: RenderScene(); CCons.Draw(); break; case ERS::Draw::TEXTURE: RenderTexture(); }; SwapBuffersEXT(); } while ( !Globals.Exiting ); return true;// Выход }
void FGLRenderer::DrawScene(int drawmode) { static int recursion=0; if (camera != nullptr) { ActorRenderFlags savedflags = camera->renderflags; if (drawmode != DM_PORTAL && !r_showviewer) { camera->renderflags |= RF_INVISIBLE; } CreateScene(); camera->renderflags = savedflags; } else { CreateScene(); } GLRenderer->mClipPortal = NULL; // this must be reset before any portal recursion takes place. RenderScene(recursion); // Handle all portals after rendering the opaque objects but before // doing all translucent stuff recursion++; GLPortal::EndFrame(); recursion--; RenderTranslucent(); }
/////////////////////////////////////////////////////////////////////////////// // Main entry point for GLFW based programs int main( int argc , char * argv []) { // initialise GLFW if(!glfwInit()) throw std::runtime_error("glfwInit failed"); // open a window with GLFW glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3); glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 2); glfwOpenWindowHint(GLFW_WINDOW_NO_RESIZE, GL_TRUE); if(!glfwOpenWindow(800, 600, 0, 0, 0, 0, 0, 0, GLFW_WINDOW)) throw std::runtime_error("glfwOpenWindow failed. Can your hardware handle OpenGL 3.2?"); // initialise GLEW glewExperimental = GL_TRUE; //stops glew crashing on OSX :-/ if (GLEW_OK != glewInit()) throw std::runtime_error("glewInit failed"); // make sure OpenGL version 3.2 API is available if(!GLEW_VERSION_3_2) throw std::runtime_error("OpenGL 3.2 API is not available."); glfwSetWindowSizeCallback(ChangeSize); SetupRC(); while(glfwGetWindowParam(GLFW_OPENED) && !glfwGetKey( GLFW_KEY_ESC )) { RenderScene(); glfwSwapBuffers(); } glfwTerminate(); }
//envent handle void Display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); g_tbView.Apply(); //mouse control, which allows to rotate and move glPushMatrix(); glRotated(g_fAng,0,1,0); RenderScene(); glPopMatrix(); glPopMatrix(); //word vector<string> strs; strs.push_back("\"s\" key : idle on/off"); strs.push_back("SHIFT+\"f\" key : fullscreen on/off" ); strs.push_back("\"v\",\"e\",\"f\" key : switch vertex,edge,face drawing"); glColor3d(1.0,1.0,1.0); //drawString(); //draw the string view of the teapot glutSwapBuffers(); }
WPARAM MainLoop() { MSG msg; while(1) // Do our infinate loop { // Check if there was a message if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if(msg.message == WM_QUIT) // If the message wasnt to quit break; TranslateMessage(&msg); // Find out what the message does DispatchMessage(&msg); // Execute the message } else // if there wasn't a message { /////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// * g_Camera.Update(); // Update the camera data /////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// * RenderScene(); // Update the screen every frame (Not good in a game) } } DeInit(); // Clean up and free all allocated memory return(msg.wParam); // Return from the program }
void main() { PSphere Sphere1; PLightSource Light1,Light2; Scene = new Environment; Sphere1 = new Sphere(Vector(0,0,0),4); Sphere1->Ambient(0.3); Sphere1->Diffuse(0.2); Sphere1->Specular(0.7); Sphere1->Reflection(0.0); Sphere1->Refraction(0.0); Sphere1->PhongSize(30); Sphere1->DefMaterial.Med = Glass; Sphere1->Color(Red); Sphere1->Add(new Bumps(7.0)); Light1 = new PointLight(Vector(-10,8,-20),20); Light2 = new PointLight(Vector(10,8,-20),20); Scene->Add(Sphere1); Scene->Add(Light1); Scene->Add(Light2); Background = SkyBlue; InitNoise(); SetCamera(Vector(0,0,-7),Vector(0,0,1),Vector(0,1,0)); RenderScene(1.5,1.0,300,200,"SAMPLE70.TGA"); DoneNoise(); }
WPARAM MainLoop() { MSG msg; while(1) // Do our infinite loop { // Check if there was a message if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if(msg.message == WM_QUIT) // If the message wasn't to quit break; TranslateMessage(&msg); // Find out what the message does DispatchMessage(&msg); // Execute the message } else // If there wasn't a message { if(AnimateNextFrame(60)) // Make sure we only render 60 frames per second { RenderScene(); // Render the scene } } } DeInit(); // Clean up and free all allocated memory return(msg.wParam); // Return from the program }
bool GraphicsManager::RenderPreProcessing(Camera* cam) { bool result; renderPass = 0; // Render the scene as normal to the back buffer. result = RenderScene(cam, renderPass); if(!result) { return false; } renderPass = 1; // Render the refraction of the scene to a texture. result = RenderRefractionToTexture(cam, renderPass); if(!result) { return false; } renderPass = 2; // Render the reflection of the scene to a texture. result = RenderReflectionToTexture(cam, renderPass); if(!result) { return false; } return true; }
/////////////////////////////////////////////////////////////////////////////// // Rendering Thread Entry Point void RenderingThreadEntryPoint(void *pVoid) { // Setup the rendering context SetupRC(); // Main loop for rendering while(1) { // Check rendering state info, terminate if flagged if(CheckStates()) break; RenderScene(); // Swap buffers SwapBuffers(hDC); } // Do any necessary cleanup and terminate gluDeleteQuadric(pSphere); // Finally, shut down OpenGL Rendering context wglMakeCurrent(hDC, NULL); wglDeleteContext(hRC); _endthread(); // Terminate the thread nicely }
void Idle() { static double lastDeltas[3] = { 0.0, 0.0, 0.0 }; static const double REFRESH_TIME = 1.0/60.0; // monitor with 60 Hz // in milisec int t = glutGet(GLUT_ELAPSED_TIME); double newTime = (double)t*0.001; double deltaTime = newTime - g_appTime; if (deltaTime > REFRESH_TIME) deltaTime = REFRESH_TIME; // average: deltaTime = (deltaTime + lastDeltas[0] + lastDeltas[1] + lastDeltas[2]) * 0.25; g_appTime = g_appTime+deltaTime; // call Update: UpdateScene(deltaTime); // render frame: RenderScene(); // save delta: lastDeltas[0] = lastDeltas[1]; lastDeltas[1] = lastDeltas[2]; lastDeltas[2] = deltaTime; }
void SpecialKeys (int key, int x, int y) { switch (key) { case GLUT_KEY_LEFT: yRot -= 1; break; case GLUT_KEY_UP: xRot += 1; break; case GLUT_KEY_RIGHT: yRot+= 1; break; case GLUT_KEY_DOWN: xRot-= 1; break; } SetupRC(); RenderScene(); }
WPARAM MainLoop() { MSG msg; // This is where we load our accelerators for keyboard shortcuts HACCEL hAccelTable = LoadAccelerators(g_hInstance, MAKEINTRESOURCE(IDR_ACCELERATOR1)); while(1) // Do our infinite loop { // Check if there was a message if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if(msg.message == WM_QUIT) // If the message wasn't to quit break; // Check if there was keyboard command - if not, process messages like normal if(!TranslateAccelerator(g_hWnd, hAccelTable, &msg)) { TranslateMessage(&msg); // Find out what the message does DispatchMessage(&msg); // Execute the message } RenderScene(); // Since no animation, only render when the user does something } } DeInit(); // Clean up and free all allocated memory return(msg.wParam); // Return from the program }
void main() { Box *b = new Box(Vector(0,-2,5),Vector(8,0,3),Vector(-8,0,3),Vector(0,-3,0)); // Sphere *s = new Sphere(Vector(0,0,5),50); LightSource *Light1 = new PointLight(Vector(7,10,-10),20); BmpImage *img = new BmpImage("backgnd.bmp"); ColorMap *cmap = new ColorMap(img); cmap->Scale = 25; Scene = new Environment; b->Mapping = new PlaneMap(Vector(0,-1,-1),Vector(1,0,0)); b->Add(cmap); b->Ambient(0.3); b->Diffuse(0.8); b->Specular(0.3); b->Reflection(0.0); b->Refraction(0.0); b->PhongSize(5); b->DefMaterial.Med = Glass; b->DefMaterial.Color = 1; Scene->Add(b); Scene->Add(Light1); Background = SkyBlue; SetCamera(Vector(0),Vector(0,0,1),Vector(0,1,0)); RenderScene(1.6,1.0,320,200,"SAMP0080.TGA"); }
WPARAM MainLoop() { MSG msg; while(1) // Do our infinite loop { // Check if there was a message if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if(msg.message == WM_QUIT) // If the message wasn't to quit break; TranslateMessage(&msg); // Find out what the message does DispatchMessage(&msg); // Execute the message } else // if there wasn't a message { // Render the scene every frame to update the rotating cube RenderScene(); } } DestroyFont(); // This frees up our font display list DeInit(); // Release memory and restore settings return(msg.wParam); // Return from the program }
WPARAM MainLoop() { MSG msg; while(1) // Do our infinite loop { // Check if there was a message if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if(msg.message == WM_QUIT) // If the message wasn't to quit break; TranslateMessage(&msg); // Find out what the message does DispatchMessage(&msg); // Execute the message } else // if there wasn't a message { if(AnimateNextFrame(60)) // Make sure we only animate 60 FPS { g_Camera.Update(); // Update the camera information RenderScene(); // Render the scene every frame } else { Sleep(1); // Let other processes work } } } DeInit(); // Clean up and free all allocated memory return(msg.wParam); // Return from the program }
void keys(unsigned char key, int x, int y) { if(key == 'p') model = 1; if(key == 'w') model = 2; if(key == 's') model = 3; RenderScene(); }
void CProcessIA4::Render(CRenderManager* rm) { //eje principal Mat44f matWorld; matWorld.SetIdentity(); rm->SetTransform(matWorld); rm->DrawAxis(5); //mueve eje de IA RenderMovIA(rm); // m_SceneEffectManager->ActivateRenderSceneEffects(); CEffectManager *l_EffectManager=CORE->GetEffectManager(); l_EffectManager->SetAnimatedModelTechnique(NULL); l_EffectManager->SetStaticMeshTechnique(NULL); //m_SceneEffectManager->PreRender(rm,this); //Renderizamos la escena RenderScene(rm); CORE->GetPhysicsManager()->DebugRender(rm); /* m_SceneEffectManager->CaptureFrameBuffers(rm); m_SceneEffectManager->PostRender(rm); m_SceneEffectManager->CaptureFrameBuffersAfterPostRender(rm); */ RenderDebugInfo(); }
void RenderMesh(int frameNumber_) { PixBufT *canvas = R_("Canvas"); SceneT *scene = R_("Scene"); float frameNumber = frameNumber_; float s = sin(frameNumber * 3.14159265f / 90.0f) + 1.0f; { MatrixStack3D *ms = GetObjectTranslation(scene, "Object"); StackReset(ms); PushScaling3D(ms, 0.75f + 0.5f * s, 0.75f + 0.5f * s, 0.75f + 0.5f * s); PushRotation3D(ms, 0, (float)(-frameNumber * 2), frameNumber); PushTranslation3D(ms, 0.0f, 0.0f, -2.0f); } PixBufClear(canvas); #if 0 RenderFlatShading = true; PixBufSetColorMap(canvas, R_("ColorMap"), -32); #endif PROFILE(RenderScene) RenderScene(scene, canvas); c2p1x1_8_c5_bm(canvas->data, GetCurrentBitMap(), WIDTH, HEIGHT, 0, 0); }
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { MSG msg; if (!InitWindow (hInstance, VidMode640x480, false, nCmdShow)) return FALSE; InitGL(); while (1) { while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) == TRUE) { if (GetMessage(&msg, NULL, 0, 0) ) { TranslateMessage(&msg); DispatchMessage(&msg); } else { return TRUE; } } RenderScene(); } return TRUE; }
WPARAM MainLoop() { MSG msg; while(1) // Do our infinate loop { // Check if there was a message if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if(msg.message == WM_QUIT) // If the message wasnt to quit break; TranslateMessage(&msg); // Find out what the message does DispatchMessage(&msg); // Execute the message } else // if there wasn't a message { RenderScene(); // Update the screen } } // Go through all the objects in the scene for(int i = 0; i < g_3DModel.numOfObjects; i++) { // Free the faces, normals, vertices, and texture coordinates. delete [] g_3DModel.pObject[i].pFaces; delete [] g_3DModel.pObject[i].pNormals; delete [] g_3DModel.pObject[i].pVerts; delete [] g_3DModel.pObject[i].pTexVerts; } DeInit(); // Clean up and free all allocated memory return(msg.wParam); // Return from the program }
void keys(unsigned char key, int x, int y) { if(key == 'p') model = 1; if(key == 'w') model = 2; if(key == 's') model = 3; RenderScene(); // przerysowanie obrazu sceny }
void Cab_mfcView::OnDraw(CDC* /*pDC*/) { Cab_mfcDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); RenderScene(); //渲染场景 ::SwapBuffers(m_hDC);//交互缓冲区 }
void GLRenderer::Render() { glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo); RenderScene(); glBindFramebuffer(GL_FRAMEBUFFER, 0); RenderFinal(); }
void CLineComputeView::OnPaint() { CPaintDC dc(this); // device context for painting // TODO: Add your message handler code here glSelectFont(16, GB2312_CHARSET, "宋体"); RenderScene(); }
void SceneManager::Render(RenderSystem* render_system, Camera* camera) { CullScene(camera); SortScene(); if(mSkydome) { mSkydome->Render(render_system, camera); }; //if(m_heightmap) {m_heightmap->Render(render_system,m_frame,&m_light);}; RenderScene(render_system); };