[Vm-dev] [commit] r2409 - Merging support files from cogvm branch.

commits at squeakvm.org commits at squeakvm.org
Thu Jun 9 08:21:49 UTC 2011


Author: andreas
Date: 2011-06-09 01:21:49 -0700 (Thu, 09 Jun 2011)
New Revision: 2409

Modified:
   trunk/platforms/Cross/plugins/B3DAcceleratorPlugin/B3DAcceleratorPlugin.h
   trunk/platforms/Cross/plugins/B3DAcceleratorPlugin/sqOpenGLRenderer.c
   trunk/platforms/Cross/plugins/B3DAcceleratorPlugin/sqOpenGLRenderer.h
Log:
Merging support files from cogvm branch.

Modified: trunk/platforms/Cross/plugins/B3DAcceleratorPlugin/B3DAcceleratorPlugin.h
===================================================================
--- trunk/platforms/Cross/plugins/B3DAcceleratorPlugin/B3DAcceleratorPlugin.h	2011-06-09 08:16:10 UTC (rev 2408)
+++ trunk/platforms/Cross/plugins/B3DAcceleratorPlugin/B3DAcceleratorPlugin.h	2011-06-09 08:21:49 UTC (rev 2409)
@@ -1,4 +1,12 @@
 /* Header file for 3D accelerator plugin */
+#ifdef WIN32
+# include <windows.h>
+#endif
+#if defined(TARGET_API_MAC_CARBON)
+#include <OpenGL/gl.h>
+#else
+#include <GL/gl.h>
+#endif
 
 /* Vertex buffer flags */
 #define B3D_VB_TRACK_AMBIENT 1
@@ -61,14 +69,19 @@
    B3D_SOFTWARE_RENDERER: Enable use of software renderers
    B3D_HARDWARE_RENDERER: Enable use of hardware renderers
    B3D_STENCIL_BUFFER:    Request stencil buffer
+   B3D_ANTIALIASING:      Request antialiasing in the renderer.
+   B3D_STEREO:            Request stereo visual from the renderer
+   B3D_SYNCVBL:           Request VBL sync
    More flags may be added - if they are not supported by the platform
    code the creation primitive should fail.
 */
 #define B3D_SOFTWARE_RENDERER 0x0001
 #define B3D_HARDWARE_RENDERER 0x0002
 #define B3D_STENCIL_BUFFER    0x0004
+#define B3D_ANTIALIASING      0x0008
+#define B3D_STEREO            0x0010
+#define B3D_SYNCVBL           0x0020
 
-
 /* Win32 defaults to DUAL D3D/GL interface everyone else to OpenGL */
 #if defined(WIN32)
 # if defined(WIN32_PURE_D3D)
@@ -211,6 +224,11 @@
 int b3dxSetVerboseLevel(int level);
 int b3dxSetFog(int handle, int fogType, double density, double rangeStart, double rangeEnd, int rgba);
 
+/* Qwaq primitives */
+int b3dDrawArrays(int handle, int mode, int minIdx, int maxIdx);
+int b3dDrawElements(int handle, int mode, int nFaces, unsigned int *facePtr);
+int b3dDrawRangeElements(int handle, int mode, int minIdx, int maxIdx, int nFaces, unsigned int *facePtr);
+
 #if defined(B3DX_DUAL)
 extern int glMode;
 

Modified: trunk/platforms/Cross/plugins/B3DAcceleratorPlugin/sqOpenGLRenderer.c
===================================================================
--- trunk/platforms/Cross/plugins/B3DAcceleratorPlugin/sqOpenGLRenderer.c	2011-06-09 08:16:10 UTC (rev 2408)
+++ trunk/platforms/Cross/plugins/B3DAcceleratorPlugin/sqOpenGLRenderer.c	2011-06-09 08:21:49 UTC (rev 2409)
@@ -6,7 +6,7 @@
 *   AUTHOR:  Andreas Raab (ar)
 *   ADDRESS: Walt Disney Imagineering, Glendale, CA
 *   EMAIL:   Andreas.Raab at disney.com
-*   RCSID:   $Id: sqOpenGLRenderer.c,v 1.10 2004/08/31 21:13:51 bertf Exp $
+*   RCSID:   $Id$
 *
 *   NOTES: 
 *
@@ -87,19 +87,19 @@
 	struct glRenderer *renderer = glRendererFromHandle(handle);
 
 	if(!renderer || !glMakeCurrentRenderer(renderer)) {
-		DPRINTF(4, (fp, "ERROR: Invalid renderer specified\n"));
+		DPRINTF3D(4, (fp, "ERROR: Invalid renderer specified\n"));
 		return 0;
 	}
 
 	if(w & (w-1)) return -1; /* not power of two */
 	if(h & (h-1)) return -1; /* not power of two */
 
-	DPRINTF(5, (fp, "### Allocating new texture (w = %d, h = %d, d = %d)\n", w, h, d));
+	DPRINTF3D(5, (fp, "### Allocating new texture (w = %d, h = %d, d = %d)\n", w, h, d));
 
 	errMsg = "glGenTextures() failed";
 	glGenTextures(1, &texture);
 	if((glErr = glGetError()) != GL_NO_ERROR) goto FAILED;
