void SpectrogramSettings::CacheWindows() const { if (hFFT == NULL || window == NULL) { double scale; const auto fftLen = WindowSize() * ZeroPaddingFactor(); const auto padding = (WindowSize() * (zeroPaddingFactor - 1)) / 2; hFFT = GetFFT(fftLen); RecreateWindow(window, WINDOW, fftLen, padding, windowType, windowSize, scale); if (algorithm == algReassignment) { RecreateWindow(tWindow, TWINDOW, fftLen, padding, windowType, windowSize, scale); RecreateWindow(dWindow, DWINDOW, fftLen, padding, windowType, windowSize, scale); } } }
// ----------------------- // SDL2 specific methods // ----------------------- void GraphicsSDL::create_game_window(bool fullscreen) { RecreateWindow(fullscreen); create_renderer(); create_screen_surface(); create_screen_tex(); }
void SpectrogramSettings::CacheWindows() const { #ifdef EXPERIMENTAL_USE_REALFFTF if (hFFT == NULL || window == NULL) { double scale; const int fftLen = windowSize * zeroPaddingFactor; const int padding = (windowSize * (zeroPaddingFactor - 1)) / 2; if (hFFT != NULL) EndFFT(hFFT); hFFT = InitializeFFT(fftLen); RecreateWindow(window, WINDOW, fftLen, padding, windowType, windowSize, scale); } #endif // EXPERIMENTAL_USE_REALFFTF }
void CWinSystemX11::NotifyXRREvent() { CLog::Log(LOGDEBUG, "%s - notify display reset event", __FUNCTION__); CSingleLock lock(g_graphicsContext); if (!g_xrandr.Query(true)) { CLog::Log(LOGERROR, "WinSystemX11::RefreshWindow - failed to query xrandr"); return; } // if external event update resolutions if (!m_bIsInternalXrr) { UpdateResolutions(); } RecreateWindow(); }
// ---------------------------- // SDL 1.2.x specific methods // ---------------------------- void GraphicsSDL::create_game_window(bool fullscreen) { RecreateWindow(fullscreen); }
void GraphicsSDL::ChangeFullScreen(bool fullscreen) { RecreateWindow(fullscreen); }
glWindow::glWindow (bool fullScreen, bool border, int width, int height, int bpp, bool stencil, std::string title, bool allowResizing, bool fitToWorkArea, ResetGLModeType resetGLMode) { m_resetGLMode = resetGLMode; // Null default values // If constructor is aborted, then destructor wont try to deallocate garbage handles. m_HDC = 0; m_HGLRC = 0; m_HWnd = 0; m_HInstance = 0; m_active = false; m_focused = false; m_visible = false; m_closing = false; m_bufStart = 0; m_bufEnd = 0; m_scanBufStart = 0; m_scanBufEnd = 0; m_showingCursor = true; // Clear key buffers ClearKeyBuffers (); // Defaults m_fov = 60; m_nearClip = 1; m_farClip = 1000; m_painting = false; m_dontPaint = false; m_pausePressed = false; m_mouseX = 0; m_mouseY = 0; m_mouseButton [0] = 0; m_mouseButton [1] = 0; m_mouseButton [2] = 0; m_mouseWheel = 0; m_mouseWheelDelta = 0; m_mouseCentred = false; m_HInstance = GetModuleHandle(NULL); // Grab An Instance For Our Window // Create open GL window. // Note: Caller should check error state after construction. If error set, // then the window is probably unusable WNDCLASS wc; // Windows Class Structure wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; // Redraw On Size, And Own DC For Window. wc.lpfnWndProc = (WNDPROC) ::WndProc; // WndProc Handles Messages wc.cbClsExtra = 0; // No Extra Window Data wc.cbWndExtra = 0; // No Extra Window Data wc.hInstance = m_HInstance; // Set The Instance wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); // Load The Default Icon wc.hCursor = LoadCursor(NULL, IDC_ARROW); // Load The Arrow Pointer wc.hbrBackground = NULL; // No Background Required For GL wc.lpszMenuName = NULL; // We Don't Want A Menu wc.lpszClassName = "gbOpenGL"; // Set The Class Name if (!RegisterClass(&wc)) // Attempt To Register The Window Class { SetError ("Window class registration failed"); return; } RecreateWindow (fullScreen, border, width, height, bpp, stencil, title, allowResizing, fitToWorkArea); }
bool glWindow::ResetGL () { if (m_resetGLMode == RGM_RECREATEWINDOW) { RecreateWindow (m_fullScreen, m_border, m_width, m_height, m_bpp, m_stencil, m_title, m_allowResizing, m_fitToWorkArea); return true; } else if (m_resetGLMode == RGM_RECREATECONTEXT) { RecreateGLContext (); return true; } // Setup OpenGL defaults. // This should reset as much as possible back to the initial state of OpenGL. // Exceptions: // * Projection matrix is initialised to a perspective transform // End current gl block try { glEnd (); } catch (...) { ; } m_dontPaint = false; // Intialise matrices try { glMatrixMode (GL_PROJECTION); ClearGLMatrix (); } catch (...) { ; } try { glMatrixMode (GL_TEXTURE); ClearGLMatrix (); } catch (...) { ; } try { glMatrixMode (GL_MODELVIEW); ClearGLMatrix (); } catch (...) { ; } // Initialise state int i; try { glColor4f (1, 1, 1, 1); } catch (...) { ; } try { glIndexi (1); } catch (...) { ; } try { glTexCoord4f (0, 0, 0, 1); } catch (...) { ; } try { glNormal3f (0, 0, 1); } catch (...) { ; } // try { glRasterPos4f (0, 0, 0, 1); } catch (...) { ; } try { glEdgeFlag (GL_TRUE); } catch (...) { ; } try { glDisable (GL_VERTEX_ARRAY); } catch (...) { ; } try { glDisable (GL_NORMAL_ARRAY); } catch (...) { ; } try { glDisable (GL_COLOR_ARRAY); } catch (...) { ; } try { glDisable (GL_INDEX_ARRAY); } catch (...) { ; } try { glDisable (GL_TEXTURE_COORD_ARRAY); } catch (...) { ; } try { glDisable (GL_EDGE_FLAG_ARRAY); } catch (...) { ; } try { glDepthRange (0, 1); } catch (...) { ; } try { glDisable (GL_NORMALIZE); } catch (...) { ; } for (i = 0; i < GL_MAX_CLIP_PLANES; i++) try { glDisable (GL_CLIP_PLANE0 + i); } catch (...) { ; } GLfloat fog[] = {0, 0, 0, 0}; try { glFogfv (GL_FOG_COLOR, fog); } catch (...) { ; } try { glFogi (GL_FOG_INDEX, 0); } catch (...) { ; } try { glFogf (GL_FOG_DENSITY, 1.0); } catch (...) { ; } try { glFogf (GL_FOG_START, 0.0); } catch (...) { ; } try { glFogf (GL_FOG_END, 1.0); } catch (...) { ; } try { glFogi (GL_FOG_MODE, GL_EXP); } catch (...) { ; } try { glDisable (GL_FOG); } catch (...) { ; } try { glShadeModel (GL_SMOOTH); } catch (...) { ; } try { glDisable (GL_LIGHTING); } catch (...) { ; } try { glDisable (GL_COLOR_MATERIAL); } catch (...) { ; } try { glColorMaterial (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); } catch (...) { ; } GLfloat ambient[] = { 0.2, 0.2, 0.2, 1.0 }, diffuse[] = { 0.8, 0.8, 0.8, 1.0 }, specular[] = { 0.0, 0.0, 0.0, 1.0 }, emission[] = { 0.0, 0.0, 0.0, 1.0 }, shininess[] = { 0.0 }; try { glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT, ambient); } catch (...) { ; } try { glMaterialfv (GL_FRONT_AND_BACK, GL_DIFFUSE, diffuse); } catch (...) { ; } try { glMaterialfv (GL_FRONT_AND_BACK, GL_SPECULAR, specular); } catch (...) { ; } try { glMaterialfv (GL_FRONT_AND_BACK, GL_EMISSION, emission); } catch (...) { ; } try { glMaterialfv (GL_FRONT_AND_BACK, GL_SHININESS, shininess); } catch (...) { ; } try { glLightModelfv (GL_LIGHT_MODEL_AMBIENT, ambient); } catch (...) { ; } try { glLightModeli (GL_LIGHT_MODEL_LOCAL_VIEWER, GL_FALSE); } catch (...) { ; } try { glLightModeli (GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE); } catch (...) { ; } GLfloat lambient[] = { 0.0, 0.0, 0.0, 1.0 }, ldiffuse0[] = { 1.0, 1.0, 1.0, 1.0 }, ldiffuse1[] = { 0.0, 0.0, 0.0, 1.0 }, lspecular0[] = { 1.0, 1.0, 1.0, 1.0 }, lspecular1[] = { 0.0, 0.0, 0.0, 1.0 }, lposition[] = { 0.0, 0.0, 1.0, 0.0 }; for (i = 0; i < 8; i++) { try { glLightfv (GL_LIGHT0 + i, GL_AMBIENT, lambient); } catch (...) { ; } try { glLightfv (GL_LIGHT0 + i, GL_DIFFUSE, i == 0 ? ldiffuse0 : ldiffuse1); } catch (...) { ; } try { glLightfv (GL_LIGHT0 + i, GL_SPECULAR, i == 0 ? lspecular0 : lspecular1); } catch (...) { ; } try { glLightfv (GL_LIGHT0 + i, GL_POSITION, lposition); } catch (...) { ; } try { glLightf (GL_LIGHT0 + i, GL_SPOT_EXPONENT, 0.0); } catch (...) { ; } try { glLightf (GL_LIGHT0 + i, GL_CONSTANT_ATTENUATION, 1.0); } catch (...) { ; } try { glLightf (GL_LIGHT0 + i, GL_LINEAR_ATTENUATION, 0.0); } catch (...) { ; } try { glLightf (GL_LIGHT0 + i, GL_QUADRATIC_ATTENUATION, 0.0); } catch (...) { ; } try { glDisable (GL_LIGHT0 + i); } catch (...) { ; } } try { glPointSize (1.0); } catch (...) { ; } try { glDisable (GL_POINT_SMOOTH); } catch (...) { ; } try { glLineWidth (1.0); } catch (...) { ; } try { glDisable (GL_LINE_SMOOTH); } catch (...) { ; } try { glLineStipple (1, 0xffff); } catch (...) { ; } try { glDisable (GL_LINE_STIPPLE); } catch (...) { ; } try { glDisable (GL_CULL_FACE); } catch (...) { ; } try { glCullFace (GL_BACK); } catch (...) { ; } try { glFrontFace (GL_CCW); } catch (...) { ; } try { glDisable (GL_POLYGON_SMOOTH); } catch (...) { ; } try { glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); } catch (...) { ; } try { glDisable (GL_TEXTURE_1D); } catch (...) { ; } try { glDisable (GL_TEXTURE_2D); } catch (...) { ; } try { glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); } catch (...) { ; } try { glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); } catch (...) { ; } try { glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); } catch (...) { ; } try { glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); } catch (...) { ; } GLfloat texBorder[] = {0, 0, 0, 0}; try { glTexParameterfv (GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, texBorder); } catch (...) { ; } try { glDisable (GL_TEXTURE_GEN_T); } catch (...) { ; } try { glDisable (GL_TEXTURE_GEN_S); } catch (...) { ; } try { glDisable (GL_TEXTURE_GEN_R); } catch (...) { ; } try { glDisable (GL_TEXTURE_GEN_Q); } catch (...) { ; } for (i = 0; i < 4; i++) { GLenum coord; switch (i) { case 0: coord = GL_T; break; case 1: coord = GL_S; break; case 2: coord = GL_R; break; case 3: coord = GL_Q; break; } try { glTexGeni (coord, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); } catch (...) { ; } } try { glDisable (GL_SCISSOR_TEST); } catch (...) { ; } try { glDisable (GL_ALPHA_TEST); } catch (...) { ; } try { glAlphaFunc (GL_ALWAYS, 0); } catch (...) { ; } try { glDisable (GL_STENCIL_TEST); } catch (...) { ; } try { glStencilFunc (GL_ALWAYS, 0, 0xffffffff); } catch (...) { ; } try { glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP); } catch (...) { ; } try { glDisable (GL_DEPTH_TEST); } catch (...) { ; } try { glDepthFunc (GL_LESS); } catch (...) { ; } try { glDisable (GL_BLEND); } catch (...) { ; } try { glBlendFunc (GL_ONE, GL_ZERO); } catch (...) { ; } try { glDrawBuffer (GL_BACK); } catch (...) { ; } try { glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); } catch (...) { ; } try { glDepthMask (GL_TRUE); } catch (...) { ; } try { glClearAccum (0, 0, 0, 0); } catch (...) { ; } try { glClearColor (0, 0, 0, 0); } catch (...) { ; } try { glClearDepth (1); } catch (...) { ; } try { glClearIndex (0); } catch (...) { ; } try { glClearStencil (0); } catch (...) { ; } try { glPixelStorei (GL_PACK_SWAP_BYTES, GL_FALSE); } catch (...) { ; } try { glPixelStorei (GL_PACK_LSB_FIRST, GL_FALSE); } catch (...) { ; } try { glPixelStoref (GL_PACK_ROW_LENGTH, 0); } catch (...) { ; } try { glPixelStoref (GL_PACK_SKIP_PIXELS, 0); } catch (...) { ; } try { glPixelStorei (GL_PACK_ALIGNMENT, 4); } catch (...) { ; } try { glPixelStorei (GL_UNPACK_SWAP_BYTES, GL_FALSE); } catch (...) { ; } try { glPixelStorei (GL_UNPACK_LSB_FIRST, GL_FALSE); } catch (...) { ; } try { glPixelStoref (GL_UNPACK_ROW_LENGTH, 0); } catch (...) { ; } try { glPixelStoref (GL_UNPACK_SKIP_PIXELS, 0); } catch (...) { ; } try { glPixelStorei (GL_UNPACK_ALIGNMENT, 4); } catch (...) { ; } try { glPixelTransferi (GL_MAP_COLOR, GL_FALSE); } catch (...) { ; } try { glPixelTransferi (GL_MAP_STENCIL, GL_FALSE); } catch (...) { ; } try { glPixelTransferi (GL_INDEX_SHIFT, 0); } catch (...) { ; } try { glPixelTransferi (GL_INDEX_OFFSET, 0); } catch (...) { ; } try { glPixelTransferf (GL_RED_SCALE, 1.0); } catch (...) { ; } try { glPixelTransferf (GL_GREEN_SCALE, 1.0); } catch (...) { ; } try { glPixelTransferf (GL_BLUE_SCALE, 1.0); } catch (...) { ; } try { glPixelTransferf (GL_ALPHA_SCALE, 1.0); } catch (...) { ; } try { glPixelTransferf (GL_DEPTH_SCALE, 1.0); } catch (...) { ; } try { glPixelTransferf (GL_RED_BIAS, 0.0); } catch (...) { ; } try { glPixelTransferf (GL_GREEN_BIAS, 0.0); } catch (...) { ; } try { glPixelTransferf (GL_BLUE_BIAS, 0.0); } catch (...) { ; } try { glPixelTransferf (GL_ALPHA_BIAS, 0.0); } catch (...) { ; } try { glPixelTransferf (GL_DEPTH_BIAS, 0.0); } catch (...) { ; } try { glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_DONT_CARE); } catch (...) { ; } try { glHint (GL_POINT_SMOOTH_HINT, GL_DONT_CARE); } catch (...) { ; } try { glHint (GL_LINE_SMOOTH_HINT, GL_DONT_CARE); } catch (...) { ; } try { glHint (GL_POLYGON_SMOOTH_HINT, GL_DONT_CARE); } catch (...) { ; } try { glHint (GL_FOG_HINT, GL_DONT_CARE); } catch (...) { ; } // Multitexturing if (ExtensionSupported ("GL_ARB_multitexture")) { // Disable texturing for all texture units int units; try { glGetIntegerv (GL_MAX_TEXTURE_UNITS_ARB, &units); } catch (...) { ; } for (int i = 0; i < units; i++) { if (glActiveTexture != NULL) glActiveTexture (GL_TEXTURE0_ARB + i); try { glDisable (GL_TEXTURE_2D); } catch (...) { ; } try { glDisable (GL_TEXTURE_1D); } catch (...) { ; } if (i == 0) try { glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); } catch (...) { ; } else try { glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND); } catch (...) { ; } } if (glActiveTexture != NULL) try { glActiveTexture (GL_TEXTURE0_ARB); } catch (...) { ; } } // Setup OpenGL defaults OpenGLDefaults (); return TRUE; // Initialization Went OK }