//-------------------------------------------------------------------------------------- // Name: RenderFrame() // Desc: Renders a frame (save state, apply matrix, render children, restore) //-------------------------------------------------------------------------------------- VOID Mesh::RenderFrame( const MESH_FRAME* pFrame, DWORD dwFlags ) { // Apply the frame's local transform XMMATRIX matSavedWorld = m_matWorld; m_matWorld = XMMatrixMultiply( pFrame->m_matTransform, m_matWorld ); // Render the mesh data if( pFrame->m_pMeshData->m_dwNumSubsets ) { // Call the callback, so the app can tweak state before rendering the mesh DWORD dwFrame = pFrame - m_pFrames; RenderMeshCallback( dwFrame, pFrame, dwFlags ); RenderMesh( pFrame->m_pMeshData, dwFlags ); } // Render any child frames if( pFrame->m_pChild ) RenderFrame( pFrame->m_pChild, dwFlags ); // Restore the transformation matrix m_matWorld = matSavedWorld; // Render any sibling frames if( pFrame->m_pNext ) RenderFrame( pFrame->m_pNext, dwFlags ); }
//----------------------------------------------------------------------------- // Renders the given frame's mesh containers, if it has any. //----------------------------------------------------------------------------- void Mesh::RenderFrame( Frame *frame ) { MeshContainer *meshContainer = (MeshContainer*)frame->pMeshContainer; // Render this frame's mesh, if it has one. if( frame->pMeshContainer != NULL ) { // Check if this mesh is a skinned mesh. if( meshContainer->pSkinInfo != NULL ) { // Create the bone transformations using the mesh's transformation matrices. for( unsigned long b = 0; b < meshContainer->pSkinInfo->GetNumBones(); ++b ) D3DXMatrixMultiply( &m_boneMatrices[b], meshContainer->pSkinInfo->GetBoneOffsetMatrix( b ), meshContainer->boneMatrixPointers[b] ); // Update the meshes vertices with the new bone transformation matrices. PBYTE sourceVertices, destinationVertices; meshContainer->originalMesh->LockVertexBuffer( D3DLOCK_READONLY, (void**)&sourceVertices ); meshContainer->MeshData.pMesh->LockVertexBuffer( 0, (void**)&destinationVertices ); meshContainer->pSkinInfo->UpdateSkinnedMesh( m_boneMatrices, NULL, sourceVertices, destinationVertices ); meshContainer->originalMesh->UnlockVertexBuffer(); meshContainer->MeshData.pMesh->UnlockVertexBuffer(); // Render the mesh by atrtribute group. for( unsigned long a = 0; a < meshContainer->totalAttributeGroups; a++ ) { Engine::GetInstance()->GetDevice()->SetMaterial( meshContainer->materials[meshContainer->attributeTable[a].AttribId]->GetLighting() ); Engine::GetInstance()->GetDevice()->SetTexture( 0, meshContainer->materials[meshContainer->attributeTable[a].AttribId]->GetTexture() ); meshContainer->MeshData.pMesh->DrawSubset( meshContainer->attributeTable[a].AttribId ); } } else { // This is not a skinned mesh, so render it like a static mesh. for( unsigned long m = 0; m < meshContainer->NumMaterials; m++) { if( meshContainer->materials[m] ) { Engine::GetInstance()->GetDevice()->SetMaterial( meshContainer->materials[m]->GetLighting() ); Engine::GetInstance()->GetDevice()->SetTexture( 0, meshContainer->materials[m]->GetTexture() ); } else Engine::GetInstance()->GetDevice()->SetTexture( 0, NULL ); meshContainer->MeshData.pMesh->DrawSubset( m ); } } } // Render the frame's siblings. if( frame->pFrameSibling != NULL ) RenderFrame( (Frame*)frame->pFrameSibling ); // Render the frame's children. if( frame->pFrameFirstChild != NULL ) RenderFrame( (Frame*)frame->pFrameFirstChild ); }
// Генерация и отображение изображения void display() { // Вызов пользователем генерации изображения RenderFrame(); // Копирования текстур изображения в память glBindTexture(GL_TEXTURE_2D, texture); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image); // Очистка буфера glClear(GL_COLOR_BUFFER_BIT); // Рендер glBegin(GL_QUADS); glTexCoord2f(1, 0); glVertex2f(1, -1); glTexCoord2f(1, 1); glVertex2f(1, 1); glTexCoord2f(0, 1); glVertex2f(-1, 1); glTexCoord2f(0, 0); glVertex2f(-1, -1); glEnd(); // Отображение результатат glFlush(); glutSwapBuffers(); }
void DirectXInterop::DrawFrame() { static float t = 0.0f; // Map the resources cudaGraphicsResource *resource = m_hdrTextureCuda->GetCurrentGraphicsResource(); CE(cudaGraphicsMapResources(1, &resource)); // Run the kernel RenderFrame(m_hdrTextureCuda->GetTextureData(), m_clientWidth, m_clientHeight, m_hdrTextureCuda->GetTexturePitch(), t); // Copy the frame over to the d3d texture m_hdrTextureCuda->CopyTextureDataToRegisteredResource(); // Unmap the resources CE(cudaGraphicsUnmapResources(1, &resource)); // Draw the frame to the screen m_immediateContext->VSSetShader(m_fullscreenTriangleVS, nullptr, 0u); m_immediateContext->PSSetShader(m_copyCudaOutputToBackbufferPS, nullptr, 0u); ID3D11ShaderResourceView *hdrSRV = m_hdrTextureD3D->GetShaderResource(); m_immediateContext->PSSetShaderResources(0, 1, &hdrSRV); m_immediateContext->Draw(3u, 0u); m_swapChain->Present(1u, 0u); t += 0.1f; }
OMX_ERRORTYPE IpulibRender::StartDeviceInPause() { OMX_ERRORTYPE ret = OMX_ErrorNone; if(bInitDev != OMX_FALSE) return OMX_ErrorNone; if(pShowFrame == NULL) return OMX_ErrorBadParameter; OMX_PTR pFrame = NULL; GetHwBuffer(pShowFrame, &pFrame); ret = Init(); if(ret != OMX_ErrorNone) return ret; bInitDev = OMX_TRUE; ret = RenderFrame(pFrame); if(ret != OMX_ErrorNone) return ret; return OMX_ErrorNone; }
/* ============================================================================ * CycleVIF: Lets the VI know we are cycling the machine. * ========================================================================= */ void CycleVIF(struct VIFController *controller) { if (unlikely(controller->cyclesUntilIntr == 0)) { char buffer[4096]; double vis, hz; if (++(controller->frameCount) == 10) { vis = (double) 10 / (glfwGetTime() - controller->startTime); hz = ((double) 6250000 / 60) / (glfwGetTime() - controller->startTime); sprintf(buffer, "CEN64 [%.2f VI/s] [RCP: %.2f MHz]", vis, hz / 10000); glfwSetWindowTitle(buffer); controller->startTime = glfwGetTime(); controller->frameCount = 0; } RenderFrame(controller); /* Raise an interrupt. */ BusRaiseRCPInterrupt(controller->bus, MI_INTR_VI); controller->cyclesUntilIntr = (62500000 / 60) + 1; } controller->cyclesUntilIntr--; }
//-------------------------------------------------------------------------------------- void CMultiDeviceContextDXUTMesh::Render(ID3D11DeviceContext* pd3dDeviceContext, UINT iDiffuseSlot, UINT iNormalSlot, UINT iSpecularSlot) { RenderFrame(0, false, pd3dDeviceContext, iDiffuseSlot, iNormalSlot, iSpecularSlot); }
//Perform per frame updates void UpdateFrame(unsigned char key, int x, int y) { camera.Update((int)key); switch (key) { //Toggle render method case 116: case 84: //T renderMethod = SHOW_TEXTURES; break; case 112: case 80: //P //Pause/Unpause PVS updates updatePVS = false; break; case 117: // U case 85: updatePVS = true; break; case 108: //L case 76: renderMethod = SHOW_LIGHTMAPS; break; case 109: //L case 77: renderMethod = MODULATE_TEXTURES; break; } RenderFrame(); }
OMX_ERRORTYPE VideoRender::ProcessDataBuffer() { OMX_ERRORTYPE ret = OMX_ErrorNone; OMX_BUFFERHEADERTYPE *pBufferHdr = NULL; if(ports[IN_PORT]->BufferNum() == 0) return OMX_ErrorNoMore; if(pSyncFrame != NULL) return OMX_ErrorNoMore; ports[IN_PORT]->GetBuffer(&pBufferHdr); if(nFrameCnt == 0 && ports[CLK_PORT]->IsEnabled() == OMX_TRUE) { OMX_TIME_CONFIG_CLOCKSTATETYPE sState; OMX_INIT_STRUCT(&sState, OMX_TIME_CONFIG_CLOCKSTATETYPE); ports[CLK_PORT]->GetTunneledInfo(&hClock); OMX_GetConfig(hClock.hTunneledComp, OMX_IndexConfigTimeClockState, &sState); ClockState = sState.eState; } nFrameCnt ++; LOG_DEBUG("VideoRender get bufer: %p:%lld:%x\n", pBufferHdr->pBuffer, pBufferHdr->nTimeStamp, pBufferHdr->nFlags); if(ports[CLK_PORT]->IsEnabled() == OMX_TRUE) ret = SyncFrame(pBufferHdr); else ret = RenderFrame(pBufferHdr); return ret; }
void CTest5Section::Reaction( long in_SrcSectionID, const CRenderSection_CreateVertexBuffer_Response& in_rCmd ) { CLog::Print("CTest5Section::Reaction( const CRenderSection_CreateVertexBuffer_Response& in_rCmd )\n"); CLog::Print(" VB handle = %lu\n",in_rCmd.m_VBHandle); assert( in_rCmd.m_VBHandle > 0 ); m_VBHandle = in_rCmd.m_VBHandle; // set lights CTCommandSender<CRenderSection_SetAmbient>::SendCommand( m_RenderSectionID, CRenderSection_SetAmbient( 0x404040 ) ); CTCommandSender<CRenderSection_SetDirectionalLight>::SendCommand( m_RenderSectionID, CRenderSection_SetDirectionalLight( CVector(-1.0f,-1.0f,-1.0f), 1.0f, 1.0f, 1.0f ) ); // set object positions m_M0.ConstructScaling( CVector(2,2,2) ); m_M1.ConstructRotationY( 0 ); m_M1 *= CMatrix().ConstructTranslation( CVector(4,0,0) ); m_M2.ConstructRotationY( CONST_PI_2 ); m_M2 *= CMatrix().ConstructTranslation( CVector(0,0,4) ); m_M3.ConstructRotationY( CONST_PI_2*2 ); m_M3 *= CMatrix().ConstructTranslation( CVector(-4,0,0) ); m_M4.ConstructRotationY( CONST_PI_2*3 ); m_M4 *= CMatrix().ConstructTranslation( CVector(0,0,-4) ); // start rendering m_NFramesToRender = 2; RenderFrame(); CTCommandSender<CTest5Section_Render>::SendCommand( GetThisID(), CTest5Section_Render() ); CLog::Print("CTest5Section::Reaction( const CRenderSection_CreateVertexBuffer_Response& in_rCmd ) end\n"); }
INT MessageLoop(HWND hwnd) { MSG msg = {0}; while (msg.message != WM_QUIT) { if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); continue; } // Wait until the timer expires or any message is posted. if (WAIT_OBJECT_0 == MsgWaitForMultipleObjects( 1, &g_Timer.Handle(), FALSE, INFINITE, QS_ALLINPUT )) { RenderFrame(hwnd); } } DestroyWindow(hwnd); return INT(msg.wParam); }
void DXApp::Frame() { UINT64 CurrentTime; UINT64 DeltaCount; QueryPerformanceCounter((LARGE_INTEGER*)&CurrentTime); DeltaCount = CurrentTime - OldCount; OldCount = CurrentTime; DeltaTime = (double)DeltaCount/(double)Frequency; { NxVec3 Temp; Cam.location+=Cam.ViewDir*40*fFoward; Temp = Cam.ViewDir; Temp.y = 0; Temp.normalize(); Temp = Temp.cross(NxVec3(0.0f, 1.0f, 0.0f)); Cam.location+=Temp*40*fStrafe;; } if(!bPaused) { DoParticles(); _p_scene->simulate(_time_step); _p_scene->flushStream(); } RenderFrame(); if(!bPaused) _p_scene->fetchResults(NX_RIGID_BODY_FINISHED, true); }
int main(int argc, char* argv[]) { SDL_Init(SDL_INIT_EVERYTHING); atexit(SDL_Quit); debugLogFile = fopen("stderr.txt", "wb"); { char buffer[128]; const time_t raw(time(NULL)); const struct tm* local(localtime(&raw)); strftime(buffer, sizeof(buffer)-1, "%c\n", local); LOG("%s", buffer); } if (!Initialise()) { exit(EXIT_FAILURE); } unsigned int lastUpdate = 0; while (!quit) { HandleEvents(); unsigned int now = SDL_GetTicks(); unsigned int elapsedMS = now - lastUpdate; lastUpdate = now; UpdateGame(elapsedMS); RenderFrame(); Device::SwapBuffers(); } return 0; }
void GLApplication::RunMainLoop(){ if(!fWindow) Error(__FUNCTION__, "Window not created"); CreateApplication(); /** * OpenGL does not have depth test switched on by default, so if you want to * enable depth testing, call glEnable(GL_DEPTH_TEST) at CreateApplication(). * */ //glEnable(GL_DEPTH_TEST); OpenGLShouldHaveNoError("InitializeApplication"); while ((!glfwWindowShouldClose(fWindow))) { RenderFrame(); glfwSwapBuffers(fWindow); glfwPollEvents(); OpenGLShouldHaveNoError(__FUNCTION__); } ShutdownApplication(); glfwDestroyWindow(fWindow); is_exit = true; OpenGLShouldHaveNoError("ShutdownApplication"); }
KW_Widget * KW_CreateFrame(KW_GUI * gui, KW_Widget * parent, const KW_Rect * geometry) { KW_Frame * frame = AllocFrame(); KW_Widget * widget = KW_CreateWidget(gui, parent, KW_WIDGETTYPE_FRAME, geometry, PaintFrame, DestroyFrame, frame); KW_AddWidgetGeometryChangeHandler(widget, FrameGeometryChanged); RenderFrame(widget); return widget; }
void DemoEntityManager::OnIdle(wxIdleEvent& event) { wxClientDC dc(this); RenderFrame (); dTimeTrackerUpdate(); event.RequestMore(); // render continuously, not only once on idle }
void CTest5Section::Reaction( long in_SrcSectionID, const CRenderSection_NewFrame& in_rCmd ) { // CLog::Print("CTest5Section::Reaction( const CRenderSection_NewFrame& in_rCmd )\n"); ++m_NFramesToRender; ++m_NFrames; if(m_HWnd!=NULL) { unsigned long ThisFrameTime = GetTickCount(); if( (ThisFrameTime-m_LastTimeFrame)>=1000 ) { float FPS = 1000.0f*(float(m_NFrames))/(float(ThisFrameTime-m_LastTimeFrame)); char Buffer[256]; sprintf(Buffer,"Render test. FPS=%1.0f",FPS); CTCommandSender<CWindowSection_WindowName>::SendCommand( m_WindowSectionID, CWindowSection_WindowName(std::string(Buffer)) ); // m_LastTimeFrame = ThisFrameTime; m_NFrames=0; } RenderFrame(); } // CLog::Print("CTest5Section::Reaction( const CRenderSection_NewFrame& in_rCmd ) end\n"); }
void RenderThread::run() { m_pGLFrame->makeCurrent(); Init(); while (m_bDoRendering) { m_pGLFrame->makeCurrent(); if (!m_bPaused) { m_pEmulator->RunToVBlank(m_pFrameBuffer); if (m_bResizeEvent) { m_bResizeEvent = false; m_bFirstFrame = true; } if (m_bMixFrames && !m_pEmulator->IsCGBRom()) RenderMixFrames(); else RenderFrame(); } m_pGLFrame->swapBuffers(); } SafeDeleteArray(m_pFrameBuffer); glDeleteTextures(1, &m_AccumulationTexture); glDeleteTextures(1, &m_GBTexture); glDeleteFramebuffers(1, &m_AccumulationFramebuffer); }
void Engine::MainLoop() { while(window->IsOpened()) { ProcessInput(); Update(); RenderFrame(); } }
void OnMouseMove(int x, int y) { if ((x!= 320) && (y!=240)) { camera.setMousePos(x, y); camera.Update(0); RenderFrame(); } }
//-------------------------------------------------------------------------------------- _Use_decl_annotations_ void CMultiDeviceContextDXUTMesh::RenderFrame( UINT iFrame, bool bAdjacent, ID3D11DeviceContext* pd3dDeviceContext, UINT iDiffuseSlot, UINT iNormalSlot, UINT iSpecularSlot ) { if( !m_pStaticMeshData || !m_pFrameArray ) return; if( m_pFrameArray[iFrame].Mesh != INVALID_MESH ) { if ( !m_pRenderMeshCallback ) { RenderMesh( m_pFrameArray[iFrame].Mesh, bAdjacent, pd3dDeviceContext, iDiffuseSlot, iNormalSlot, iSpecularSlot ); } else { m_pRenderMeshCallback( this, m_pFrameArray[iFrame].Mesh, bAdjacent, pd3dDeviceContext, iDiffuseSlot, iNormalSlot, iSpecularSlot ); } } // Render our children if( m_pFrameArray[iFrame].ChildFrame != INVALID_FRAME ) RenderFrame( m_pFrameArray[iFrame].ChildFrame, bAdjacent, pd3dDeviceContext, iDiffuseSlot, iNormalSlot, iSpecularSlot ); // Render our siblings if( m_pFrameArray[iFrame].SiblingFrame != INVALID_FRAME ) RenderFrame( m_pFrameArray[iFrame].SiblingFrame, bAdjacent, pd3dDeviceContext, iDiffuseSlot, iNormalSlot, iSpecularSlot ); }
//----------------------------------------------------------------------------- // Name: WinMain() // Desc: Entry point for the application. Since we use a simple dialog for // user interaction we don't need to pump messages. //----------------------------------------------------------------------------- int WINAPI wWinMain( _In_ HINSTANCE hInstance, _In_opt_ HINSTANCE, _In_ LPWSTR, _In_ int ) { // Initialize COM HRESULT hr; if( FAILED( hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED) ) ) return 1; // Register the window class HBRUSH hBrush = CreateSolidBrush( 0xFF0000 ); WNDCLASSEX wc = { sizeof( WNDCLASSEX ), 0, MsgProc, 0L, 0L, hInstance, nullptr, LoadCursor( nullptr, IDC_ARROW ), hBrush, nullptr, L"XInputSample", nullptr }; RegisterClassEx( &wc ); // Create the application's window g_hWnd = CreateWindow( L"XInputSample", L"XInput Sample: RumbleController", WS_OVERLAPPED | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT, 600, 600, nullptr, nullptr, hInstance, nullptr ); // Init state ZeroMemory( g_Controllers, sizeof( CONTROLLER_STATE ) * MAX_CONTROLLERS ); // Enter the message loop bool bGotMsg; MSG msg; msg.message = WM_NULL; while( WM_QUIT != msg.message ) { // Use PeekMessage() so we can use idle time to render the scene and call pEngine->DoWork() bGotMsg = ( PeekMessage( &msg, nullptr, 0U, 0U, PM_REMOVE ) != 0 ); if( bGotMsg ) { // Translate and dispatch the message TranslateMessage( &msg ); DispatchMessage( &msg ); } else { UpdateControllerState(); RenderFrame(); } } // Clean up UnregisterClass( L"XInputSample", nullptr ); CoUninitialize(); return 0; }
//主进程 void main(void) { //创建Opengl渲染环境及窗口 char *device = "opengl"; HCoreResizeFunc( ResizeWindow ); HCoreCreateWindow(100, 100, 800, 600, device); if ( !HCoreInitGraphicsDevice(device) ) { printf("初始化失败 \n", device); exit(0); } //注册输入函数 HCoreInputInit(); HCoreRegisterKeyDown(HCoreKEY_0, KeyDown_0); HCoreRegisterKeyDown(HCoreKEY_1, KeyDown_1); HCoreRegisterKeyDown(HCoreKEY_2, KeyDown_2); HCoreRegisterKeyDown(HCoreKEY_3, KeyDown_3); HCoreRegisterKeyDown(HCoreKEY_4, KeyDown_4); HCoreRegisterKeyDown(HCoreKEY_5, KeyDown_5); HCoreRegisterKeyDown(HCoreKEY_6, KeyDown_6); HCoreRegisterKeyDown(HCoreKEY_7, KeyDown_7); HCoreRegisterKeyDown(HCoreKEY_8, KeyDown_8); HCoreRegisterKeyDown(HCoreKEY_9, KeyDown_9); //设置相机 g_Control.SetCamera(Vector4(0.0f, 0.0f, 1.0f), Vector4(0.0f, 1.0f, 1.0f), Vector4(0.0f, 0.0f, 1.0f) ); //读取模型 //地形 g_Model.Load_ASCII("..\\models\\terrain.gma"); //棋盘 g_SSAOModel.Load_ASCII("..\\models\\chess.gma"); // 载入shader if ( !InitResource() ) { ReleaseResource(); exit(0); } // 主循环 while( HCoreProcessMessage() ) { GetUserInput(); RenderFrame(); } // 释放shader ReleaseResource(); // 关闭OpenGL绘图设备 HCoreReleaseGraphicsDevice(); }
void RenderCanvas::OnPaint( wxPaintEvent& event ) { // This is required even though dc is not used otherwise. // PrepareDC(dc); wxPaintDC dc(this); const wxSize size = GetClientSize(); if ( m_RenderManager ) m_RenderManager->ResizeViewport( size.GetWidth(), size.GetHeight() ); RenderFrame(); event.Skip(); }
/* ============================ idAutoRender::Run ============================ */ int idAutoRender::Run() { while( !IsTerminating() ) { RenderFrame(); } return 0; }
void CTest5Section::Reaction( long in_SrcSectionID, const CTest5Section_Render& in_rCmd ) { //CLog::Print("CTest5Section::Reaction( const CTest5Section_Render& in_rCmd )\n"); if(m_HWnd!=NULL) { RenderFrame(); } //CLog::Print("CTest5Section::Reaction( const CTest5Section_Render& in_rCmd ) end\n"); }
void Engine::MainLoop() { //Loop until our window is closed while(window->isOpen()) { ProcessInput(); Update(); RenderFrame(); } }
//------------------------------------------------------------------------------ void Example::Run(void) { double start_time = glfwGetTime(); glfwPollEvents(); while(!glfwWindowShouldClose(glfw_window)) { RenderFrame(glfwGetTime()-start_time); glfwSwapBuffers(glfw_window); glfwPollEvents(); } }
void OnPaint(HWND hwnd) { PAINTSTRUCT ps; HDC hdc = 0; hdc = BeginPaint(hwnd, &ps); RenderFrame(hwnd); EndPaint(hwnd, &ps); }
void MD2Model::drawFrame(int frame) { glPushMatrix(); glMaterialfv(GL_FRONT,GL_AMBIENT,mat_ambient); glMaterialfv(GL_FRONT,GL_DIFFUSE,mat_diffuse); glMaterialfv(GL_FRONT,GL_SPECULAR,mat_specular); glMaterialfv(GL_FRONT,GL_SHININESS,mat_shininess); glTranslatef(100,-70,140); glRotatef(-90,1.0,0.0,0.0); RenderFrame(); glPopMatrix(); }