-	DPRINTF(5, (fp, "Allocated texture id = %d\n", texture));
+	DPRINTF3D(5, (fp, "Allocated texture id = %d\n", texture));
 	errMsg = "glBindTexture() failed";
 	glBindTexture(GL_TEXTURE_2D, texture);
 	if((glErr = glGetError()) != GL_NO_ERROR) goto FAILED;
@@ -125,10 +125,10 @@
 				 GL_UNSIGNED_BYTE, /* type */
 				 NULL /* image data - if NULL contents is unspecified */);
 	if((glErr = glGetError()) != GL_NO_ERROR) goto FAILED;
-	DPRINTF(5, (fp,"\tid = %d\n", texture));
+	DPRINTF3D(5, (fp,"\tid = %d\n", texture));
 	return texture;
 FAILED:
-	DPRINTF(1, (fp, "ERROR (glAllocateTexture): %s -- %s\n", errMsg, glErrString()));
+	DPRINTF3D(1, (fp, "ERROR (glAllocateTexture): %s -- %s\n", errMsg, glErrString()));
 	glDeleteTextures(1, &texture);
 	return -1;
 }
@@ -138,14 +138,14 @@
 	struct glRenderer *renderer = glRendererFromHandle(rendererHandle);
 
 	if(!renderer || !glMakeCurrentRenderer(renderer)) {
-		DPRINTF(4, (fp, "ERROR: Invalid renderer specified\n"));
+		DPRINTF3D(4, (fp, "ERROR: Invalid renderer specified\n"));
 		return 0;
 	}
 
 	if(!glIsTexture(handle)) {
 		return 0;
 	}
-	DPRINTF(5, (fp, "### Destroying texture (id = %d)\n", handle));
+	DPRINTF3D(5, (fp, "### Destroying texture (id = %d)\n", handle));
 	glDeleteTextures(1, (GLuint*) &handle);
 	ERROR_CHECK;
 	return 1;
@@ -199,7 +199,7 @@
 	struct glRenderer *renderer = glRendererFromHandle(rendererHandle);
 
 	if(!renderer || !glMakeCurrentRenderer(renderer)) {
-		DPRINTF(4, (fp, "ERROR: Invalid renderer specified\n"));
+		DPRINTF3D(4, (fp, "ERROR: Invalid renderer specified\n"));
 		return 0;
 	}
 
@@ -208,7 +208,7 @@
 	if(!glIsTexture(handle)) {
 		return 0;
 	}
