1 #include "evas_engine.h"
7 static Evas_GL_Glew_Window *_evas_gl_glew_window = NULL;
10 eng_window_new(HWND window,
15 PIXELFORMATDESCRIPTOR pfd;
16 Evas_GL_Glew_Window *gw;
19 gw = calloc(1, sizeof(Evas_GL_Glew_Window));
25 gw->dc = GetDC(window);
29 ZeroMemory(&pfd, sizeof (pfd));
30 pfd.nSize = sizeof (pfd);
32 pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
33 pfd.iPixelType = PFD_TYPE_RGBA;
36 pfd.iLayerType = PFD_MAIN_PLANE;
38 format = ChoosePixelFormat(gw->dc, &pfd);
42 SetPixelFormat(gw->dc, format, &pfd);
44 if (pfd.iPixelType != PFD_TYPE_RGBA)
47 gw->context = wglCreateContext(gw->dc);
51 wglMakeCurrent(gw->dc, gw->context);
53 if (glewInit() != GLEW_OK)
56 if (!GLEW_VERSION_2_0)
58 fprintf(stderr, "\nERROR: OpenGL 2.0 not supported. Exiting...\n\n");
62 _evas_gl_glew_window = gw;
64 gw->gl_context = evas_gl_common_context_new();
67 evas_gl_common_context_resize(gw->gl_context, width, height);
72 wglMakeCurrent(NULL, NULL);
73 wglDeleteContext(gw->context);
75 ReleaseDC(window, gw->dc);
83 eng_window_free(Evas_GL_Glew_Window *gw)
87 if (gw == _evas_gl_glew_window) _evas_gl_glew_window = NULL;
88 evas_gl_common_context_free(gw->gl_context);
89 wglMakeCurrent(NULL, NULL);
90 wglDeleteContext(gw->context);
91 ReleaseDC(gw->window, gw->dc);
96 eng_window_use(Evas_GL_Glew_Window *gw)
98 if (_evas_gl_glew_window != gw)
100 if (_evas_gl_glew_window)
101 evas_gl_common_context_flush(_evas_gl_glew_window->gl_context);
102 _evas_gl_glew_window = gw;
103 wglMakeCurrent(gw->dc, gw->context);
105 evas_gl_common_context_use(gw->gl_context);
109 eng_window_swap_buffers(Evas_GL_Glew_Window *gw)
115 eng_window_vsync_set(int on)
117 #if 1 /* Using Glew */
118 wglSwapIntervalEXT(on);
119 #else /* Using plain OpenGL */
120 const char *extensions = glGetString(GL_EXTENSIONS);
122 /* check if WGL_EXT_swap_control extension is supported */
123 if (strstr(extensions, "WGL_EXT_swap_control") == 0)
127 wglSwapIntervalEXT = (PFNWGLSWAPINTERVALFARPROC)wglGetProcAddress("wglSwapIntervalEXT");
129 if (wglSwapIntervalEXT)
130 wglSwapIntervalEXT(on);