]> git.cworth.org Git - apitrace/blobdiff - glws_wgl.cpp
Try to find the best matching EGL visual according to the profile.
[apitrace] / glws_wgl.cpp
index adc99578e3b7aa9cd885c2de41458301856dec52..ca100d9106b753e5c0cfb8d46453222503c57609 100644 (file)
@@ -23,7 +23,7 @@
  *
  **************************************************************************/
 
-#include "glimports.hpp"
+#include "glproc.hpp"
 #include "glws.hpp"
 
 
@@ -136,21 +136,28 @@ public:
     
     void
     resize(int w, int h) {
-        Drawable::resize(w, h);
+        if (w == width && h == height) {
+            return;
+        }
+
         RECT rClient, rWindow;
         GetClientRect(hWnd, &rClient);
         GetWindowRect(hWnd, &rWindow);
         w += (rWindow.right  - rWindow.left) - rClient.right;
         h += (rWindow.bottom - rWindow.top)  - rClient.bottom;
         SetWindowPos(hWnd, NULL, rWindow.left, rWindow.top, w, h, SWP_NOMOVE);
+
+        Drawable::resize(w, h);
     }
 
     void show(void) {
-        if (!visible) {
-            ShowWindow(hWnd, SW_SHOW);
-
-            Drawable::show();
+        if (visible) {
+            return;
         }
+
+        ShowWindow(hWnd, SW_SHOW);
+
+        Drawable::show();
     }
 
     void swapBuffers(void) {
@@ -165,8 +172,8 @@ public:
     HGLRC hglrc;
     WglContext *shareContext;
 
-    WglContext(const Visual *vis, WglContext *share) :
-        Context(vis),
+    WglContext(const Visual *vis, Profile prof, WglContext *share) :
+        Context(vis, prof),
         hglrc(0),
         shareContext(share)
     {}
@@ -181,6 +188,10 @@ public:
 
 void
 init(void) {
+    /*
+     * OpenGL library must be loaded by the time we call GDI.
+     */
+    __libGlHandle = LoadLibraryA("OPENGL32");
 }
 
 void
@@ -188,7 +199,11 @@ cleanup(void) {
 }
 
 Visual *
-createVisual(bool doubleBuffer) {
+createVisual(bool doubleBuffer, Profile profile) {
+    if (profile != PROFILE_COMPAT) {
+        return NULL;
+    }
+
     Visual *visual = new Visual();
 
     visual->doubleBuffer = doubleBuffer;
@@ -203,9 +218,13 @@ createDrawable(const Visual *visual, int width, int height)
 }
 
 Context *
-createContext(const Visual *visual, Context *shareContext)
+createContext(const Visual *visual, Context *shareContext, Profile profile)
 {
-    return new WglContext(visual, dynamic_cast<WglContext *>(shareContext));
+    if (profile != PROFILE_COMPAT) {
+        return NULL;
+    }
+
+    return new WglContext(visual, profile, static_cast<WglContext *>(shareContext));
 }
 
 bool
@@ -214,8 +233,8 @@ makeCurrent(Drawable *drawable, Context *context)
     if (!drawable || !context) {
         return wglMakeCurrent(NULL, NULL);
     } else {
-        WglDrawable *wglDrawable = dynamic_cast<WglDrawable *>(drawable);
-        WglContext *wglContext = dynamic_cast<WglContext *>(context);
+        WglDrawable *wglDrawable = static_cast<WglDrawable *>(drawable);
+        WglContext *wglContext = static_cast<WglContext *>(context);
 
         if (!wglContext->hglrc) {
             wglContext->hglrc = wglCreateContext(wglDrawable->hDC);