MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { initializeGLContext(); initializeGLArea(); initializeParamsArea(); resize(600, 400); }
SkCommandBufferGLContext::SkCommandBufferGLContext(void* nativeWindow, int msaaSampleCount) { static const EGLint surfaceAttribs[] = { EGL_NONE }; EGLint configAttribs[] = { EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8, EGL_ALPHA_SIZE, 8, EGL_DEPTH_SIZE, 8, EGL_STENCIL_SIZE, 8, EGL_SAMPLE_BUFFERS, 1, EGL_SAMPLES, msaaSampleCount, EGL_NONE }; if (msaaSampleCount == 0) { configAttribs[12] = EGL_NONE; } initializeGLContext(nativeWindow, configAttribs, surfaceAttribs); }
SkCommandBufferGLContext::SkCommandBufferGLContext() : fContext(EGL_NO_CONTEXT) , fDisplay(EGL_NO_DISPLAY) , fSurface(EGL_NO_SURFACE) { static const EGLint configAttribs[] = { EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8, EGL_ALPHA_SIZE, 8, EGL_NONE }; static const EGLint surfaceAttribs[] = { EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE }; initializeGLContext(nullptr, configAttribs, surfaceAttribs); }
void OpenGLGraphicsManager::notifyContextCreate(const Graphics::PixelFormat &defaultFormat, const Graphics::PixelFormat &defaultFormatAlpha) { // Initialize context for use. initializeGLContext(); // Initialize pipeline. delete _pipeline; _pipeline = nullptr; #if !USE_FORCED_GLES if (g_context.shadersSupported) { ShaderMan.notifyCreate(); _pipeline = new ShaderPipeline(ShaderMan.query(ShaderManager::kDefault)); } #endif #if !USE_FORCED_GLES2 if (_pipeline == nullptr) { _pipeline = new FixedPipeline(); } #endif g_context.setPipeline(_pipeline); // Disable 3D properties. GL_CALL(glDisable(GL_CULL_FACE)); GL_CALL(glDisable(GL_DEPTH_TEST)); GL_CALL(glDisable(GL_DITHER)); g_context.getActivePipeline()->setColor(1.0f, 1.0f, 1.0f, 1.0f); GL_CALL(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)); // Setup backbuffer state. // Default to black as clear color. _backBuffer.setClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Setup alpha blend (for overlay and cursor). _backBuffer.enableBlend(true); // Setup scissor state accordingly. _backBuffer.enableScissorTest(!_overlayVisible); g_context.getActivePipeline()->setFramebuffer(&_backBuffer); // Clear the whole screen for the first three frames to assure any // leftovers are cleared. _scissorOverride = 3; // We use a "pack" alignment (when reading from textures) to 4 here, // since the only place where we really use it is the BMP screenshot // code and that requires the same alignment too. GL_CALL(glPixelStorei(GL_PACK_ALIGNMENT, 4)); // Refresh the output screen dimensions if some are set up. if (_outputScreenWidth != 0 && _outputScreenHeight != 0) { setActualScreenSize(_outputScreenWidth, _outputScreenHeight); } // TODO: Should we try to convert textures into one of those formats if // possible? For example, when _gameScreen is CLUT8 we might want to use // defaultFormat now. _defaultFormat = defaultFormat; _defaultFormatAlpha = defaultFormatAlpha; if (_gameScreen) { _gameScreen->recreate(); } if (_overlay) { _overlay->recreate(); } if (_cursor) { _cursor->recreate(); } #ifdef USE_OSD if (_osdMessageSurface) { _osdMessageSurface->recreate(); } if (_osdIconSurface) { _osdIconSurface->recreate(); } #endif }