void CTDirectScreenBitmap::TestContinuousRefreshingPerDisplayModeL(const TDisplayMode& aDisplayMode) { CFbsDrawDevice *pDev = NULL; iDispMode = aDisplayMode; TRAPD(err,pDev = CFbsDrawDevice::NewScreenDeviceL(0, aDisplayMode)); if (err) { INFO_PRINTF2(_L("Note: Failed to create screen device for display mode %i - not supported on this config?"),iDispMode); } else { INFO_PRINTF2(_L("Testing Continuous Refreshing for display mode %i"),iDispMode); CleanupDeletePushL(pDev); User::LeaveIfError(pDev->InitScreen()); TSize screenSize = pDev->SizeInPixels(); TRect directRect; // Quarter screen ENone INFO_PRINTF1(_L("Consecutively update frames at left bottom corner and setting ENone")); directRect = TRect(TPoint(0, screenSize.iHeight/2), TSize(screenSize.iWidth/2, screenSize.iHeight/2)); TRAPD(err,ConstructL(directRect, CDirectScreenBitmap::ENone)); if (err) { INFO_PRINTF1(_L("The Direct Screen Bitmap object is not created")); } else { // use the same iDirectScreenBitmap as CTDirectScreenBitmap UpdateFrame(); } // Quarter screen EDoubleBuffer INFO_PRINTF1(_L("Consecutively update frames at up right corner and setting EDoubleBuffer")); directRect = TRect(TPoint(screenSize.iWidth/2, 0), TSize(screenSize.iWidth/2, screenSize.iHeight/2)); TRAP(err,ConstructL(directRect,CDirectScreenBitmap::EDoubleBuffer,1)); if (err) { INFO_PRINTF1(_L("The Direct Screen Bitmap object is not created")); } else { // use the same iDirectScreenBitmap as CTDirectScreenBitmap UpdateFrame(); } // Quarter screen EIncremental INFO_PRINTF1(_L("Consecutively update frames at right bottom corner and setting EIncremental")); directRect = TRect(TPoint(screenSize.iWidth/2, screenSize.iHeight/2), TSize(screenSize.iWidth/2, screenSize.iHeight/2)); TRAP(err,ConstructL(directRect,CDirectScreenBitmap::EIncrementalUpdate,2)); if (err) { INFO_PRINTF1(_L("The Direct Screen Bitmap object is not created")); } else { // use the same iDirectScreenBitmap as CTDirectScreenBitmap UpdateFrame(); } // Full screen EIncremental INFO_PRINTF1(_L("Consecutively update frames at full screen and setting EIncremental")); directRect = TRect(TPoint(0,0), screenSize); TRAP(err,ConstructL(directRect,CDirectScreenBitmap::EIncrementalUpdate,2)); if (err) { INFO_PRINTF1(_L("The Direct Screen Bitmap object is not created")); } else { // use the same iDirectScreenBitmap as CTDirectScreenBitmap UpdateFrame(); } // Full screen ENone INFO_PRINTF1(_L("Consecutively update frames at full screen and setting ENone")); directRect = TRect(TPoint(0,0), screenSize); TRAP(err,ConstructL(directRect,CDirectScreenBitmap::ENone)); if (err) { INFO_PRINTF1(_L("The Direct Screen Bitmap object is not created")); } else { // use the same iDirectScreenBitmap as CTDirectScreenBitmap UpdateFrame(); } // Full screen EDoubleBuffering INFO_PRINTF1(_L("Consecutively update frames at full screen and setting EDoubleBuffering")); directRect = TRect(TPoint(0,0), screenSize); TRAP(err,ConstructL(directRect,CDirectScreenBitmap::EDoubleBuffer,1)); if (err) { INFO_PRINTF1(_L("The Direct Screen Bitmap object is not created")); } else { // use the same iDirectScreenBitmap as CTDirectScreenBitmap UpdateFrame(); } CleanupStack::PopAndDestroy(pDev); } }
void SCSanimation::Update (const SCSfloat fDeltaTime) { if (m_iRepeat < 0) UpdateFrame(fDeltaTime); else if (m_iPlayCount <= m_iRepeat) UpdateFrame(fDeltaTime); }
void HUD::Update() { UpdateFrame(); UpdateHUD(); }
bool COGLGraphicsContext::Initialize(uint32 dwWidth, uint32 dwHeight, BOOL bWindowed ) { DebugMessage(M64MSG_INFO, "Initializing OpenGL Device Context."); Lock(); CGraphicsContext::Get()->m_supportTextureMirror = false; CGraphicsContext::Initialize(dwWidth, dwHeight, bWindowed ); if( bWindowed ) { windowSetting.statusBarHeightToUse = windowSetting.statusBarHeight; windowSetting.toolbarHeightToUse = windowSetting.toolbarHeight; } else { windowSetting.statusBarHeightToUse = 0; windowSetting.toolbarHeightToUse = 0; } int depthBufferDepth = options.OpenglDepthBufferSetting; int colorBufferDepth = 32; int bVerticalSync = windowSetting.bVerticalSync; if( options.colorQuality == TEXTURE_FMT_A4R4G4B4 ) colorBufferDepth = 16; // init sdl & gl DebugMessage(M64MSG_VERBOSE, "Initializing video subsystem..."); if (CoreVideo_Init() != M64ERR_SUCCESS) return false; /* hard-coded attribute values */ const int iDOUBLEBUFFER = 1; #if 0 /* set opengl attributes */ CoreVideo_GL_SetAttribute(M64P_GL_DOUBLEBUFFER, iDOUBLEBUFFER); CoreVideo_GL_SetAttribute(M64P_GL_SWAP_CONTROL, bVerticalSync); CoreVideo_GL_SetAttribute(M64P_GL_BUFFER_SIZE, colorBufferDepth); CoreVideo_GL_SetAttribute(M64P_GL_DEPTH_SIZE, depthBufferDepth); #endif /* set multisampling */ if (options.multiSampling > 0) { CoreVideo_GL_SetAttribute(M64P_GL_MULTISAMPLEBUFFERS, 1); if (options.multiSampling <= 2) CoreVideo_GL_SetAttribute(M64P_GL_MULTISAMPLESAMPLES, 2); else if (options.multiSampling <= 4) CoreVideo_GL_SetAttribute(M64P_GL_MULTISAMPLESAMPLES, 4); else if (options.multiSampling <= 8) CoreVideo_GL_SetAttribute(M64P_GL_MULTISAMPLESAMPLES, 8); else CoreVideo_GL_SetAttribute(M64P_GL_MULTISAMPLESAMPLES, 16); } /* Set the video mode */ m64p_video_mode ScreenMode = bWindowed ? M64VIDEO_WINDOWED : M64VIDEO_FULLSCREEN; if (CoreVideo_SetVideoMode(windowSetting.uDisplayWidth, windowSetting.uDisplayHeight, colorBufferDepth, ScreenMode) != M64ERR_SUCCESS) { DebugMessage(M64MSG_ERROR, "Failed to set %i-bit video mode: %ix%i", colorBufferDepth, (int)windowSetting.uDisplayWidth, (int)windowSetting.uDisplayHeight); CoreVideo_Quit(); return false; } #if 0 /* check that our opengl attributes were properly set */ int iActual; if (CoreVideo_GL_GetAttribute(M64P_GL_DOUBLEBUFFER, &iActual) == M64ERR_SUCCESS) if (iActual != iDOUBLEBUFFER) DebugMessage(M64MSG_WARNING, "Failed to set GL_DOUBLEBUFFER to %i. (it's %i)", iDOUBLEBUFFER, iActual); if (CoreVideo_GL_GetAttribute(M64P_GL_SWAP_CONTROL, &iActual) == M64ERR_SUCCESS) if (iActual != bVerticalSync) DebugMessage(M64MSG_WARNING, "Failed to set GL_SWAP_CONTROL to %i. (it's %i)", bVerticalSync, iActual); if (CoreVideo_GL_GetAttribute(M64P_GL_BUFFER_SIZE, &iActual) == M64ERR_SUCCESS) if (iActual != colorBufferDepth) DebugMessage(M64MSG_WARNING, "Failed to set GL_BUFFER_SIZE to %i. (it's %i)", colorBufferDepth, iActual); if (CoreVideo_GL_GetAttribute(M64P_GL_DEPTH_SIZE, &iActual) == M64ERR_SUCCESS) if (iActual != depthBufferDepth) DebugMessage(M64MSG_WARNING, "Failed to set GL_DEPTH_SIZE to %i. (it's %i)", depthBufferDepth, iActual); #endif /* Get function pointers to OpenGL extensions (blame Microsoft Windows for this) */ OGLExtensions_Init(); char caption[500]; sprintf(caption, "%s v%i.%i.%i", PLUGIN_NAME, VERSION_PRINTF_SPLIT(PLUGIN_VERSION)); CoreVideo_SetCaption(caption); SetWindowMode(); InitState(); InitOGLExtension(); sprintf(m_strDeviceStats, "%.60s - %.128s : %.60s", m_pVendorStr, m_pRenderStr, m_pVersionStr); TRACE0(m_strDeviceStats); DebugMessage(M64MSG_INFO, "Using OpenGL: %s", m_strDeviceStats); Unlock(); Clear(CLEAR_COLOR_AND_DEPTH_BUFFER); // Clear buffers UpdateFrame(); Clear(CLEAR_COLOR_AND_DEPTH_BUFFER); UpdateFrame(); m_bReady = true; status.isVertexShaderEnabled = false; return true; }
//---------------------------------------------------// // TreeView_mHpProcess //---------------------------------------------------// void TreeView_mHpProcess(HWND hWndActive,BOOL &bChangeWnd,int iCurrentWnd,int iCountWnd) { switch(GetmHpVarStruct()->CourantTask->GetmHpStep()) { case 2: // 1° CLICK { EndObjects(hWndActive); GetmHpVarStruct()->bRefreshDDraw=TRUE; SetDDrawObj(hWndActive,7); if(!DoInit(hWndActive)) StopmHelp(hWndActive,TRUE,TRUE); else SetTimer(hWndActive,ID_TIMER_DDRAW,1,(TIMERPROC)mHpTimerProc); break; } case 3: // DELAY { PlayResourceWAV(MAKEINTRESOURCE(IDR_WAVE_PRESS)); SetTimer(hWndActive,ID_TIMER_DELAI,50,(TIMERPROC)mHpTimerProc); break; } case 4: // UNCLICK + Selection { PlayResourceWAV(MAKEINTRESOURCE(IDR_WAVE_UNPRESS)); EndObjects(hWndActive); if(GetFocus()!=GetmHpVarStruct()->hWndCurCtrl) SetFocus(GetmHpVarStruct()->hWndCurCtrl); TreeView_SelectItem(GetmHpVarStruct()->hWndCurCtrl,hCurSelItm); GetmHpVarStruct()->bRefreshDDraw=TRUE; SetDDrawObj(hWndActive,0); if(!DoInit(hWndActive)) StopmHelp(hWndActive,TRUE,TRUE); else SetTimer(hWndActive,ID_TIMER_DDRAW,1,(TIMERPROC)mHpTimerProc); break; } case 5: // DELAY { SetTimer(hWndActive,ID_TIMER_DELAI,1,(TIMERPROC)mHpTimerProc); break; } case 6: // 2° CLICK { EndObjects(hWndActive); GetmHpVarStruct()->bRefreshDDraw=TRUE; SetDDrawObj(hWndActive,8); if(!DoInit(hWndActive)) StopmHelp(hWndActive,TRUE,TRUE); else SetTimer(hWndActive,ID_TIMER_DDRAW,1,(TIMERPROC)mHpTimerProc); break; } case 7: // DELAY { PlayResourceWAV(MAKEINTRESOURCE(IDR_WAVE_PRESS)); SetTimer(hWndActive,ID_TIMER_DELAI,50,(TIMERPROC)mHpTimerProc); break; } case 8: // UNCLICK + Expand { PlayResourceWAV(MAKEINTRESOURCE(IDR_WAVE_UNPRESS)); TreeView_Expand(GetmHpVarStruct()->hWndCurCtrl,hCurSelItm,TVE_EXPAND); EndObjects(hWndActive); GetmHpVarStruct()->bRefreshDDraw=TRUE; SetDDrawObj(hWndActive,0); if(!DoInit(hWndActive)) StopmHelp(hWndActive,TRUE,TRUE); else SetTimer(hWndActive,ID_TIMER_DDRAW,1,(TIMERPROC)mHpTimerProc); break; } case 9: // DELAY { SetTimer(hWndActive,ID_TIMER_DELAI,400,(TIMERPROC)mHpTimerProc); break; } case 10: // NEXT SELECTION { GetmHpVarStruct()->SelItemListe->ItemIndexSuivant(); hCurSelItm=GetNexthTreeItemToSel(GetmHpVarStruct()->hWndCurCtrl,TreeView_GetChild(GetmHpVarStruct()->hWndCurCtrl,hCurSelItm)); if(hCurSelItm!=NULL) { RECT CtlRct; GetWindowRect(GetmHpVarStruct()->hWndCurCtrl,&CtlRct); GetmHpVarStruct()->bRefreshDDraw=TRUE; GetmHpVarStruct()->bNewDepl=TRUE; RECT ItmRct; TreeView_GetItemRect(GetmHpVarStruct()->hWndCurCtrl,hCurSelItm,&ItmRct,TRUE); ListTreeStatusPos(hWndActive,ItmRct); if(!GetmHpVarStruct()->AscensSens) { // When the last visible item is selected, that launch an auto-scroll TreeView_EnsureVisible(GetmHpVarStruct()->hWndCurCtrl,hCurSelItm); TreeView_GetItemRect(GetmHpVarStruct()->hWndCurCtrl,hCurSelItm,&ItmRct,TRUE); // GetmHpVarStruct()->YnextPos=(int)(CtlRct.top+((ItmRct.bottom-ItmRct.top)/2)+ItmRct.top); GetmHpVarStruct()->XnextPos=(int)(CtlRct.left+((ItmRct.right-ItmRct.left)/2)+ItmRct.left); // DoubleClick | Click if(GetmHpVarStruct()->SelItemListe->IsNextIndexExist()) GetmHpVarStruct()->CourantTask->SetmHpStep(1); } else MoveOnScrollBar(GetmHpVarStruct()->hWndCurCtrl,CtlRct); // Not visible SetTimer(hWndActive,ID_TIMER_DDRAW,1,(TIMERPROC)mHpTimerProc); } else // END { GetmHpVarStruct()->CourantTask->SetmHpStep(14); SetTimer(hWndActive,ID_TIMER_DELAI,1,(TIMERPROC)mHpTimerProc); } break; } case 11: // CLICK { GetmHpVarStruct()->bRefreshDDraw=TRUE; SetDDrawObj(hWndActive,0); GetmHpVarStruct()->CursorType=1; SetTimer(hWndActive,ID_TIMER_DDRAW,1,(TIMERPROC)mHpTimerProc); break; } case 12: // DELAY { PlayResourceWAV(MAKEINTRESOURCE(IDR_WAVE_PRESS)); SetTimer(hWndActive,ID_TIMER_DELAI,150,(TIMERPROC)mHpTimerProc); break; } case 13: // LAST SELECTION { RECT ctlRct; RECT itmRct; int iLastAscens; if(!GetmHpVarStruct()->AscensSens) { PlayResourceWAV(MAKEINTRESOURCE(IDR_WAVE_UNPRESS)); EndObjects(hWndActive); if(GetFocus()!=GetmHpVarStruct()->hWndCurCtrl) SetFocus(GetmHpVarStruct()->hWndCurCtrl); TreeView_SelectItem(GetmHpVarStruct()->hWndCurCtrl,hCurSelItm); GetmHpVarStruct()->bRefreshDDraw=TRUE; SetDDrawObj(hWndActive,0); GetmHpVarStruct()->CourantTask->SetmHpStep(14); if(!DoInit(hWndActive)) StopmHelp(hWndActive,TRUE,TRUE); else SetTimer(hWndActive,ID_TIMER_DDRAW,1,(TIMERPROC)mHpTimerProc); } else { switch(GetmHpVarStruct()->AscensSens) { case 1: // UP { if(!RestoreBackBuffer(hWndActive)) StopmHelp(hWndActive,TRUE,TRUE); else { UpdateBackBuffer(TRUE); SendMessage(GetmHpVarStruct()->hWndCurCtrl,WM_VSCROLL, MAKEWPARAM(SB_THUMBPOSITION,(GetScrollPos(GetmHpVarStruct()->hWndCurCtrl,SB_VERT)-1)),NULL); if(!UpdateFrame(hWndActive)) StopmHelp(hWndActive,TRUE,TRUE); } break; } case 2: // DOWN { if(!RestoreBackBuffer(hWndActive)) StopmHelp(hWndActive,TRUE,TRUE); else { UpdateBackBuffer(TRUE); SendMessage(GetmHpVarStruct()->hWndCurCtrl,WM_VSCROLL, MAKEWPARAM(SB_THUMBPOSITION,(GetScrollPos(GetmHpVarStruct()->hWndCurCtrl,SB_VERT)+1)),NULL); if(!UpdateFrame(hWndActive)) StopmHelp(hWndActive,TRUE,TRUE); } break; } case 3: // RIGHT { if(!RestoreBackBuffer(hWndActive)) StopmHelp(hWndActive,TRUE,TRUE); else { UpdateBackBuffer(TRUE); SendMessage(GetmHpVarStruct()->hWndCurCtrl,WM_HSCROLL, MAKEWPARAM(SB_THUMBPOSITION,(GetScrollPos(GetmHpVarStruct()->hWndCurCtrl,SB_HORZ)+1)),NULL); if(!UpdateFrame(hWndActive)) StopmHelp(hWndActive,TRUE,TRUE); } break; } case 4: // LEFT { if(!RestoreBackBuffer(hWndActive)) StopmHelp(hWndActive,TRUE,TRUE); else { UpdateBackBuffer(TRUE); SendMessage(GetmHpVarStruct()->hWndCurCtrl,WM_HSCROLL, MAKEWPARAM(SB_THUMBPOSITION,(GetScrollPos(GetmHpVarStruct()->hWndCurCtrl,SB_HORZ)-1)),NULL); if(!UpdateFrame(hWndActive)) StopmHelp(hWndActive,TRUE,TRUE); } break; } } iLastAscens=GetmHpVarStruct()->AscensSens; GetWindowRect(GetmHpVarStruct()->hWndCurCtrl,&ctlRct); TreeView_GetItemRect(GetmHpVarStruct()->hWndCurCtrl,hCurSelItm,&itmRct,TRUE); ListTreeStatusPos(hWndActive,itmRct); if(!GetmHpVarStruct()->AscensSens) { // When the last visible item is selected, that launch an auto-scroll TreeView_EnsureVisible(GetmHpVarStruct()->hWndCurCtrl,hCurSelItm); TreeView_GetItemRect(GetmHpVarStruct()->hWndCurCtrl,hCurSelItm,&itmRct,TRUE); // GetmHpVarStruct()->YnextPos=(int)(ctlRct.top+((itmRct.bottom-itmRct.top)/2)+itmRct.top); GetmHpVarStruct()->XnextPos=(int)(ctlRct.left+((itmRct.right-itmRct.left)/2)+itmRct.left); // DoubleClick | Click if(GetmHpVarStruct()->SelItemListe->IsNextIndexExist()) GetmHpVarStruct()->CourantTask->SetmHpStep(1); else GetmHpVarStruct()->CourantTask->SetmHpStep(10); PlayResourceWAV(MAKEINTRESOURCE(IDR_WAVE_UNPRESS)); EndObjects(hWndActive); GetmHpVarStruct()->bRefreshDDraw=TRUE; GetmHpVarStruct()->bNewDepl=TRUE; SetDDrawObj(hWndActive,0); if(!DoInit(hWndActive)) StopmHelp(hWndActive,TRUE,TRUE); else SetTimer(hWndActive,ID_TIMER_DDRAW,1,(TIMERPROC)mHpTimerProc); } else // Not visible { if(iLastAscens!=GetmHpVarStruct()->AscensSens) { MoveOnScrollBar(GetmHpVarStruct()->hWndCurCtrl,ctlRct); GetmHpVarStruct()->CourantTask->SetmHpStep(10); PlayResourceWAV(MAKEINTRESOURCE(IDR_WAVE_UNPRESS)); EndObjects(hWndActive); GetmHpVarStruct()->bRefreshDDraw=TRUE; GetmHpVarStruct()->bNewDepl=TRUE; SetDDrawObj(hWndActive,0); if(!DoInit(hWndActive)) StopmHelp(hWndActive,TRUE,TRUE); else SetTimer(hWndActive,ID_TIMER_DDRAW,1,(TIMERPROC)mHpTimerProc); } else { GetmHpVarStruct()->CourantTask->SetmHpStep(12); SetTimer(hWndActive,ID_TIMER_DELAI,200,(TIMERPROC)mHpTimerProc); } } } break; } case 14: { if((!bFindItm)&&(GetmHpVarStruct()->CourantTask->GetmHpOption()>=10)) ViewCtrlNotReadyMsg(hWndActive,4); else SetTimer(hWndActive,ID_TIMER_DELAI,300,(TIMERPROC)mHpTimerProc); break; } case 15: { if(GetmHpVarStruct()->TaskList->NextCellule()) { GetmHpVarStruct()->bNewDepl=TRUE; SetDDrawObj(hWndActive,0); GetmHpVarStruct()->CourantTask=GetmHpVarStruct()->TaskList->GetCurrentTask(); GetNextPos(hWndActive); } else NextRepeatAssistProc(hWndActive); break; } default: NULL; } }
int WINAPI WinMain(HINSTANCE hInst,HINSTANCE hPrevInst, LPSTR cmdLine,int cmdShow) { MSG msg; g_bLmouseButt = false; if(!SysInit(hInst)) return -1; appRunning = true; buffer.RecalcOffs(); InitSinCos(); InitApp(); // Initialzie the FPS counting variables fps = 0; frmCounter = 0; timeLast = GetTickCount(); //initialize dTime vars pentru dTime LARGE_INTEGER qwTicksPerSec; QueryPerformanceFrequency(&qwTicksPerSec); LONGLONG m_llQPFTicksPerSec = qwTicksPerSec.QuadPart; LARGE_INTEGER qwTicks; QueryPerformanceCounter(&qwTicks); m_llLastElapsedTime = qwTicks.QuadPart; while(appRunning) { if(PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { switch(msg.message) { case WM_QUIT: { appRunning = false; } break; case WM_MOUSEMOVE: { g_ptMouse.x = GET_X_LPARAM(msg.lParam); g_ptMouse.y = GET_Y_LPARAM(msg.lParam); } break; case WM_LBUTTONDOWN: { g_bLmouseButt = true; } break; case WM_LBUTTONUP: { g_bLmouseButt = false; } break; } TranslateMessage(&msg); DispatchMessage(&msg); } if(buffer.IsBuffer()) { // Clear buffer buffer.clearBuffer(); LARGE_INTEGER qwTime; QueryPerformanceCounter(&qwTime); double fElapsedTime = (double) (qwTime.QuadPart - m_llLastElapsedTime) / (double) m_llQPFTicksPerSec; m_llLastElapsedTime = qwTime.QuadPart; //max 5000 fps si min 30 fps if(fElapsedTime <= 0.0001f) fElapsedTime = 0.0001f; if(fElapsedTime > 0.04f) fElapsedTime = 0.04f; //Update stuff UpdateFrame(fElapsedTime); // Render stuff RenderFrame(fElapsedTime); // Swap buffers SwapBuffers(); // Keep track of FPS UpdateFPS(); } } SysDeinit(); return 0; }
void Base3DApplication::OnRender() { UpdateFrame(); m_pColossus->RenderFrame(); }
void SDLApplication::UpdateFrame (void*) { UpdateFrame (); }
bool COGLGraphicsContext::Initialize(uint32 dwWidth, uint32 dwHeight, BOOL bWindowed ) { DebugMessage(M64MSG_INFO, "Initializing OpenGL Device Context."); Lock(); CGraphicsContext::Get()->m_supportTextureMirror = false; CGraphicsContext::Initialize(dwWidth, dwHeight, bWindowed ); if( bWindowed ) { windowSetting.statusBarHeightToUse = windowSetting.statusBarHeight; windowSetting.toolbarHeightToUse = windowSetting.toolbarHeight; } else { windowSetting.statusBarHeightToUse = 0; windowSetting.toolbarHeightToUse = 0; } int depthBufferDepth = options.OpenglDepthBufferSetting; int colorBufferDepth = 32; int bVerticalSync = windowSetting.bVerticalSync; if( options.colorQuality == TEXTURE_FMT_A4R4G4B4 ) colorBufferDepth = 16; /* // init sdl & gl DebugMessage(M64MSG_VERBOSE, "Initializing video subsystem..."); if (CoreVideo_Init() != M64ERR_SUCCESS) return false; */ /* hard-coded attribute values */ const int iDOUBLEBUFFER = 1; /* set opengl attributes */ // CoreVideo_GL_SetAttribute(M64P_GL_DOUBLEBUFFER, iDOUBLEBUFFER); // CoreVideo_GL_SetAttribute(M64P_GL_SWAP_CONTROL, bVerticalSync); // CoreVideo_GL_SetAttribute(M64P_GL_BUFFER_SIZE, colorBufferDepth); // CoreVideo_GL_SetAttribute(M64P_GL_DEPTH_SIZE, depthBufferDepth); // // /* set multisampling */ // if (options.multiSampling > 0) // { // CoreVideo_GL_SetAttribute(M64P_GL_MULTISAMPLEBUFFERS, 1); // if (options.multiSampling <= 2) // CoreVideo_GL_SetAttribute(M64P_GL_MULTISAMPLESAMPLES, 2); // else if (options.multiSampling <= 4) // CoreVideo_GL_SetAttribute(M64P_GL_MULTISAMPLESAMPLES, 4); // else if (options.multiSampling <= 8) // CoreVideo_GL_SetAttribute(M64P_GL_MULTISAMPLESAMPLES, 8); // else // CoreVideo_GL_SetAttribute(M64P_GL_MULTISAMPLESAMPLES, 16); // } // // /* Set the video mode */ // m64p_video_mode ScreenMode = bWindowed ? M64VIDEO_WINDOWED : M64VIDEO_FULLSCREEN; // if (CoreVideo_SetVideoMode(windowSetting.uDisplayWidth, windowSetting.uDisplayHeight, colorBufferDepth, ScreenMode) != M64ERR_SUCCESS) // { // DebugMessage(M64MSG_ERROR, "Failed to set %i-bit video mode: %ix%i", colorBufferDepth, (int)windowSetting.uDisplayWidth, (int)windowSetting.uDisplayHeight); // CoreVideo_Quit(); // return false; // } // //#ifdef WIN32 // GLenum err = glewInit(); // if (GLEW_OK != err) // { // /* Problem: glewInit failed, something is seriously wrong. */ // fprintf(stderr, "Error: %s\n", glewGetErrorString(err)); // } //#endif // // char caption[500]; // sprintf(caption, "%s v%i.%i.%i", PLUGIN_NAME, VERSION_PRINTF_SPLIT(PLUGIN_VERSION)); // CoreVideo_SetCaption(caption); // SetWindowMode(); /* SDL_Surface* screen; SDL_Init(SDL_INIT_VIDEO); if (!(screen = SDL_SetVideoMode(1024, 768, 16, SDL_SWSURFACE ))) { SDL_QuitSubSystem( SDL_INIT_VIDEO ); return FALSE; } EGLNativeWindowType EGL_handle; EGLContext EGL_context; HDC EGL_device; EGLint EGL_version_major,EGL_version_minor; EGLint nConfigs; EGLConfig EGL_config; GLint success; const EGLint ConfigAttribs[] = { EGL_LEVEL, 0, EGL_DEPTH_SIZE, 16, EGL_STENCIL_SIZE, 0, EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL_NATIVE_RENDERABLE, EGL_FALSE, EGL_NONE }; const EGLint ContextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE }; SDL_SysWMinfo info; SDL_VERSION(&info.version); SDL_GetWMInfo(&info); EGL_handle = (EGLNativeWindowType) info.window; EGL_device = GetDC(EGL_handle); printf("EGL Context Creation\n"); EGL_display = eglGetDisplay((EGLNativeDisplayType) EGL_device); if (EGL_display == EGL_NO_DISPLAY){ printf( "EGL Display Get failed: %s \n", EGLErrorString()); return FALSE; } if (!eglInitialize(EGL_display, &EGL_version_major, &EGL_version_minor)){ printf( "EGL Display Initialize failed: %s \n", EGLErrorString()); return FALSE; } if (!eglChooseConfig(EGL_display, ConfigAttribs, &EGL_config, 1, &nConfigs)){ printf( "EGL Configuration failed: %s \n", EGLErrorString()); return FALSE; } else if (nConfigs != 1){ printf( "EGL Configuration failed: nconfig %i, %s \n", nConfigs, EGLErrorString()); return FALSE; } EGL_surface = eglCreateWindowSurface(EGL_display, EGL_config, EGL_handle, NULL); if (EGL_surface == EGL_NO_SURFACE){ printf("EGL Surface Creation failed: %s will attempt without window... \n", EGLErrorString()); EGL_surface = eglCreateWindowSurface(EGL_display, EGL_config, NULL, NULL); if (EGL_surface == EGL_NO_SURFACE){ printf( "EGL Surface Creation failed: %s \n", EGLErrorString()); return FALSE; } } eglBindAPI(EGL_OPENGL_ES_API); EGL_context = eglCreateContext(EGL_display, EGL_config, EGL_NO_CONTEXT, ContextAttribs); if (EGL_context == EGL_NO_CONTEXT){ printf( "EGL Context Creation failed: %s \n", EGLErrorString()); return FALSE; } if (!eglMakeCurrent(EGL_display, EGL_surface, EGL_surface, EGL_context)){ printf( "EGL Make Current failed: %s \n", EGLErrorString()); return FALSE; }; eglSwapInterval(EGL_display, 1); */ #ifdef USE_SDL //// paulscode, added for switching between RGBA8888 and RGB565 // (part of the color banding fix) int bitsPP; if( Android_JNI_UseRGBA8888() ) bitsPP = 32; else bitsPP = 16; /* Set the video mode */ SDL_Surface* hScreen; printf( "Setting video mode %dx%d...\n", windowSetting.uDisplayWidth, windowSetting.uDisplayHeight ); // TODO: I should actually check what the pixelformat is, rather than assuming 16 bpp (RGB_565) or 32 bpp (RGBA_8888): // if (!(hScreen = SDL_SetVideoMode( windowSetting.uDisplayWidth, windowSetting.uDisplayHeight, 16, SDL_HWSURFACE ))) if (!(hScreen = SDL_SetVideoMode( windowSetting.uDisplayWidth, windowSetting.uDisplayHeight, bitsPP, SDL_HWSURFACE ))) { printf( "Problem setting videomode %dx%d: %s\n", windowSetting.uDisplayWidth, windowSetting.uDisplayHeight, SDL_GetError() ); SDL_QuitSubSystem( SDL_INIT_VIDEO ); return false; } #endif InitState(); InitOGLExtension(); sprintf(m_strDeviceStats, "%.60s - %.128s : %.60s", m_pVendorStr, m_pRenderStr, m_pVersionStr); TRACE0(m_strDeviceStats); DebugMessage(M64MSG_INFO, "Using OpenGL: %s", m_strDeviceStats); GLint precision,range; glGetShaderPrecisionFormat(GL_VERTEX_SHADER,GL_LOW_FLOAT,&precision,&range); DebugMessage(M64MSG_INFO,"GLSL Vertex Shader lowp precision:%i range:%i",precision,range); glGetShaderPrecisionFormat(GL_VERTEX_SHADER,GL_MEDIUM_FLOAT,&precision,&range); DebugMessage(M64MSG_INFO,"GLSL Vertex Shader mediump precision:%i range:%i",precision,range); glGetShaderPrecisionFormat(GL_VERTEX_SHADER,GL_HIGH_FLOAT,&precision,&range); DebugMessage(M64MSG_INFO,"GLSL Vertex Shader highp precision:%i range:%i",precision,range); glGetShaderPrecisionFormat(GL_FRAGMENT_SHADER ,GL_LOW_FLOAT,&precision,&range); DebugMessage(M64MSG_INFO,"GLSL Fragment Shader lowp precision:%i range:%i",precision,range); glGetShaderPrecisionFormat(GL_FRAGMENT_SHADER,GL_MEDIUM_FLOAT,&precision,&range); DebugMessage(M64MSG_INFO,"GLSL Fragment Shader mediump precision:%i range:%i",precision,range); glGetShaderPrecisionFormat(GL_FRAGMENT_SHADER,GL_HIGH_FLOAT,&precision,&range); DebugMessage(M64MSG_INFO,"GLSL Fragment Shader highp precision:%i range:%i",precision,range); Unlock(); Clear(CLEAR_COLOR_AND_DEPTH_BUFFER); // Clear buffers UpdateFrame(); Clear(CLEAR_COLOR_AND_DEPTH_BUFFER); UpdateFrame(); m_bReady = true; status.isVertexShaderEnabled = false; return true; }
void Boss::UpdateBoss() { int x = GetTimerAttack(); if( x >= BOSS_ATTACK_START || HeadsComing == true ) { HeadsComing = true; AnimPaceBoss++; HeadTimer++; SetState( BOSS_ATTACK ); if( AnimPaceBoss >= ANIMPACEBOSSHEAD ) { UpdateFrame(); AnimPaceBoss = 0; } ResetAttackTimer(); if( HeadTimer >= 20 ) { if( HeadAnimation == true ) { HeadTimer = 0; My_BossHead.push_back( CreateBossHeads( xPos, yPos + 10, surface, 20 * SizeHeads )); SizeHeads++; } if( GetFrame() >= 4 ) { HeadAnimation = true; SetFrame( BOSS_IDLE ); } } if( SizeHeads == 6 ) { HeadsComing = false; SetFrame( BOSS_IDLE ); SizeHeads = 1; } } else { SetFrame( BOSS_IDLE ); UpdateAttackTimer(); } //sanity check switch( GetState() ) { case BOSS_IDLE: { SDL_BlitSurface( gamestate.GetSurface( surface ), &GetClips( GetFrame() ), gamestate.screen, &ReturnDestRect() ); } case BOSS_ATTACK: { SDL_BlitSurface( gamestate.GetSurface( surface ), &GetClips( GetFrame() ), gamestate.screen, &ReturnDestRect() ); } case BOSS_DIE: { SDL_BlitSurface( gamestate.GetSurface( surface ), &GetClips( GetFrame() ), gamestate.screen, &ReturnDestRect() ); } } UpdateHeads(); }
//----------------------------------------------------------------- // Sprite General Methods //----------------------------------------------------------------- SPRITEACTION Sprite::Update() { // See if the sprite needs to be killed if (m_bDying) return SA_KILL; // Update the frame UpdateFrame(); // Update the position SDL_Point ptNewPosition, ptSpriteSize; ptNewPosition.x = m_rcPosition.x + m_ptVelocity.x; ptNewPosition.y = m_rcPosition.y + m_ptVelocity.y; ptSpriteSize.x = m_rcPosition.w; ptSpriteSize.y = m_rcPosition.h; // Check the bounds // Wrap? if (m_baBoundsAction == BA_WRAP) { if ((ptNewPosition.x + ptSpriteSize.x) < m_rcBounds.x) ptNewPosition.x = m_rcBounds.w; else if (ptNewPosition.x > m_rcBounds.w) ptNewPosition.x = m_rcBounds.x - ptSpriteSize.x; if ((ptNewPosition.y + ptSpriteSize.y) < m_rcBounds.y) ptNewPosition.y = m_rcBounds.h; else if (ptNewPosition.y > m_rcBounds.h) ptNewPosition.y = m_rcBounds.y - ptSpriteSize.y; } // Bounce? else if (m_baBoundsAction == BA_BOUNCE) { bool bBounce = false; SDL_Point ptNewVelocity = m_ptVelocity; if (ptNewPosition.x < m_rcBounds.x) { bBounce = true; ptNewPosition.x = m_rcBounds.x; ptNewVelocity.x = -ptNewVelocity.x; } else if ((ptNewPosition.x + ptSpriteSize.x) > m_rcBounds.w) { bBounce = true; ptNewPosition.x = m_rcBounds.w - ptSpriteSize.x; ptNewVelocity.x = -ptNewVelocity.x; } if (ptNewPosition.y < m_rcBounds.y) { bBounce = true; ptNewPosition.y = m_rcBounds.y; ptNewVelocity.y = -ptNewVelocity.y; } else if ((ptNewPosition.y + ptSpriteSize.y) > m_rcBounds.h) { bBounce = true; ptNewPosition.y = m_rcBounds.h - ptSpriteSize.y; ptNewVelocity.y = -ptNewVelocity.y; } if (bBounce) SetVelocity(ptNewVelocity); } // Die? else if (m_baBoundsAction == BA_DIE) { if ((ptNewPosition.x + ptSpriteSize.x) < m_rcBounds.x || ptNewPosition.x > m_rcBounds.w || (ptNewPosition.y + ptSpriteSize.y) < m_rcBounds.y || ptNewPosition.y > m_rcBounds.h) return SA_KILL; } // Stop (default) else { if (ptNewPosition.x < m_rcBounds.x || ptNewPosition.x > (m_rcBounds.w - ptSpriteSize.x)) { ptNewPosition.x = std::max(m_rcBounds.x, std::min(ptNewPosition.x, m_rcBounds.w - ptSpriteSize.x)); SetVelocity(0, 0); } if (ptNewPosition.y < m_rcBounds.y || ptNewPosition.y > (m_rcBounds.h - ptSpriteSize.y)) { ptNewPosition.y = std::max(m_rcBounds.y, std::min(ptNewPosition.y, m_rcBounds.h - ptSpriteSize.y)); SetVelocity(0, 0); } } SetPosition(ptNewPosition); return SA_NONE; }