Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Depends on your code. Usually the device context is created on each platform in a different way</p> <p>Windows:</p> <pre><code>hRC_ = wglCreateContextAttribsARB(hDC_, 0, attributes); // Create and OpenGL 3.x context based on the given attributes if(hRC_ == 0) { GLenum error = glGetError(); // ... handle error } wglMakeCurrent(nullptr, nullptr); // Remove the temporary context from being active wglDeleteContext(tempContext); // Delete the temporary OpenGL 2.1 context wglMakeCurrent(hDC_, hRC_); // Make our OpenGL 3.0 context current </code></pre> <p>X11/GLX:</p> <pre><code>const char *glxExts = glXQueryExtensionsString( display_, DefaultScreen( display_ ) ); if(isExtensionSupported( glxExts, "GLX_ARB_create_context" )) // If the OpenGL 3.x context creation extension is available { glXCreateContextAttribsARB = (GLXContext(*)(Display* dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list))glXGetProcAddressARB((GLubyte*)"glXCreateContextAttribsARB"); hRC_ = glXCreateContextAttribsARB(display_, fbConfigs_[0], 0, true, attributes); // Create and OpenGL 3.x context based on the given attributes if(!glXMakeCurrent(display_, window_, hRC_)) { throw BlueFramework::BlueCore::Exception("Making context current failed."); }; // Make our OpenGL 3.0 context current GLenum err = glewInit(); // Enable GLEW if (GLEW_OK != err) // If GLEW fails { std::cerr &lt;&lt; err &lt;&lt; std::endl; std::cerr &lt;&lt; "Error: " &lt;&lt; glewGetString(err) &lt;&lt; std::endl; throw BlueFramework::BlueCore::Exception("GLEW is not initialized!"); } } </code></pre> <p>There are also differences in the attributes handed over to XXXCreateContextAttribs:</p> <p>Windows:</p> <pre><code>WGL_CONTEXT_MAJOR_VERSION_ARB, majorVersion_, // Set the MAJOR version of OpenGL WGL_CONTEXT_MINOR_VERSION_ARB, miniorVersion_, // Set the MINOR version of OpenGL WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB // Set our OpenGL context to be forward com WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB ... </code></pre> <p>X11/GLX:</p> <pre><code>GLX_CONTEXT_MAJOR_VERSION_ARB, majorVersion_, // Set the MAJOR version of OpenGL GLX_CONTEXT_MINOR_VERSION_ARB, miniorVersion_, // Set the MINOR version of OpenGL GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB // Set our OpenGL context to be forward compatible //#ifdef _DEBUG | GLX_CONTEXT_DEBUG_BIT_ARB //#endif , GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB, 0 ... </code></pre> <p>After device creation the OpenGL dependent code is almost the same. To create a render context in Win you need to create a Window handle.</p> <p>Can look something like this:</p> <pre><code>// Register class WNDCLASSEX wcex; wcex.cbSize = sizeof( WNDCLASSEX ); wcex.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; wcex.lpfnWndProc = (WNDPROC)RenderWindow::controlEventsProcessor;//WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = nullptr;//LoadIcon( hInstance, ( LPCTSTR )IDI_TUTORIAL1 ); wcex.hCursor = LoadCursor( NULL, IDC_ARROW ); if(fullscreen_) { wcex.hbrBackground = ( HBRUSH )( COLOR_WINDOW + 1 ); } else { wcex.hbrBackground = ( HBRUSH )( COLOR_WINDOW + 1 ); } wcex.lpszMenuName = NULL; wcex.lpszClassName = wstrWindowClassName_.c_str(); //ss.str().c_str(); wcex.hIconSm = nullptr;//LoadIcon( wcex.hInstance, ( LPCTSTR )IDI_TUTORIAL1 ); if( !RegisterClassEx( &amp;wcex ) ) { BLUE_LOG_STREAM_EX( "BlueFramework::BlueGraphicsEngine::RenderWindow::initWindow", buw::eLogSeverityLevel::Error) &lt;&lt; "RegisterClassEx failed"; return E_FAIL; } // Create window hInstance = hInstance; RECT rc = { 0, 0, width, height }; if(!AdjustWindowRect( &amp;rc, WS_OVERLAPPEDWINDOW, FALSE )) { BLUE_LOG_STREAM_EX( "BlueFramework::BlueGraphicsEngine::RenderWindow::initWindow", buw::eLogSeverityLevel::Error) &lt;&lt; "AdjustWindowRect failed"; } if(fullscreen_) { hWnd_ = CreateWindowEx(0, wstrWindowClassName_.c_str(),//L"BlueRenderWindow",//ss.str().c_str(), L"Render Window", WS_EX_TOPMOST | WS_POPUP, // fullscreen values 0, 0, // the starting x and y positions should be 0 rc.right - rc.left, rc.bottom - rc.top, nullptr, nullptr, hInstance, nullptr); } else { hWnd_ = CreateWindowEx(0, wstrWindowClassName_.c_str(),//L"BlueRenderWindow",//ss.str().c_str(), L"Render Window", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, rc.right - rc.left, rc.bottom - rc.top, nullptr, nullptr, hInstance, nullptr); } </code></pre> <p>The counter part in X11/GLX can look something like this:</p> <pre><code>int attribs[] = { GLX_RENDER_TYPE, GLX_RGBA_BIT, GLX_X_RENDERABLE, True, GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, GLX_X_VISUAL_TYPE, GLX_TRUE_COLOR, GLX_DOUBLEBUFFER, True, GLX_RED_SIZE, 8, GLX_BLUE_SIZE, 8, GLX_GREEN_SIZE, 8, GLX_ALPHA_SIZE, 8, GLX_DEPTH_SIZE, 24, GLX_STENCIL_SIZE, 8, 0L //= None }; display_ = XOpenDisplay(nullptr); if(display_ == nullptr) { BLUE_LOG_STREAM_EX( "BlueFramework::BlueGraphicsEngine::RenderWindow::initWindow", buw::eLogSeverityLevel::Error) &lt;&lt; "Cannot connect to X-Server"; return false; } int screenNr = XDefaultScreen (display_); int numConfigs = 0; // glXCreateContextAttribsARB = (GLXContext(*)(Display* dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list))glXGetProcAddressARB((GLubyte*)"glXCreateContextAttribsARB"); glXChooseFBConfig = (GLXFBConfig*(*)(Display *dpy, int screen, const int *attrib_list, int *nelements))glXGetProcAddressARB((GLubyte*)"glXChooseFBConfig"); glXGetVisualFromFBConfig = (XVisualInfo*(*)(Display *dpy, GLXFBConfig config))glXGetProcAddressARB((GLubyte*)"glXGetVisualFromFBConfig"); fbConfigs_ = glXChooseFBConfig(display_, XDefaultScreen(display_), attribs, &amp;numConfigs); if(fbConfigs_ == nullptr) { BLUE_LOG_STREAM_EX( "BlueFramework::BlueGraphicsEngine::RenderWindow::initWindow", buw::eLogSeverityLevel::Error) &lt;&lt; "Failed to get framebuffer config"; return false; } XVisualInfo* vi = glXGetVisualFromFBConfig(display_, fbConfigs_[0]); if(vi == nullptr) { BLUE_LOG_STREAM_EX( "BlueFramework::BlueGraphicsEngine::RenderWindow::initWindow", buw::eLogSeverityLevel::Error) &lt;&lt; "No appropriate visual found (X-Server)"; return false; } bool doubleBuffered = true; Colormap cmap = XCreateColormap (display_, RootWindow (display_, vi-&gt;screen), vi-&gt;visual, AllocNone); XSetWindowAttributes attributes; attributes.background_pixmap = 0L; attributes.colormap = cmap; attributes.border_pixel = 0; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload