|
From: Brenda L. <asp...@us...> - 2003-05-12 07:39:38
|
Update of /cvsroot/squeak/squeak/platforms/unix/plugins/B3DAcceleratorPlugin
In directory sc8-pr-cvs1:/tmp/cvs-serv6251/plugins/B3DAcceleratorPlugin
Modified Files:
sqUnixOpenGL.c
Log Message:
Ian Piumarta's release 3.4.1
Index: sqUnixOpenGL.c
===================================================================
RCS file: /cvsroot/squeak/squeak/platforms/unix/plugins/B3DAcceleratorPlugin/sqUnixOpenGL.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** sqUnixOpenGL.c 28 May 2002 20:16:54 -0000 1.1
--- sqUnixOpenGL.c 12 May 2003 07:39:02 -0000 1.2
***************
*** 5,9 ****
* Based on Andreas Raab's sqWin32OpenGL.c
*
! * Last edited: 19 May 2001 bert@faust
*/
--- 5,14 ----
* Based on Andreas Raab's sqWin32OpenGL.c
*
! * Last edited: Mon 11 Nov 2002 15:43:31 by bert on balloon
! *
! * History
! * Nov 02: added TGraphicsTest conformant log support
! * Oct 02: added Tea initialization support w/ stencil
! * May 01: initial revision
*/
***************
*** 26,29 ****
--- 31,37 ----
extern struct VirtualMachine *interpreterProxy;
+ static void printVisual(XVisualInfo* visinfo);
+ static void listVisuals();
+
static Display *stDisplay= NULL; /* Squeak's display */
static Window stWindow= 0; /* Squeak's main window */
***************
*** 34,46 ****
static int visualAttributes[]= {
GLX_RGBA, /* no indexed colors */
GLX_DOUBLEBUFFER, /* will swap */
GLX_LEVEL, 0, /* frame buffer, not overlay */
- GLX_RED_SIZE, 1, /* need rgb & alpha */
- GLX_GREEN_SIZE, 1,
- GLX_BLUE_SIZE, 1,
- GLX_ALPHA_SIZE, 1,
GLX_DEPTH_SIZE, 16, /* decent depth */
- GLX_STENCIL_SIZE, 0, /* need no stencil */
GLX_AUX_BUFFERS, 0, /* no aux buffers */
GLX_ACCUM_RED_SIZE, 0, /* no accumulation */
--- 42,51 ----
static int visualAttributes[]= {
+ GLX_STENCIL_SIZE, 0, /* filled in later - must be first item! */
+ GLX_ALPHA_SIZE, 1, /* filled in later - must be second item! */
GLX_RGBA, /* no indexed colors */
GLX_DOUBLEBUFFER, /* will swap */
GLX_LEVEL, 0, /* frame buffer, not overlay */
GLX_DEPTH_SIZE, 16, /* decent depth */
GLX_AUX_BUFFERS, 0, /* no aux buffers */
GLX_ACCUM_RED_SIZE, 0, /* no accumulation */
***************
*** 68,72 ****
/*** create / destroy a renderer ***/
! int glCreateRenderer(int allowSoftware, int allowHardware, int x, int y, int w, int h)
{
glRenderer *renderer;
--- 73,77 ----
/*** create / destroy a renderer ***/
! int glCreateRendererFlags(int x, int y, int w, int h, int flags)
{
glRenderer *renderer;
***************
*** 74,77 ****
--- 79,93 ----
int index= -1;
+ if (flags & ~(B3D_HARDWARE_RENDERER | B3D_SOFTWARE_RENDERER | B3D_STENCIL_BUFFER))
+ {
+ DPRINTF(1, (fp, "ERROR: Unsupported renderer flags (%d)\r", flags));
+ return -1;
+ }
+
+ if (flags & B3D_STENCIL_BUFFER)
+ visualAttributes[1]= 1;
+ else
+ visualAttributes[1]= 0;
+
/* find unused renderer */
{
***************
*** 89,93 ****
if (index == -1)
{
! DPRINTF(1, (fp, "ERROR: Maximum number of renderers (%d) exceeded\n", MAX_RENDERER));
return 0;
}
--- 105,109 ----
if (index == -1)
{
! DPRINTF(1, (fp, "ERROR: Maximum number of renderers (%d) exceeded\r", MAX_RENDERER));
return 0;
}
***************
*** 99,103 ****
renderer->context= NULL;
! DPRINTF(3, (fp, "---- Creating new renderer ----\n\n"));
/* sanity checks */
--- 115,119 ----
renderer->context= NULL;
! DPRINTF(3, (fp, "---- Creating new renderer ----\r\r"));
/* sanity checks */
***************
*** 105,109 ****
if (w < 0 || h < 0)
{
! DPRINTF(1, (fp, "Negative extent (%i@%i)!\n", w, h));
goto FAILED;
}
--- 121,125 ----
if (w < 0 || h < 0)
{
! DPRINTF(1, (fp, "Negative extent (%i@%i)!\r", w, h));
goto FAILED;
}
***************
*** 111,126 ****
/* choose visual and create context */
{
visinfo= glXChooseVisual(stDisplay,
! DefaultScreen(stDisplay),
! visualAttributes);
if (!visinfo)
{
! DPRINTF(1, (fp, "No OpenGL visual found!\n"));
goto FAILED;
}
! DPRINTF(3, (fp, "\n#### Selected GLX visual #%ld (depth: %d) ####\n",
! visinfo->visualid, visinfo->depth));
renderer->context= glXCreateContext(stDisplay, visinfo, 0, GL_TRUE);
--- 127,157 ----
/* choose visual and create context */
+ if (verboseLevel >= 3)
+ listVisuals();
+
{
visinfo= glXChooseVisual(stDisplay,
! DefaultScreen(stDisplay),
! visualAttributes);
!
if (!visinfo)
{
! /* retry without alpha */
! visualAttributes[3]= 0;
! visinfo= glXChooseVisual(stDisplay,
! DefaultScreen(stDisplay),
! visualAttributes);
! }
!
! if (!visinfo)
! {
! DPRINTF(1, (fp, "No OpenGL visual found!\r"));
goto FAILED;
}
! DPRINTF(3, (fp, "\r#### Selected GLX visual ID 0x%lx ####\r",
! visinfo->visualid));
! if (verboseLevel >= 3)
! printVisual(visinfo);
renderer->context= glXCreateContext(stDisplay, visinfo, 0, GL_TRUE);
***************
*** 128,136 ****
if (!renderer->context)
{
! DPRINTF(1, (fp, "Creating GLX context failed!\n"));
goto FAILED;
}
! DPRINTF(3, (fp, "\n#### Created GLX context ####\n" ));
/* create window */
--- 159,167 ----
if (!renderer->context)
{
! DPRINTF(1, (fp, "Creating GLX context failed!\r"));
goto FAILED;
}
! DPRINTF(3, (fp, "\r#### Created GLX context ####\r" ));
/* create window */
***************
*** 153,157 ****
if (!renderer->window)
{
! DPRINTF(1, (fp, "Failed to create client window\n"));
goto FAILED;
}
--- 184,188 ----
if (!renderer->window)
{
! DPRINTF(1, (fp, "Failed to create client window\r"));
goto FAILED;
}
***************
*** 161,165 ****
}
! DPRINTF(3, (fp, "\n#### Created window ####\n" ));
XFree(visinfo);
--- 192,196 ----
}
! DPRINTF(3, (fp, "\r#### Created window ####\r" ));
XFree(visinfo);
***************
*** 170,174 ****
if (!glXMakeCurrent(stDisplay, renderer->window, renderer->context))
{
! DPRINTF(1, (fp, "Failed to make context current\n"));
goto FAILED;
}
--- 201,205 ----
if (!glXMakeCurrent(stDisplay, renderer->window, renderer->context))
{
! DPRINTF(1, (fp, "Failed to make context current\r"));
goto FAILED;
}
***************
*** 179,183 ****
renderer->bufferRect[3]= h;
! DPRINTF(3, (fp, "\n### Renderer created! ###\n"));
/* setup user context */
--- 210,214 ----
renderer->bufferRect[3]= h;
! DPRINTF(3, (fp, "\r### Renderer created! ###\r"));
/* setup user context */
***************
*** 199,203 ****
FAILED:
/* do necessary cleanup */
! DPRINTF(1, (fp, "OpenGL initialization failed\n"));
if (visinfo)
--- 230,234 ----
FAILED:
/* do necessary cleanup */
! DPRINTF(1, (fp, "OpenGL initialization failed\r"));
if (visinfo)
***************
*** 216,220 ****
glRenderer *renderer= glRendererFromHandle(handle);
! DPRINTF(3, (fp, "\n--- Destroying renderer ---\n"));
if (!renderer)
--- 247,251 ----
glRenderer *renderer= glRendererFromHandle(handle);
! DPRINTF(3, (fp, "\r--- Destroying renderer ---\r"));
if (!renderer)
***************
*** 241,245 ****
glRenderer *glRendererFromHandle(int handle)
{
! DPRINTF(7, (fp, "Looking for renderer id: %i\n", handle));
if (handle < 0 || handle >= MAX_RENDERER)
--- 272,276 ----
glRenderer *glRendererFromHandle(int handle)
{
! DPRINTF(7, (fp, "Looking for renderer id: %i\r", handle));
if (handle < 0 || handle >= MAX_RENDERER)
***************
*** 283,287 ****
if (!glXMakeCurrent(stDisplay, renderer->window, renderer->context))
{
! DPRINTF(1, (fp, "Failed to make context current\n"));
return 0;
}
--- 314,318 ----
if (!glXMakeCurrent(stDisplay, renderer->window, renderer->context))
{
! DPRINTF(1, (fp, "Failed to make context current\r"));
return 0;
}
***************
*** 327,331 ****
! int glGetIntProperty(int handle, int prop)
{
GLint v;
--- 358,362 ----
! int glGetIntPropertyOS(int handle, int prop)
{
GLint v;
***************
*** 358,362 ****
! int glSetIntProperty(int handle, int prop, int value)
{
glRenderer *renderer= glRendererFromHandle(handle);
--- 389,393 ----
! int glSetIntPropertyOS(int handle, int prop, int value)
{
glRenderer *renderer= glRendererFromHandle(handle);
***************
*** 395,398 ****
--- 426,477 ----
+ /* GLX_CONFIG_CAVEAT might not be supported */
+ /* but the test below is worded so it does not matter */
+ #ifndef GLX_CONFIG_CAVEAT
+ # define GLX_CONFIG_CAVEAT 0x20
+ # define GLX_SLOW_CONFIG 0x8001
+ #endif
+
+ static void printVisual(XVisualInfo* visinfo)
+ {
+ int isOpenGL;
+ glXGetConfig(stDisplay, visinfo, GLX_USE_GL, &isOpenGL);
+ if (isOpenGL)
+ {
+ int slow= 0;
+ int red, green, blue, alpha, stencil, depth;
+ glXGetConfig(stDisplay, visinfo, GLX_CONFIG_CAVEAT, &slow);
+ glXGetConfig(stDisplay, visinfo, GLX_RED_SIZE, &red);
+ glXGetConfig(stDisplay, visinfo, GLX_GREEN_SIZE, &green);
+ glXGetConfig(stDisplay, visinfo, GLX_BLUE_SIZE, &blue);
+ glXGetConfig(stDisplay, visinfo, GLX_ALPHA_SIZE, &alpha);
+ glXGetConfig(stDisplay, visinfo, GLX_STENCIL_SIZE, &stencil);
+ glXGetConfig(stDisplay, visinfo, GLX_DEPTH_SIZE, &depth);
+
+ if (slow != GLX_SLOW_CONFIG)
+ DPRINTF(3, (fp,"===> OpenGL visual\r"))
+ else
+ DPRINTF(3, (fp,"---> slow OpenGL visual\r"));
+
+ DPRINTF(3, (fp,"rgbaBits = %i+%i+%i+%i\r", red, green, blue, alpha));
+ DPRINTF(3, (fp,"stencilBits = %i\r", stencil));
+ DPRINTF(3, (fp,"depthBits = %i\r", depth));
+ }
+ }
+
+ static void listVisuals()
+ {
+ XVisualInfo* visinfo;
+ int nvisuals, i;
+
+ visinfo= XGetVisualInfo(stDisplay, VisualNoMask, NULL, &nvisuals);
+
+ for (i= 0; i < nvisuals; i++)
+ {
+ DPRINTF(3, (fp,"#### Checking pixel format (visual ID 0x%lx)\r", visinfo[i].visualid));
+ printVisual(&visinfo[i]);
+ }
+ XFree(visinfo);
+ }
***************
*** 404,423 ****
{
int i, p;
! p= interpreterProxy->ioLoadFunctionFrom("stDisplay", NULL);
! if (!p)
{
! DPRINTF(1,(fp,"ERROR: Failed to look up stDisplay\n"));
return 0;
}
- stDisplay= *(Display**) p;
! p= interpreterProxy->ioLoadFunctionFrom("stWindow", NULL);
! if (!p)
{
! DPRINTF(1,(fp,"ERROR: Failed to look up stWindow\n"));
return 0;
}
- stWindow= *(Window*) p;
for (i= 0; i < MAX_RENDERER; i++)
--- 483,503 ----
{
int i, p;
+ int fn;
! fn= interpreterProxy->ioLoadFunctionFrom("ioGetDisplay", NULL);
! stDisplay= (fn ? ((Display *(*)(void))fn)() : 0);
! if (!stDisplay)
{
! DPRINTF(1,(fp,"ERROR: Failed to look up stDisplay\r"));
return 0;
}
! fn= interpreterProxy->ioLoadFunctionFrom("ioGetWindow", NULL);
! stWindow= (fn ? ((Window (*)(void))fn)() : 0);
! if (!stWindow)
{
! DPRINTF(1,(fp,"ERROR: Failed to look up stWindow\r"));
return 0;
}
for (i= 0; i < MAX_RENDERER; i++)
|