Demos (cmake): Revert callback changes.
Jose Fonseca
jrfonseca at kemper.freedesktop.org
Tue Nov 9 14:21:42 UTC 2010
Module: Demos
Branch: cmake
Commit: c207ac5309decacb805ddea71ca9d0e4cc9a5c58
URL: http://cgit.freedesktop.org/mesa/demos/commit/?id=c207ac5309decacb805ddea71ca9d0e4cc9a5c58
Author: José Fonseca <jfonseca at vmware.com>
Date: Tue Nov 9 13:22:16 2010 +0000
Revert callback changes.
The original code was correct & portable -- the problem was the missing
windows.h headers.
---
src/demos/tessdemo.c | 41 +++++++++++++++++++++++++----------------
src/samples/nurb.c | 12 +++++++++---
src/samples/quad.c | 12 +++++++++---
3 files changed, 43 insertions(+), 22 deletions(-)
diff --git a/src/demos/tessdemo.c b/src/demos/tessdemo.c
index db66bd8..f2dcee7 100644
--- a/src/demos/tessdemo.c
+++ b/src/demos/tessdemo.c
@@ -7,13 +7,20 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <GL/glew.h> /* for GLAPIENTRY */
#include <GL/glut.h>
#define MAX_POINTS 256
#define MAX_CONTOURS 32
#define MAX_TRIANGLES 256
+#ifndef GLCALLBACK
+#ifdef CALLBACK
+#define GLCALLBACK CALLBACK
+#else
+#define GLCALLBACK
+#endif
+#endif
+
#ifdef GLU_VERSION_1_2
typedef enum{ QUIT, TESSELATE, CLEAR } menu_entries;
@@ -43,7 +50,7 @@ static struct {
-static void GLAPIENTRY error_callback( GLenum err )
+static void GLCALLBACK error_callback( GLenum err )
{
int len, i;
char const *str;
@@ -59,14 +66,14 @@ static void GLAPIENTRY error_callback( GLenum err )
}
}
-static void GLAPIENTRY begin_callback( GLenum mode )
+static void GLCALLBACK begin_callback( GLenum mode )
{
/* Allow multiple triangles to be output inside the begin/end pair. */
triangle_cnt = 0;
triangles[triangle_cnt].no = 0;
}
-static void GLAPIENTRY edge_callback( GLenum flag )
+static void GLCALLBACK edge_callback( GLenum flag )
{
/* Persist the edge flag across triangles. */
if ( flag == GL_TRUE ) {
@@ -80,7 +87,7 @@ static void GLAPIENTRY edge_callback( GLenum flag )
}
}
-static void GLAPIENTRY end_callback(void)
+static void GLCALLBACK end_callback(void)
{
GLuint i;
@@ -114,7 +121,7 @@ static void GLAPIENTRY end_callback(void)
glEnd();
}
-static void GLAPIENTRY vertex_callback( void *data )
+static void GLCALLBACK vertex_callback( void *data )
{
GLsizei no;
GLfloat *p;
@@ -136,7 +143,7 @@ static void GLAPIENTRY vertex_callback( void *data )
}
}
-static void GLAPIENTRY combine_callback( GLdouble coords[3],
+static void GLCALLBACK combine_callback( GLdouble coords[3],
GLdouble *vertex_data[4],
GLfloat weight[4], void **data )
{
@@ -157,6 +164,8 @@ static void set_screen_wh( GLsizei w, GLsizei h )
height = h;
}
+typedef void (GLAPIENTRY *callback_t)(void);
+
static void tesse( void )
{
GLUtesselator *tobj;
@@ -169,11 +178,11 @@ static void tesse( void )
if ( tobj != NULL ) {
gluTessNormal( tobj, 0.0, 0.0, 1.0 );
- gluTessCallback( tobj, GLU_TESS_BEGIN, (_GLUfuncptr) glBegin );
- gluTessCallback( tobj, GLU_TESS_VERTEX, (_GLUfuncptr) glVertex2fv );
- gluTessCallback( tobj, GLU_TESS_END, (_GLUfuncptr) glEnd );
- gluTessCallback( tobj, GLU_TESS_ERROR, (_GLUfuncptr) error_callback );
- gluTessCallback( tobj, GLU_TESS_COMBINE, (_GLUfuncptr) combine_callback );
+ gluTessCallback( tobj, GLU_TESS_BEGIN, (callback_t) glBegin );
+ gluTessCallback( tobj, GLU_TESS_VERTEX, (callback_t) glVertex2fv );
+ gluTessCallback( tobj, GLU_TESS_END, (callback_t) glEnd );
+ gluTessCallback( tobj, GLU_TESS_ERROR, (callback_t) error_callback );
+ gluTessCallback( tobj, GLU_TESS_COMBINE, (callback_t) combine_callback );
glNewList( list_start, GL_COMPILE );
gluBeginPolygon( tobj );
@@ -193,10 +202,10 @@ static void tesse( void )
gluEndPolygon( tobj );
glEndList();
- gluTessCallback( tobj, GLU_TESS_BEGIN, (_GLUfuncptr) begin_callback );
- gluTessCallback( tobj, GLU_TESS_VERTEX, (_GLUfuncptr) vertex_callback );
- gluTessCallback( tobj, GLU_TESS_END, (_GLUfuncptr) end_callback );
- gluTessCallback( tobj, GLU_TESS_EDGE_FLAG, (_GLUfuncptr) edge_callback );
+ gluTessCallback( tobj, GLU_TESS_BEGIN, (callback_t) begin_callback );
+ gluTessCallback( tobj, GLU_TESS_VERTEX, (callback_t) vertex_callback );
+ gluTessCallback( tobj, GLU_TESS_END, (callback_t) end_callback );
+ gluTessCallback( tobj, GLU_TESS_EDGE_FLAG, (callback_t) edge_callback );
glNewList( list_start + 1, GL_COMPILE );
gluBeginPolygon( tobj );
diff --git a/src/samples/nurb.c b/src/samples/nurb.c
index 099144e..dc89912 100644
--- a/src/samples/nurb.c
+++ b/src/samples/nurb.c
@@ -26,10 +26,14 @@
#include <stdlib.h>
#include <string.h>
#include <math.h>
-#include <GL/glew.h>
#include <GL/glut.h>
+#ifndef CALLBACK
+#define CALLBACK
+#endif
+
+
#define INREAL float
#define S_NUMPOINTS 13
@@ -203,7 +207,7 @@ Point ctlpoints[S_NUMPOINTS][T_NUMPOINTS] = {
GLUnurbsObj *theNurbs;
-static void GLAPIENTRY ErrorCallback(GLenum which)
+static void CALLBACK ErrorCallback(GLenum which)
{
if (which != expectedError) {
@@ -212,11 +216,13 @@ static void GLAPIENTRY ErrorCallback(GLenum which)
}
}
+typedef void (GLAPIENTRY *callback_t)();
+
static void Init(void)
{
theNurbs = gluNewNurbsRenderer();
- gluNurbsCallback(theNurbs, GLU_ERROR, (_GLUfuncptr) ErrorCallback);
+ gluNurbsCallback(theNurbs, GLU_ERROR, (callback_t) ErrorCallback);
gluNurbsProperty(theNurbs, GLU_SAMPLING_TOLERANCE, 15.0);
gluNurbsProperty(theNurbs, GLU_DISPLAY_MODE, GLU_OUTLINE_PATCH);
diff --git a/src/samples/quad.c b/src/samples/quad.c
index 8171d76..193850a 100644
--- a/src/samples/quad.c
+++ b/src/samples/quad.c
@@ -25,10 +25,14 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
-#include <GL/glew.h>
#include <GL/glut.h>
+#ifndef CALLBACK
+#define CALLBACK
+#endif
+
+
#define PI 3.141592654
#define BLACK 0
#define GRAY 128
@@ -92,12 +96,14 @@ GLubyte brickImage[4*brickImageWidth*brickImageHeight] = {
char *texFileName = 0;
-static void GLAPIENTRY ErrorHandler(GLenum which)
+static void CALLBACK ErrorHandler(GLenum which)
{
fprintf(stderr, "Quad Error: %s\n", (char *) gluErrorString(which));
}
+typedef void (GLAPIENTRY *callback_t)();
+
static void Init(void)
{
static GLint colorIndexes[3] = {0, 200, 255};
@@ -159,7 +165,7 @@ static void Init(void)
}
quadObj = gluNewQuadric();
- gluQuadricCallback(quadObj, GLU_ERROR, (_GLUfuncptr) ErrorHandler);
+ gluQuadricCallback(quadObj, GLU_ERROR, (callback_t) ErrorHandler);
radius1 = 10;
radius2 = 5;
More information about the mesa-commit
mailing list