aboutsummaryrefslogtreecommitdiff
path: root/generic/tkZinc.c
diff options
context:
space:
mode:
authorlecoanet2004-09-21 08:40:25 +0000
committerlecoanet2004-09-21 08:40:25 +0000
commit9fb38f56959cd8a6d64c8e9ff0d034b1aefb5215 (patch)
tree8e0959613f662b65171d07085f7743dba2b631cc /generic/tkZinc.c
parent6a495d868f7fa7a0989f2fe7c30ce468496b2f10 (diff)
downloadtkzinc-9fb38f56959cd8a6d64c8e9ff0d034b1aefb5215.zip
tkzinc-9fb38f56959cd8a6d64c8e9ff0d034b1aefb5215.tar.gz
tkzinc-9fb38f56959cd8a6d64c8e9ff0d034b1aefb5215.tar.bz2
tkzinc-9fb38f56959cd8a6d64c8e9ff0d034b1aefb5215.tar.xz
One more attempt towards a truly working GL initialization
code.
Diffstat (limited to 'generic/tkZinc.c')
-rw-r--r--generic/tkZinc.c133
1 files changed, 67 insertions, 66 deletions
diff --git a/generic/tkZinc.c b/generic/tkZinc.c
index 6465a31..21221d0 100644
--- a/generic/tkZinc.c
+++ b/generic/tkZinc.c
@@ -992,72 +992,7 @@ InitRendering1(ZnWInfo *wi)
ZnGLContext gl_context;
if (wi->render) {
-# ifdef _WIN32
- /*
- * Look for a matching context already available.
- */
- ce = ZnGetGLContext(wi->dpy);
- if (ce) {
- gl_context = ce->context;
- ce->hwnd = Tk_GetHWND(Tk_WindowId(wi->win));
- ce->hdc = GetDC(ce->hwnd);
- ZnListAdd(ce->widgets, &wi, ZnListTail);
- SetPixelFormat(ce->hdc, ce->ipixel, &ce->pfd);
- }
- else {
- ce = ZnMalloc(sizeof(ZnGLContextEntry));
- ce->hwnd = Tk_GetHWND(Tk_WindowId(wi->win));
- ce->hdc = GetDC(ce->hwnd);
- ce->widgets = ZnListNew(1, sizeof(ZnWInfo *));
- ZnListAdd(ce->widgets, &wi, ZnListTail);
-
- memset(&ce->pfd, 0, sizeof(PIXELFORMATDESCRIPTOR));
- ce->pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
- ce->pfd.nVersion = 1;
- ce->pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
- ce->pfd.iPixelType = PFD_TYPE_RGBA;
- ce->pfd.cRedBits = 8;
- ce->pfd.cGreenBits = 8;
- ce->pfd.cBlueBits = 8;
- ce->pfd.cAlphaBits = 8;
- ce->pfd.cStencilBits = 8;
- ce->pfd.iLayerType = PFD_MAIN_PLANE;
- ce->ipixel = ChoosePixelFormat(ce->hdc, &ce->pfd);
- /*printf("ipixel=%d dwFlags=0x%x req=0x%x iPixelType=%d hdc=%d\n",
- ce->ipixel, ce->pfd.dwFlags,
- PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_DOUBLEBUFFER,
- ce->pfd.iPixelType==PFD_TYPE_RGBA,
- ce->hdc);*/
- if (!ce->ipixel ||
- (ce->pfd.cRedBits != 8) || (ce->pfd.cGreenBits != 8) || (ce->pfd.cBlueBits != 8) ||
- (ce->pfd.cStencilBits != 8)) {
- fprintf(stderr, "ChoosePixelFormat failed\n");
- }
-
- if (SetPixelFormat(ce->hdc, ce->ipixel, &ce->pfd) == TRUE) {
- gl_context = wglCreateContext(ce->hdc);
- if (gl_context) {
- ce->context = gl_context;
- ce->dpy = wi->dpy;
- ce->max_tex_size = 64; /* Minimum value is always valid */
- ce->max_line_width = 1;
- ce->max_point_width = 1;
- ce->next = gl_contexts;
- gl_contexts = ce;
- }
- else {
- fprintf(stderr, "wglCreateContext failed\n");
- ZnFree(ce);
- }
- }
- else {
- ZnFree(ce);
- }
- }
- ReleaseDC(ce->hwnd, ce->hdc);
-
-# else /* _WIN32 */
-
+# ifndef _WIN32
XVisualInfo *gl_visual = NULL;
Colormap colormap = 0;
@@ -1144,10 +1079,76 @@ static void
InitRendering2(ZnWInfo *wi)
{
ZnGLContextEntry *ce;
+ ZnGLContext gl_context;
GLfloat r[2]; /* Min, Max */
GLint i[1];
if (wi->render) {
+# ifdef _WIN32
+ /*
+ * Look for a matching context already available.
+ */
+ ce = ZnGetGLContext(wi->dpy);
+ if (ce) {
+ gl_context = ce->context;
+ ce->hwnd = Tk_GetHWND(Tk_WindowId(wi->win));
+ ce->hdc = GetDC(ce->hwnd);
+ ZnListAdd(ce->widgets, &wi, ZnListTail);
+ SetPixelFormat(ce->hdc, ce->ipixel, &ce->pfd);
+ }
+ else {
+ ce = ZnMalloc(sizeof(ZnGLContextEntry));
+ ce->hwnd = Tk_GetHWND(Tk_WindowId(wi->win));
+ ce->hdc = GetDC(ce->hwnd);
+ ce->widgets = ZnListNew(1, sizeof(ZnWInfo *));
+ ZnListAdd(ce->widgets, &wi, ZnListTail);
+
+ memset(&ce->pfd, 0, sizeof(PIXELFORMATDESCRIPTOR));
+ ce->pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
+ ce->pfd.nVersion = 1;
+ ce->pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
+ ce->pfd.iPixelType = PFD_TYPE_RGBA;
+ ce->pfd.cRedBits = 8;
+ ce->pfd.cGreenBits = 8;
+ ce->pfd.cBlueBits = 8;
+ ce->pfd.cAlphaBits = 8;
+ ce->pfd.cStencilBits = 8;
+ ce->pfd.iLayerType = PFD_MAIN_PLANE;
+ ce->ipixel = ChoosePixelFormat(ce->hdc, &ce->pfd);
+ /*printf("ipixel=%d dwFlags=0x%x req=0x%x iPixelType=%d hdc=%d\n",
+ ce->ipixel, ce->pfd.dwFlags,
+ PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_DOUBLEBUFFER,
+ ce->pfd.iPixelType==PFD_TYPE_RGBA,
+ ce->hdc);*/
+ if (!ce->ipixel ||
+ (ce->pfd.cRedBits != 8) || (ce->pfd.cGreenBits != 8) || (ce->pfd.cBlueBits != 8) ||
+ (ce->pfd.cStencilBits != 8)) {
+ fprintf(stderr, "ChoosePixelFormat failed\n");
+ }
+
+ if (SetPixelFormat(ce->hdc, ce->ipixel, &ce->pfd) == TRUE) {
+ gl_context = wglCreateContext(ce->hdc);
+ if (gl_context) {
+ ce->context = gl_context;
+ ce->dpy = wi->dpy;
+ ce->max_tex_size = 64; /* Minimum value is always valid */
+ ce->max_line_width = 1;
+ ce->max_point_width = 1;
+ ce->next = gl_contexts;
+ gl_contexts = ce;
+ }
+ else {
+ fprintf(stderr, "wglCreateContext failed\n");
+ ZnFree(ce);
+ }
+ }
+ else {
+ ZnFree(ce);
+ }
+ }
+ ReleaseDC(ce->hwnd, ce->hdc);
+#endif
+
ce = ZnGLMakeCurrent(wi->dpy, wi);
glGetFloatv(ZN_GL_LINE_WIDTH_RANGE, r);
ce->max_line_width = r[1];