EglContext::EglContext(EglContext* shared) : m_display (EGL_NO_DISPLAY), m_context (EGL_NO_CONTEXT), m_surface (EGL_NO_SURFACE), m_config (NULL) { // Get the initialized EGL display m_display = getInitializedDisplay(); // Get the best EGL config matching the default video settings m_config = getBestConfig(m_display, VideoMode::getDesktopMode().bitsPerPixel, ContextSettings()); updateSettings(); // Note: The EGL specs say that attrib_list can be NULL when passed to eglCreatePbufferSurface, // but this is resulting in a segfault. Bug in Android? EGLint attrib_list[] = { EGL_WIDTH, 1, EGL_HEIGHT,1, EGL_NONE }; m_surface = eglCheck(eglCreatePbufferSurface(m_display, m_config, attrib_list)); // Create EGL context createContext(shared); }
GlContext* GlContext::create() { // Make sure that there's an active context (context creation may need extensions, and thus a valid context) assert(sharedContext != NULL); Lock lock(mutex); GlContext* context = NULL; // We don't use acquireTransientContext here since we have // to ensure we have exclusive access to the shared context // in order to make sure it is not active during context creation { sharedContext->setActive(true); // Create the context context = new ContextType(sharedContext); sharedContext->setActive(false); } context->initialize(ContextSettings()); return context; }
GlxContext::GlxContext(GlxContext* shared) : myWindow (0), myContext (NULL), myOwnsWindow(true) { // Open a connection with the X server myDisplay = XOpenDisplay(NULL); // Create a dummy window (disabled and hidden) int screen = DefaultScreen(myDisplay); myWindow = XCreateWindow(myDisplay, RootWindow(myDisplay, screen), 0, 0, 1, 1, 0, DefaultDepth(myDisplay, screen), InputOutput, DefaultVisual(myDisplay, screen), 0, NULL); // Create the context CreateContext(shared, VideoMode::GetDesktopMode().BitsPerPixel, ContextSettings(0, 0, 0)); // Activate the context SetActive(true); }
void GlContext::globalInit() { Lock lock(mutex); if (sharedContext) return; // Create the shared context sharedContext = new ContextType(NULL); sharedContext->initialize(ContextSettings()); // Load our extensions vector extensions.clear(); // Check whether a >= 3.0 context is available int majorVersion = 0; glGetIntegerv(GL_MAJOR_VERSION, &majorVersion); if (glGetError() == GL_INVALID_ENUM) { // Try to load the < 3.0 way const char* extensionString = reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)); do { const char* extension = extensionString; while(*extensionString && (*extensionString != ' ')) extensionString++; extensions.push_back(std::string(extension, extensionString)); } while (*extensionString++); } else { // Try to load the >= 3.0 way glGetStringiFuncType glGetStringiFunc = NULL; glGetStringiFunc = reinterpret_cast<glGetStringiFuncType>(getFunction("glGetStringi")); if (glGetStringiFunc) { int numExtensions = 0; glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions); if (numExtensions) { for (unsigned int i = 0; i < static_cast<unsigned int>(numExtensions); ++i) { const char* extensionString = reinterpret_cast<const char*>(glGetStringiFunc(GL_EXTENSIONS, i)); extensions.push_back(extensionString); } } } } // Deactivate the shared context so that others can activate it when necessary sharedContext->setActive(false); }
void App::initSFML() { // stwórz okno window.create(VideoMode(windowWidth, windowHeight), "OpenGL", Style::Fullscreen, ContextSettings(32)); window.setFramerateLimit(60); window.setKeyRepeatEnabled(false); window.setMouseCursorVisible(false); Mouse::setPosition(getWindowCenter(), window); }
void createWindow(Window* app) { app->contextSettings = ContextSettings(24,8,0,3,3); app->contextVideoMode = VideoMode(WIDTH,HEIGHT,32); app->contextWindow = new sf::Window(app->contextVideoMode,"Midori - NG4 Logo identify tool", Style::Close,app->contextSettings); app->contextWindow->SetActive(); app->contextWindow->ShowMouseCursor(true); app->contextWindow->SetCursorPosition(WIDTH/2,HEIGHT/2); }
bool RenderImageImplDefault::Create(unsigned int width, unsigned int height, unsigned int, bool depthBuffer) { // Store the dimensions myWidth = width; myHeight = height; // Create the in-memory OpenGL context myContext = new Context(ContextSettings(depthBuffer ? 32 : 0, 0, 4), width, height); return true; }
bool RenderTextureImplDefault::create(unsigned int width, unsigned int height, unsigned int, bool depthBuffer) { // Store the dimensions m_width = width; m_height = height; // Create the in-memory OpenGL context m_context = new Context(ContextSettings(depthBuffer ? 32 : 0), width, height); return true; }
GLContextWin32::GLContextWin32(GLContextWin32 *shared) : mWindow(null), mDeviceContext(null), mContext(null), mOwnsWindow(true) { mWindow = CreateWindowA("STATIC", "", WS_POPUP | WS_DISABLED, 0, 0, 1, 1, null, null, GetModuleHandle(null), null); ShowWindow(mWindow, SW_HIDE); mDeviceContext = GetDC(mWindow); if (mDeviceContext) { createContext(shared, VideoMode::getDesktopMode().bpp, ContextSettings()); } }
void WindowBase::create(VideoMode mode, const String& title, Uint32 style) { // Destroy the previous window implementation close(); // Fullscreen style requires some tests if (style & Style::Fullscreen) { // Make sure there's not already a fullscreen window (only one is allowed) if (getFullscreenWindow()) { err() << "Creating two fullscreen windows is not allowed, switching to windowed mode" << std::endl; style &= ~Style::Fullscreen; } else { // Make sure that the chosen video mode is compatible if (!mode.isValid()) { err() << "The requested video mode is not available, switching to a valid mode" << std::endl; mode = VideoMode::getFullscreenModes()[0]; } // Update the fullscreen window setFullscreenWindow(this); } } // Check validity of style according to the underlying platform #if defined(SFML_SYSTEM_IOS) || defined(SFML_SYSTEM_ANDROID) if (style & Style::Fullscreen) style &= ~Style::Titlebar; else style |= Style::Titlebar; #else if ((style & Style::Close) || (style & Style::Resize)) style |= Style::Titlebar; #endif // Recreate the window implementation m_impl = priv::WindowImpl::create(mode, title, style, ContextSettings(0, 0, 0, 0, 0, 0xFFFFFFFF, false)); // Perform common initializations initialize(); }
WglContext::WglContext(WglContext* shared) : m_window (NULL), m_deviceContext(NULL), m_context (NULL), m_ownsWindow (true) { // Creating a dummy window is mandatory: we could create a memory DC but then // its pixel format wouldn't match the regular contexts' format, and thus // wglShareLists would always fail. Too bad... // Create a dummy window (disabled and hidden) m_window = CreateWindowA("STATIC", "", WS_POPUP | WS_DISABLED, 0, 0, 1, 1, NULL, NULL, GetModuleHandle(NULL), NULL); ShowWindow(m_window, SW_HIDE); m_deviceContext = GetDC(m_window); // Create the context if (m_deviceContext) createContext(shared, VideoMode::getDesktopMode().bitsPerPixel, ContextSettings()); }
GameManager::GameManager() : _lua(new LuaContext), _world(new World), _script_manager(new ScriptManager(_lua, SCRIPT_PATH)), _image_manager(new ImageManager), _shape_manager(new ShapeManager(SHAPE_PATH)), _sound_manager(new SoundManager(SOUND_PATH)), _music_manager(new MusicManager(MUSIC_PATH)), _level_manager(new LevelManager(LEVEL_PATH)), _physics_world(new b2World(b2Vec2_zero)), _sfgui(new sfg::SFGUI), _desktop(new sfg::Desktop) { this->_render_window = make_shared<RenderWindow>( VideoMode(SCREEN_SIZE.x, SCREEN_SIZE.y), "RAY", sf::Style::Default, ContextSettings(0, 0, 4) ); this->_render_window->setFramerateLimit(FPS); #ifdef DEBUG this->_debug_draw.setWindow(*this->_render_window); this->resetPhysicsWorld(); #endif // DEBUG this->_state_machine.reset( new GSM( *this->_world, "start", { {"start", make_shared<TitleScreenState>(*this)}, {"game", make_shared<InGameState>(*this)}, }, { {make_pair("swap", "start"), "game"}, {make_pair("swap", "game"), "start"}, {make_pair("advance", "game"), "game"}, {make_pair("return", "game"), "start"}, })); enemiesKilled = 0; }
GlContext::GlContext() : m_window(NULL), m_deviceContext(NULL), m_context(NULL), m_ownsWindow(true) { m_window = CreateWindowA("STATIC", "", WS_POPUP | WS_DISABLED, 0, 0, 1, 1, NULL, NULL, GetModuleHandle(NULL), NULL); ShowWindow(m_window, SW_HIDE); m_deviceContext = GetDC(m_window); if (m_deviceContext) { createContext(VideoMode::getDesktopMode().bitsPerPixel, ContextSettings()); } makeCurrent(); //now that we have a dummy context we can initialize glew initGlew(); }
GlxContext::GlxContext(GlxContext* shared) : m_display (NULL), m_window (0), m_context (NULL), m_pbuffer (0), m_ownsWindow(false) { // Save the creation settings m_settings = ContextSettings(); // Make sure that extensions are initialized if this is not the shared context // The shared context is the context used to initialize the extensions if (shared && shared->m_display) ensureExtensionsInit(shared->m_display, DefaultScreen(shared->m_display)); // Create the rendering surface (window or pbuffer if supported) createSurface(shared, 1, 1, VideoMode::getDesktopMode().bitsPerPixel); // Create the context createContext(shared); }
GlxContext::GlxContext(GlxContext* shared) : m_window (0), m_context (NULL), m_ownsWindow(true) { // Open a connection with the X server m_display = OpenDisplay(); // Create a dummy window (disabled and hidden) int screen = DefaultScreen(m_display); m_window = XCreateWindow(m_display, RootWindow(m_display, screen), 0, 0, 1, 1, 0, DefaultDepth(m_display, screen), InputOutput, DefaultVisual(m_display, screen), 0, NULL); // Create the context createContext(shared, VideoMode::getDesktopMode().bitsPerPixel, ContextSettings()); }
GlxContext::GlxContext(GlxContext* shared) : m_window (0), m_context (NULL), m_ownsWindow(true) { // Open a connection with the X server m_display = OpenDisplay(); m_connection = XGetXCBConnection(m_display); xcb_screen_t* screen = XCBScreenOfDisplay(m_connection, DefaultScreen(m_display)); // Choose the visual according to the context settings XVisualInfo visualInfo = selectBestVisual(m_display, VideoMode::getDesktopMode().bitsPerPixel, ContextSettings()); // Define the window attributes xcb_colormap_t colormap = xcb_generate_id(m_connection); xcb_create_colormap(m_connection, XCB_COLORMAP_ALLOC_NONE, colormap, screen->root, visualInfo.visualid); const uint32_t value_list[] = {colormap}; // Create a dummy window (disabled and hidden) m_window = xcb_generate_id(m_connection); xcb_create_window( m_connection, static_cast<uint8_t>(visualInfo.depth), m_window, screen->root, 0, 0, 1, 1, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, visualInfo.visualid, XCB_CW_COLORMAP, value_list ); // Create the context createContext(shared, VideoMode::getDesktopMode().bitsPerPixel, ContextSettings()); }
const ContextSettings SDL2WindowBackend::getSettings() const { //settings not finalized; return ContextSettings(); }
/** * Method is used to create application window. */ void Core::createWindow() { const int width = Configuration::getInstance()->getWidth(); const int height = Configuration::getInstance()->getHeight(); const bool isFull = Configuration::getInstance()->isFullscreenEnabled(); if(isFull) window = new RenderWindow(VideoMode(width,height,32),"DammSmallEngine", Style::Fullscreen, ContextSettings()); else window = new RenderWindow(VideoMode(width,height,32),"DammSmallEngine", Style::Close, ContextSettings()); }