-	DPRINTF(5, (fp, "### Uploading texture (w = %d, h = %d, d = %d, id = %d)\n", w, h, d, handle));
+	DPRINTF3D(5, (fp, "### Uploading texture (w = %d, h = %d, d = %d, id = %d)\n", w, h, d, handle));
 	glBindTexture(GL_TEXTURE_2D, handle);
 	ERROR_CHECK;
 	for(y = 0; y < h; y++) {
@@ -231,14 +231,14 @@
 	struct glRenderer *renderer = glRendererFromHandle(rendererHandle);
 
 	if(!renderer || !glMakeCurrentRenderer(renderer)) {
-		DPRINTF(4, (fp, "ERROR: Invalid renderer specified\n"));
+		DPRINTF3D(4, (fp, "ERROR: Invalid renderer specified\n"));
 		return 0;
 	}
 	if(!glIsTexture(handle)) {
 		return 0;
 	}
 	ERROR_CHECK;
-	DPRINTF(7, (fp, "glCompositeTexture(%d, %d, %d, %d)\n", x, y, w, h));
+	DPRINTF3D(7, (fp, "glCompositeTexture(%d, %d, %d, %d)\n", x, y, w, h));
 	{
 		/* setup a transformation so that we're dealing with pixel x/y coordinate systems */
 		glPushMatrix();
@@ -289,7 +289,7 @@
 		ERROR_CHECK;
 		x -= renderer->bufferRect[0];
 		y -= renderer->bufferRect[1];
-		DPRINTF(7, (fp, "glRecti(%d, %d, %d, %d)\n", x, y, w, h));
+		DPRINTF3D(7, (fp, "glRecti(%d, %d, %d, %d)\n", x, y, w, h));
 		glBegin(GL_QUADS);
 			glTexCoord2d(0.0, 0.0);
 			glVertex2i(x, y);
@@ -326,15 +326,15 @@
 	struct glRenderer *renderer = glRendererFromHandle(handle);
 	if(!renderer || !glMakeCurrentRenderer(renderer)) return 0;
 
-	DPRINTF(5, (fp, "### New Viewport\n"));
-	DPRINTF(5, (fp, "\tx: %d\n\ty: %d\n\tw: %d\n\th: %d\n", x, y, w, h));
+	DPRINTF3D(5, (fp, "### New Viewport\n"));
+	DPRINTF3D(5, (fp, "\tx: %d\n\ty: %d\n\tw: %d\n\th: %d\n", x, y, w, h));
 	renderer->viewport[0] = x;
 	renderer->viewport[1] = y;
 	renderer->viewport[2] = w;
 	renderer->viewport[3] = h;
 	x -= renderer->bufferRect[0];
 	y -= renderer->bufferRect[1];
-	DPRINTF(5, (fp, "\tx: %d\n\ty: %d\n\tw: %d\n\th: %d\n", x, y, w, h));
+	DPRINTF3D(5, (fp, "\tx: %d\n\ty: %d\n\tw: %d\n\th: %d\n", x, y, w, h));
 	glViewport(x, renderer->bufferRect[3] - (y+h), w, h);
 	ERROR_CHECK;
 
@@ -345,7 +345,7 @@
 {
 	struct glRenderer *renderer = glRendererFromHandle(handle);
 	if(!renderer || !glMakeCurrentRenderer(renderer)) return 0;
-	DPRINTF(5, (fp, "### Clearing depth buffer\n"));
+	DPRINTF3D(5, (fp, "### Clearing depth buffer\n"));
 	glClear(GL_DEPTH_BUFFER_BIT);
 	ERROR_CHECK;
 	return 1;
@@ -355,7 +355,7 @@
 {
 	struct glRenderer *renderer = glRendererFromHandle(handle);
 	if(!renderer || !glMakeCurrentRenderer(renderer)) return 0;
-	DPRINTF(5, (fp, "### Clearing viewport buffer\n"));
+	DPRINTF3D(5, (fp, "### Clearing viewport buffer\n"));
 	glClearColor(
 				((rgba >> 16) & 255) / 255.0, 
 				((rgba >>  8) & 255) / 255.0, 
@@ -370,7 +370,7 @@
 {
 	struct glRenderer *renderer = glRendererFromHandle(handle);
 	if(!renderer || !glMakeCurrentRenderer(renderer)) return 0;
-	DPRINTF(5, (fp, "### Finishing renderer\n"));
+	DPRINTF3D(5, (fp, "### Finishing renderer\n"));
 	glFinish();
 	ERROR_CHECK;
 	return 1;
@@ -380,7 +380,7 @@
 {
 	struct glRenderer *renderer = glRendererFromHandle(handle);
 	if(!renderer || !glMakeCurrentRenderer(renderer)) return 0;
-	DPRINTF(5, (fp, "### Flushing renderer\n"));
+	DPRINTF3D(5, (fp, "### Flushing renderer\n"));
 	glFlush();
 	ERROR_CHECK;
 	return 1;
@@ -390,7 +390,7 @@
 {
 	struct glRenderer *renderer = glRendererFromHandle(handle);
 	if(!renderer || !glMakeCurrentRenderer(renderer)) return 0;
-	DPRINTF(5, (fp, "### Swapping renderer buffers\n"));
+	DPRINTF3D(5, (fp, "### Swapping renderer buffers\n"));
 	glSwapBuffers(renderer);
 	ERROR_CHECK;
 	return 1;
@@ -404,7 +404,7 @@
 	struct glRenderer *renderer = glRendererFromHandle(handle);
 	if(!renderer || !glMakeCurrentRenderer(renderer)) return 0;
 
-	DPRINTF(5, (fp, "### Installing new transformations\n"));
+	DPRINTF3D(5, (fp, "### Installing new transformations\n"));
 	glMatrixMode(GL_PROJECTION);
 	ERROR_CHECK;
 	glLoadIdentity();
@@ -438,18 +438,18 @@
 	struct glRenderer *renderer = glRendererFromHandle(handle);
 
 	if(!renderer || !glMakeCurrentRenderer(renderer)) {
-		DPRINTF(4, (fp, "ERROR: Invalid renderer specified\n"));
+		DPRINTF3D(4, (fp, "ERROR: Invalid renderer specified\n"));
 		return 0;
 	}
 
-	DPRINTF(5, (fp, "### Disabling all lights\n"));
+	DPRINTF3D(5, (fp, "### Disabling all lights\n"));
 	glGetIntegerv(GL_MAX_LIGHTS, &max);
 	ERROR_CHECK;
 	for(i = 0; i < max; i++) {
 		glDisable(GL_LIGHT0+i);
 		ERROR_CHECK;
 		if( (glErr = glGetError()) != GL_NO_ERROR) 
-			DPRINTF(1, (fp,"ERROR (glDisableLights): glDisable(GL_LIGHT%d) failed -- %s\n", i, glErrString()));
+			DPRINTF3D(1, (fp,"ERROR (glDisableLights): glDisable(GL_LIGHT%d) failed -- %s\n", i, glErrString()));
 	}
 	return 1;
 }
@@ -459,22 +459,22 @@
 	struct glRenderer *renderer = glRendererFromHandle(handle);
 
 	if(!renderer || !glMakeCurrentRenderer(renderer)) {
-		DPRINTF(4, (fp, "ERROR: Invalid renderer specified\n"));
+		DPRINTF3D(4, (fp, "ERROR: Invalid renderer specified\n"));
 		return 0;
 	}
 
-	DPRINTF(5, (fp, "### New Material\n"));
+	DPRINTF3D(5, (fp, "### New Material\n"));
 	if(!mat) {
-		DPRINTF(5, (fp, "\tOFF (material == nil)\n"));
+		DPRINTF3D(5, (fp, "\tOFF (material == nil)\n"));
 		glDisable(GL_LIGHTING);
 		ERROR_CHECK;
 		return 1;
 	}
-	DPRINTF(5, (fp, "\tambient  : %g, %g, %g, %g\n",mat->ambient[0], mat->ambient[1], mat->ambient[2], mat->ambient[3]));
-	DPRINTF(5, (fp, "\tdiffuse  : %g, %g, %g, %g\n",mat->diffuse[0], mat->diffuse[1], mat->diffuse[2], mat->diffuse[3]));
-	DPRINTF(5, (fp, "\tspecular : %g, %g, %g, %g\n",mat->specular[0], mat->specular[1], mat->specular[2], mat->specular[3]));
-	DPRINTF(5, (fp, "\temission : %g, %g, %g, %g\n",mat->emission[0], mat->emission[1], mat->emission[2], mat->emission[3]));
-	DPRINTF(5, (fp, "\tshininess: %g\n", mat->shininess));
+	DPRINTF3D(5, (fp, "\tambient  : %g, %g, %g, %g\n",mat->ambient[0], mat->ambient[1], mat->ambient[2], mat->ambient[3]));
+	DPRINTF3D(5, (fp, "\tdiffuse  : %g, %g, %g, %g\n",mat->diffuse[0], mat->diffuse[1], mat->diffuse[2], mat->diffuse[3]));
+	DPRINTF3D(5, (fp, "\tspecular : %g, %g, %g, %g\n",mat->specular[0], mat->specular[1], mat->specular[2], mat->specular[3]));
+	DPRINTF3D(5, (fp, "\temission : %g, %g, %g, %g\n",mat->emission[0], mat->emission[1], mat->emission[2], mat->emission[3]));
+	DPRINTF3D(5, (fp, "\tshininess: %g\n", mat->shininess));
 	glEnable(GL_LIGHTING);
 	ERROR_CHECK;
 	glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mat->ambient);
@@ -497,67 +497,67 @@
 	struct glRenderer *renderer = glRendererFromHandle(handle);
 
 	if(!renderer || !glMakeCurrentRenderer(renderer)) {
-		DPRINTF(4, (fp, "ERROR: Invalid renderer specified\n"));
+		DPRINTF3D(4, (fp, "ERROR: Invalid renderer specified\n"));
 		return 0;
 	}
 
-	DPRINTF(5, (fp, "### New Light (%d)\n", idx));
+	DPRINTF3D(5, (fp, "### New Light (%d)\n", idx));
 
 	if(!light) {
-		DPRINTF(5, (fp, "\tDISABLED\n"));
+		DPRINTF3D(5, (fp, "\tDISABLED\n"));
 		glDisable(index);
 		ERROR_CHECK;
 		return 1;
 	}
 	glEnable(index);
 	ERROR_CHECK;
-	DPRINTF(5, (fp, "\tambient       : %g, %g, %g, %g\n",light->ambient[0], light->ambient[1], light->ambient[2], light->ambient[3]));
-	DPRINTF(5, (fp, "\tdiffuse       : %g, %g, %g, %g\n",light->diffuse[0], light->diffuse[1], light->diffuse[2], light->diffuse[3]));
-	DPRINTF(5, (fp, "\tspecular      : %g, %g, %g, %g\n",light->specular[0], light->specular[1], light->specular[2], light->specular[3]));
-	DPRINTF(5, (fp, "\tposition      : %g, %g, %g\n",light->position[0], light->position[1], light->position[2]));
-	DPRINTF(5, (fp, "\tdirection     : %g, %g, %g\n",light->direction[0], light->direction[1], light->direction[2]));
-	DPRINTF(5, (fp, "\tattenuation   : %g, %g, %g\n",light->attenuation[0], light->attenuation[1], light->attenuation[2]));
-	DPRINTF(5, (fp, "\tflags [%d]:", light->flags));
-	if(light->flags & B3D_LIGHT_AMBIENT) DPRINTF(5,(fp," B3D_LIGHT_AMBIENT"));
-	if(light->flags & B3D_LIGHT_DIFFUSE) DPRINTF(5,(fp," B3D_LIGHT_DIFFUSE"));
-	if(light->flags & B3D_LIGHT_SPECULAR) DPRINTF(5,(fp," B3D_LIGHT_SPECULAR"));
-	if(light->flags & B3D_LIGHT_POSITIONAL) DPRINTF(5,(fp," B3D_LIGHT_POSITIONAL"));
-	if(light->flags & B3D_LIGHT_DIRECTIONAL) DPRINTF(5,(fp," B3D_LIGHT_DIRECTIONAL"));
-	if(light->flags & B3D_LIGHT_ATTENUATED) DPRINTF(5,(fp," B3D_LIGHT_ATTENUATED"));
-	if(light->flags & B3D_LIGHT_HAS_SPOT) DPRINTF(5,(fp," B3D_LIGHT_HAS_SPOT"));
-	DPRINTF(5, (fp, "\n"));
-	DPRINTF(5, (fp, "\tspot exponent : %g\n", light->spotExponent));
+	DPRINTF3D(5, (fp, "\tambient       : %g, %g, %g, %g\n",light->ambient[0], light->ambient[1], light->ambient[2], light->ambient[3]));
+	DPRINTF3D(5, (fp, "\tdiffuse       : %g, %g, %g, %g\n",light->diffuse[0], light->diffuse[1], light->diffuse[2], light->diffuse[3]));
+	DPRINTF3D(5, (fp, "\tspecular      : %g, %g, %g, %g\n",light->specular[0], light->specular[1], light->specular[2], light->specular[3]));
+	DPRINTF3D(5, (fp, "\tposition      : %g, %g, %g\n",light->position[0], light->position[1], light->position[2]));
+	DPRINTF3D(5, (fp, "\tdirection     : %g, %g, %g\n",light->direction[0], light->direction[1], light->direction[2]));
+	DPRINTF3D(5, (fp, "\tattenuation   : %g, %g, %g\n",light->attenuation[0], light->attenuation[1], light->attenuation[2]));
+	DPRINTF3D(5, (fp, "\tflags [%d]:", light->flags));
+	if(light->flags & B3D_LIGHT_AMBIENT) DPRINTF3D(5,(fp," B3D_LIGHT_AMBIENT"));
+	if(light->flags & B3D_LIGHT_DIFFUSE) DPRINTF3D(5,(fp," B3D_LIGHT_DIFFUSE"));
+	if(light->flags & B3D_LIGHT_SPECULAR) DPRINTF3D(5,(fp," B3D_LIGHT_SPECULAR"));
+	if(light->flags & B3D_LIGHT_POSITIONAL) DPRINTF3D(5,(fp," B3D_LIGHT_POSITIONAL"));
+	if(light->flags & B3D_LIGHT_DIRECTIONAL) DPRINTF3D(5,(fp," B3D_LIGHT_DIRECTIONAL"));
+	if(light->flags & B3D_LIGHT_ATTENUATED) DPRINTF3D(5,(fp," B3D_LIGHT_ATTENUATED"));
+	if(light->flags & B3D_LIGHT_HAS_SPOT) DPRINTF3D(5,(fp," B3D_LIGHT_HAS_SPOT"));
+	DPRINTF3D(5, (fp, "\n"));
+	DPRINTF3D(5, (fp, "\tspot exponent : %g\n", light->spotExponent));
 
-	DPRINTF(5, (fp, "### Installing Light (%d)\n", idx));
+	DPRINTF3D(5, (fp, "### Installing Light (%d)\n", idx));
 	if(light->flags & B3D_LIGHT_AMBIENT) {
-		DPRINTF(5, (fp, "\tambient  : %g, %g, %g, %g\n",light->ambient[0], light->ambient[1], light->ambient[2], light->ambient[3]));
+		DPRINTF3D(5, (fp, "\tambient  : %g, %g, %g, %g\n",light->ambient[0], light->ambient[1], light->ambient[2], light->ambient[3]));
 		glLightfv(index, GL_AMBIENT, light->ambient);
 	} else {
-		DPRINTF(5, (fp, "\tambient  : OFF (0, 0, 0, 1)\n"));
+		DPRINTF3D(5, (fp, "\tambient  : OFF (0, 0, 0, 1)\n"));
 		glLightfv(index, GL_AMBIENT, blackLight);
 	}
 	ERROR_CHECK;
 
 	if(light->flags & B3D_LIGHT_DIFFUSE) {
-		DPRINTF(5, (fp, "\tdiffuse  : %g, %g, %g, %g\n",light->diffuse[0], light->diffuse[1], light->diffuse[2], light->diffuse[3]));
+		DPRINTF3D(5, (fp, "\tdiffuse  : %g, %g, %g, %g\n",light->diffuse[0], light->diffuse[1], light->diffuse[2], light->diffuse[3]));
 		glLightfv(index, GL_DIFFUSE, light->diffuse);
 	} else {
-		DPRINTF(5, (fp, "\tdiffuse  : OFF (0, 0, 0, 1)\n"));
+		DPRINTF3D(5, (fp, "\tdiffuse  : OFF (0, 0, 0, 1)\n"));
 		glLightfv(index, GL_DIFFUSE, blackLight);
 	}
 	ERROR_CHECK;
 
 	if(light->flags & B3D_LIGHT_SPECULAR) {
-		DPRINTF(5, (fp, "\tspecular : %g, %g, %g, %g\n",light->specular[0], light->specular[1], light->specular[2], light->specular[3]));
+		DPRINTF3D(5, (fp, "\tspecular : %g, %g, %g, %g\n",light->specular[0], light->specular[1], light->specular[2], light->specular[3]));
 		glLightfv(index, GL_SPECULAR, light->specular);
 	} else {
-		DPRINTF(5, (fp, "\tspecular : OFF (0, 0, 0, 1)\n"));
+		DPRINTF3D(5, (fp, "\tspecular : OFF (0, 0, 0, 1)\n"));
 		glLightfv(index, GL_SPECULAR, blackLight);
 	}
 	ERROR_CHECK;
 
 	if(light->flags & B3D_LIGHT_POSITIONAL) {
-		DPRINTF(5, (fp, "\tposition : %g, %g, %g\n",light->position[0], light->position[1], light->position[2]));
+		DPRINTF3D(5, (fp, "\tposition : %g, %g, %g\n",light->position[0], light->position[1], light->position[2]));
 		pos[0] = light->position[0];
 		pos[1] = light->position[1];
 		pos[2] = light->position[2];
@@ -569,7 +569,7 @@
 		glPopMatrix();
 	} else {
 		if(light->flags & B3D_LIGHT_DIRECTIONAL) {
-			DPRINTF(5, (fp, "\tdirection: %g, %g, %g\n",light->direction[0], light->direction[1], light->direction[2]));
+			DPRINTF3D(5, (fp, "\tdirection: %g, %g, %g\n",light->direction[0], light->direction[1], light->direction[2]));
 			pos[0] = light->direction[0];
 			pos[1] = light->direction[1];
 			pos[2] = light->direction[2];
@@ -584,7 +584,7 @@
 	ERROR_CHECK;
 
 	if(light->flags & B3D_LIGHT_ATTENUATED) {
-		DPRINTF(5, (fp, "\tattenuation: %g, %g, %g\n",light->attenuation[0], light->attenuation[1], light->attenuation[2]));
+		DPRINTF3D(5, (fp, "\tattenuation: %g, %g, %g\n",light->attenuation[0], light->attenuation[1], light->attenuation[2]));
 		glLightf(index, GL_CONSTANT_ATTENUATION,  light->attenuation[0]);
 		ERROR_CHECK;
 		glLightf(index, GL_LINEAR_ATTENUATION,    light->attenuation[1]);
@@ -592,7 +592,7 @@
 		glLightf(index, GL_QUADRATIC_ATTENUATION, light->attenuation[2]);
 		ERROR_CHECK;
 	} else {
-		DPRINTF(5, (fp, "\tattenuation: OFF (1, 0, 0)\n"));
+		DPRINTF3D(5, (fp, "\tattenuation: OFF (1, 0, 0)\n"));
 		glLightf(index, GL_CONSTANT_ATTENUATION,  1.0);
 		ERROR_CHECK;
 		glLightf(index, GL_LINEAR_ATTENUATION,    0.0);
@@ -602,9 +602,9 @@
 	}
 
 	if(light->flags & B3D_LIGHT_HAS_SPOT) {
-		DPRINTF(5, (fp, "\tspot exponent : %g\n", light->spotExponent));
-		DPRINTF(5, (fp, "\tspot cutoff   : ???\n"));
-		DPRINTF(5, (fp, "\tspot direction: %g, %g, %g\n",light->direction[0], light->direction[1], light->direction[2]));
+		DPRINTF3D(5, (fp, "\tspot exponent : %g\n", light->spotExponent));
+		DPRINTF3D(5, (fp, "\tspot cutoff   : ???\n"));
+		DPRINTF3D(5, (fp, "\tspot direction: %g, %g, %g\n",light->direction[0], light->direction[1], light->direction[2]));
 		glLightf(index, GL_SPOT_EXPONENT, light->spotExponent);
 		ERROR_CHECK;
 		glLightf(index, GL_SPOT_CUTOFF, light->spotExponent);
@@ -780,21 +780,21 @@
 
 static void glRenderVertex(B3DPrimitiveVertex *vtx, int flags)
 {
-	DPRINTF(10, (fp, "["));
+	DPRINTF3D(10, (fp, "["));
 	if(flags & 1) {
 		unsigned int vv = vtx->pixelValue32;
-		DPRINTF(10, (fp, "C(%d, %d, %d, %d)",(vv >> 16) & 255, (vv >> 8) & 255, vv & 255, vv >> 24));
+		DPRINTF3D(10, (fp, "C(%d, %d, %d, %d)",(vv >> 16) & 255, (vv >> 8) & 255, vv & 255, vv >> 24));
 		glColor4ub( (vv >> 16) & 255, (vv >> 8) & 255, vv & 255, vv >> 24 );
 	}
 	if(flags & 2) {
-		DPRINTF(10, (fp, "N(%g, %g, %g)", vtx->normal[0], vtx->normal[1], vtx->normal[2]));
+		DPRINTF3D(10, (fp, "N(%g, %g, %g)", vtx->normal[0], vtx->normal[1], vtx->normal[2]));
 		glNormal3fv(vtx->normal);
 	}
 	if(flags & 4) {
-		DPRINTF(10, (fp, "T(%g, %g)", vtx->texCoord[0], vtx->texCoord[1]));
+		DPRINTF3D(10, (fp, "T(%g, %g)", vtx->texCoord[0], vtx->texCoord[1]));
 		glTexCoord2fv(vtx->texCoord);
 	}
-	DPRINTF(10, (fp, "V(%g, %g, %g)]\n", vtx->position[0], vtx->position[1], vtx->position[2]));
+	DPRINTF3D(10, (fp, "V(%g, %g, %g)]\n", vtx->position[0], vtx->position[1], vtx->position[2]));
 	glVertex3fv(vtx->position);
 }
 #endif
@@ -814,24 +814,24 @@
 	struct glRenderer *renderer = glRendererFromHandle(handle);
 
 	if(!renderer || !glMakeCurrentRenderer(renderer)) {
-		DPRINTF(4, (fp, "ERROR: Invalid renderer specified\n"));
+		DPRINTF3D(4, (fp, "ERROR: Invalid renderer specified\n"));
 		return 0;
 	}
 
-	DPRINTF(5, (fp,"### Primitive : %d\n", primType));
-	DPRINTF(5, (fp,"\ttexHandle   : %d\n", texHandle));
-	DPRINTF(5, (fp,"\tcolor flags :"));
-	if(flags & B3D_VB_TRACK_AMBIENT) DPRINTF(5,(fp," B3D_VB_TRACK_AMBIENT"));
-	if(flags & B3D_VB_TRACK_DIFFUSE) DPRINTF(5,(fp," B3D_VB_TRACK_DIFFUSE"));
-	if(flags & B3D_VB_TRACK_SPECULAR) DPRINTF(5,(fp," B3D_VB_TRACK_SPECULAR"));
-	if(flags & B3D_VB_TRACK_EMISSION) DPRINTF(5,(fp," B3D_VB_TRACK_EMISSION"));
-	DPRINTF(5, (fp,"\n\tlight flags :"));
-	if(flags & B3D_VB_LOCAL_VIEWER) DPRINTF(5,(fp," B3D_VB_LOCAL_VIEWER"));
-	if(flags & B3D_VB_TWO_SIDED) DPRINTF(5,(fp," B3D_VB_TWO_SIDED"));
-	DPRINTF(5, (fp,"\n\tvertex flags:"));
-	if(flags & B3D_VB_HAS_NORMALS) DPRINTF(5,(fp," B3D_VB_HAS_NORMALS"));
-	if(flags & B3D_VB_HAS_TEXTURES) DPRINTF(5,(fp," B3D_VB_HAS_TEXTURES"));
-	DPRINTF(5, (fp, "\n"));
+	DPRINTF3D(5, (fp,"### Primitive : %d\n", primType));
+	DPRINTF3D(5, (fp,"\ttexHandle   : %d\n", texHandle));
+	DPRINTF3D(5, (fp,"\tcolor flags :"));
+	if(flags & B3D_VB_TRACK_AMBIENT) DPRINTF3D(5,(fp," B3D_VB_TRACK_AMBIENT"));
+	if(flags & B3D_VB_TRACK_DIFFUSE) DPRINTF3D(5,(fp," B3D_VB_TRACK_DIFFUSE"));
+	if(flags & B3D_VB_TRACK_SPECULAR) DPRINTF3D(5,(fp," B3D_VB_TRACK_SPECULAR"));
+	if(flags & B3D_VB_TRACK_EMISSION) DPRINTF3D(5,(fp," B3D_VB_TRACK_EMISSION"));
+	DPRINTF3D(5, (fp,"\n\tlight flags :"));
+	if(flags & B3D_VB_LOCAL_VIEWER) DPRINTF3D(5,(fp," B3D_VB_LOCAL_VIEWER"));
+	if(flags & B3D_VB_TWO_SIDED) DPRINTF3D(5,(fp," B3D_VB_TWO_SIDED"));
+	DPRINTF3D(5, (fp,"\n\tvertex flags:"));
+	if(flags & B3D_VB_HAS_NORMALS) DPRINTF3D(5,(fp," B3D_VB_HAS_NORMALS"));
+	if(flags & B3D_VB_HAS_TEXTURES) DPRINTF3D(5,(fp," B3D_VB_HAS_TEXTURES"));
+	DPRINTF3D(5, (fp, "\n"));
 
 	/* process VB flags */
 	tracking = 0;
@@ -940,7 +940,7 @@
 			for(i = 0; i < nFaces; i++) {
 				B3DInputFace *face = facePtr + (2*i);
 				if(face[0] && face[1]) {
-					DPRINTF(10, (fp,"\n"));
+					DPRINTF3D(10, (fp,"\n"));
 					glRenderVertex(vtxPointer + face[0] - 1, vtxFlags);
 					glRenderVertex(vtxPointer + face[1] - 1, vtxFlags);
 				}
@@ -957,7 +957,7 @@
 			for(i = 0; i < nFaces; i++) {
 				B3DInputFace *face = facePtr + (3*i);
 				if(face[0] && face[1] && face[2]) {
-					DPRINTF(10, (fp,"\n"));
+					DPRINTF3D(10, (fp,"\n"));
 					glRenderVertex(vtxPointer + face[0] - 1, vtxFlags);
 					glRenderVertex(vtxPointer + face[1] - 1, vtxFlags);
 					glRenderVertex(vtxPointer + face[2] - 1, vtxFlags);
@@ -975,7 +975,7 @@
 			for(i = 0; i < nFaces; i++) {
 				B3DInputFace *face = facePtr + (4*i);
 				if(face[0] && face[1] && face[2] && face[3]) {
-					DPRINTF(10, (fp,"\n"));
+					DPRINTF3D(10, (fp,"\n"));
 					glRenderVertex(vtxPointer + face[0] - 1, vtxFlags);
 					glRenderVertex(vtxPointer + face[1] - 1, vtxFlags);
 					glRenderVertex(vtxPointer + face[2] - 1, vtxFlags);
@@ -987,7 +987,7 @@
 			break;
 	}
 	ERROR_CHECK;
-	DPRINTF(5, (fp,"\n"));
+	DPRINTF3D(5, (fp,"\n"));
 	glDisable(GL_COLOR_MATERIAL);
 	ERROR_CHECK;
 #ifdef GL_VERSION_1_1
@@ -1003,4 +1003,65 @@
 	return 1;
 }
 
+
+/*****************************************************************************/
+/*****************************************************************************/
+int b3dLoadClientState(int handle, float *vtxData, int vtxSize, float *colorData, int colorSize, float *normalData, int normalSize, float *txData, int txSize) {
+  glRenderer *renderer = glRendererFromHandle(handle);
+  if(!renderer || !glMakeCurrentRenderer(renderer)) {
+    DPRINTF3D(0, (fp, "ERROR: Invalid renderer specified: %d\n", handle));
+    return 0;
+  }
+
+  if(colorData) glColorPointer(colorSize, GL_FLOAT, colorSize*4, colorData);
+  else glDisableClientState(GL_COLOR_ARRAY);
+  if(normalData) glNormalPointer(GL_FLOAT, normalSize*4, normalData);
+  else glDisableClientState(GL_NORMAL_ARRAY);
+  if(txData) glTexCoordPointer(txSize, GL_FLOAT, txSize*4, txData);
+  else glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+  glVertexPointer(vtxSize, GL_FLOAT, vtxSize*4, vtxData);
+  return 1;
+}
+
+int b3dDrawRangeElements(int handle, int mode, int minIdx, int maxIdx, int nFaces, unsigned int *facePtr) {
+  glRenderer *renderer = glRendererFromHandle(handle);
+  if(!renderer || !glMakeCurrentRenderer(renderer)) return 0;
+
+#ifdef WIN32
+  if(!renderer->glDrawRangeElements) {
+    void *fn;
+    fn = wglGetProcAddress("glDrawRangeElements");
+    if(!fn) {
+      DPRINTF3D(1, (fp, "ERROR: Cannot find glDrawRangeElements\n"));
+      fn = wglGetProcAddress("glDrawRangeElementsEXT");
+      if(!fn) {
+	DPRINTF3D(1, (fp, "ERROR: Cannot find glDrawRangeElementsEXT\n"));
+	return 0;
+      }
+    }
+    renderer->glDrawRangeElements = fn;
+  }
+  (*(renderer->glDrawRangeElements))
+    (mode, minIdx, maxIdx, nFaces, GL_UNSIGNED_INT, facePtr);
+#else
+  glDrawRangeElements(mode, minIdx, maxIdx, nFaces, GL_UNSIGNED_INT, facePtr);
+#endif
+  return 1;
+}
+
+int b3dDrawElements(int handle, int mode, int nFaces, unsigned int *facePtr) {
+  glRenderer *renderer = glRendererFromHandle(handle);
+  if(!renderer || !glMakeCurrentRenderer(renderer)) return 0;
+  glDrawElements(mode, nFaces, GL_UNSIGNED_INT, facePtr);
+  return 1;
+}
+
+int b3dDrawArrays(int handle, int mode, int minIdx, int maxIdx) {
+  glRenderer *renderer = glRendererFromHandle(handle);
+  if(!renderer || !glMakeCurrentRenderer(renderer)) return 0;
+  glDrawArrays(mode, minIdx, maxIdx);
+  return 1;
+}
+
+
 #endif /* defined B3DX_GL */

Modified: trunk/platforms/Cross/plugins/B3DAcceleratorPlugin/sqOpenGLRenderer.h
===================================================================
--- trunk/platforms/Cross/plugins/B3DAcceleratorPlugin/sqOpenGLRenderer.h	2011-06-09 08:16:10 UTC (rev 2408)
+++ trunk/platforms/Cross/plugins/B3DAcceleratorPlugin/sqOpenGLRenderer.h	2011-06-09 08:21:49 UTC (rev 2409)
@@ -43,10 +43,10 @@
 }
 
 #define ERROR_CHECK_2(glFn, sqFn) \
-	{ if( (glErr = glGetError()) != GL_NO_ERROR) DPRINTF(1, (fp,"ERROR (%s): %s failed -- %s\n", sqFn, glFn, glErrString())); }
+	{ if( (glErr = glGetError()) != GL_NO_ERROR) DPRINTF3D(1, (fp,"ERROR (%s): %s failed -- %s\n", sqFn, glFn, glErrString())); }
 
 #define ERROR_CHECK_1(glFn) \
-	{ if( (glErr = glGetError()) != GL_NO_ERROR) DPRINTF(1, (fp,"ERROR (file %s, line %d): %s failed -- %s\n", __FILE__, __LINE__, glFn, glErrString())); }
+	{ if( (glErr = glGetError()) != GL_NO_ERROR) DPRINTF3D(1, (fp,"ERROR (file %s, line %d): %s failed -- %s\n", __FILE__, __LINE__, glFn, glErrString())); }
 
 #define ERROR_CHECK ERROR_CHECK_1("a GL function")
 
@@ -67,8 +67,8 @@
 #define forceFlush 1
 
 /* Note: Print this stuff into a file in case we lock up*/
-#undef DPRINTF
-# define DPRINTF(vLevel, args) if(vLevel <= verboseLevel) {\
+#undef DPRINTF3D
+# define DPRINTF3D(vLevel, args) if(vLevel <= verboseLevel) {\
 	FILE *fp = fopen("Squeak3D.log", "at");\
 	if(fp) { fprintf args; if(forceFlush) fflush(fp); fclose(fp); }}
 



More information about the Vm-dev mailing list