99 assert(context->
win != NULL);
101 if ((context->
hdc = GetDC(context->
win)) == NULL)
103 fprintf(stderr,
"Failed to Get the Window Device Context\n");
108 fprintf(stderr,
"Unable to set pixel format.\n");
112 if ((context->
hglrc = wglCreateContext(context->
hdc)) == NULL)
114 fprintf(stderr,
"Failed to Create the OpenGL Rendering Context.\n");
115 goto release_context;
119 fprintf(stderr,
"Unable to make context current.\n");
121 goto release_context;
124 int err = glewInit();
126 fprintf(stderr,
"Error intializing GLEW.\n");
127 goto release_context;
132 if(glewIsSupported(
"GL_ARB_create_context_profile") != GLEW_OK) {
133 fprintf(stderr,
"OpenGL implementation is not capable "
134 "of selecting profile.\n");
135 goto release_context;
138 wglMakeCurrent(context->
hdc, NULL);
139 wglDeleteContext(context->
hglrc);
141 const int attrib_list[] = {
147 if ((context->
hglrc = wglCreateContextAttribsARB(context->
hdc, NULL, attrib_list)) == NULL)
149 fprintf(stderr,
"Failed to Create the OpenGL Rendering Context %d,%d.\n",
152 goto release_context;
160 wglMakeCurrent(context->
hdc, NULL);
162 pthread_mutex_lock(&context->
lock);
164 pthread_cond_signal(&context->
status_cv);
165 pthread_mutex_unlock(&context->
lock);
167 pthread_mutex_lock(&context->
lock);
169 pthread_cond_wait(&context->
loop_cv, &context->
lock);
170 pthread_mutex_unlock(&context->
lock);
172 wglMakeCurrent(context->
hdc, NULL);
173 wglDeleteContext(context->
hglrc);
180 wglMakeCurrent(context->
hdc, NULL);
181 wglDeleteContext(context->
hglrc);
185 pthread_mutex_lock(&context->
lock);
187 pthread_cond_signal(&context->
status_cv);
188 pthread_mutex_unlock(&context->
lock);
203 int indexPixelFormat = 0;
205 PIXELFORMATDESCRIPTOR pfd =
207 sizeof(PIXELFORMATDESCRIPTOR),
209 PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_DOUBLEBUFFER,
212 0,0,0,0,0,0,0,0,0,0,0,0,0,
218 indexPixelFormat = ChoosePixelFormat(
hdc, &pfd);
221 return SetPixelFormat(
hdc, indexPixelFormat, &pfd);
228 ex.cbSize =
sizeof(WNDCLASSEX);
229 ex.style = CS_HREDRAW|CS_VREDRAW|CS_OWNDC;
230 ex.lpfnWndProc = DefWindowProc;
234 ex.hIcon = LoadIcon(NULL, IDI_APPLICATION);
235 ex.hCursor = LoadCursor(NULL, IDC_ARROW);
236 ex.hbrBackground = NULL;
237 ex.lpszMenuName = NULL;
241 ATOM res = RegisterClassEx(&ex);
win32_opengl_version_t version