Is any body using gluNurbsCallback()?

Started by
1 comment, last by fjj 18 years, 7 months ago
I've met some problems with gluNurbsCallback() I write code in Vs.net vc7, and I want to use this routine to retrieve data from a nurbs curve. after I compiled , the error information is error C2664: 'gluNurbsCallback' : cannot convert parameter 3 from 'void (GLenum)' to 'GLvoid (__stdcall *)(void)' None of the functions with this name in scope match the target type error C2664: 'gluNurbsCallback' : cannot convert parameter 3 from 'void (GLfloat *)' to 'GLvoid (__stdcall *)(void)' None of the functions with this name in scope match the target type and I found a similar topic of this problem in this fourm, which is posted by _gl_coder_one_. (http://www.gamedev.net/community/forums/topic.asp?topic_id=333716) after then, I change this code to a c code and compile in lcc-win32. other errors come: Wedit output window build: Wed Sep 7 03:44:36 2005 Error e:\tools\lcc\projects\test.c 109 undefined reference to _glutInit@8 Error e:\tools\lcc\projects\test.c 110 undefined reference to _glutInitDisplayMode@4 Error e:\tools\lcc\projects\test.c 111 undefined reference to _glutInitWindowPosition@8 Error e:\tools\lcc\projects\test.c 112 undefined reference to _glutInitWindowSize@8 Error e:\tools\lcc\projects\test.c 113 undefined reference to _glutCreateWindow@4 Error e:\tools\lcc\projects\test.c 116 undefined reference to _glutDisplayFunc@4 Error e:\tools\lcc\projects\test.c 125 undefined reference to _glutMainLoop@0 0; Compilation + link time:0.4 sec, Return code: 7 what could be the problem? Thanks
Advertisement
Can we see the code? And this is the function prototype:

gluNurbsCallback
The gluNurbsCallback function defines a callback for a NURBS object.

void gluNurbsCallback(
GLUnurbsObj *nobj,
GLenum which,
void (* fn)()
);
Parameters
nobj
The NURBS object (created with gluNewNurbsRenderer).
which
The callback being defined. The only valid value is GLU_ERROR. The meaning of GLU_ERROR means that the error function is called when an error is encountered. Its single argument is of type GLenum, and it indicates the specific error that occurred. There are 37 errors unique to NURBS, named GLU_NURBS_ERROR1 through GLU_NURBS_ERROR37. Character strings describing these errors can be retrieved with gluErrorString.
fn
A pointer to the callback function.
the prototype which is described on msdn lib is opengl 1.1
and what I am doing is involke callback fuctions from glu.h version 1.3

set gluNurbsProperty(nobj, GLU_NURBS_MODE, GLU_NURBS_TESSELLATOR)
then the addtional 12 callback function is actived

my code is:
// test3.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include "windows.h"#include "gl/gl.h"#include "gl/glu.h"#include "gl/glut.h"#include "stdio.h"#include "stdlib.h"#include "math.h"GLsizei winWidth = 200, winHeight = 150;GLUnurbsObj *parabola;	float **array;int i=0;#ifndef CALLBACK#define CALLBACK#endifvoid CALLBACK beginCallback(GLenum type){	type=GL_LINES;	glBegin(GL_LINES);}void CALLBACK endCallback(){	glEnd();}/*void CALLBACK nurbsError (){	int errorCode;	const GLubyte *estring;	estring = gluErrorString(errorCode);	fprintf(stderr, "Nurbs Error: %s\n", estring);	exit(0);}*/void CALLBACK vertexCallback(GLfloat *vertex){	glVertex3fv(vertex);	array[0]=vertex[0];	array[1]=vertex[1];	array[2]=vertex[2];	i++;	printf("%d", i);	printf("glVertex3f (%5.3f, %5.3f, %5.3f\n)", vertex[0],vertex[1],vertex[2]);}void init (void){	glClearColor (1.0, 1.0, 1.0, 0.0);	glMatrixMode(GL_PROJECTION);	gluOrtho2D(0.0, 200.0, 0.0, 150.0);	parabola = gluNewNurbsRenderer();	gluNurbsProperty(parabola,GLU_NURBS_MODE_EXT,GLU_NURBS_TESSELLATOR_EXT);	gluNurbsProperty(parabola,GLU_SAMPLING_TOLERANCE,100.0);	gluNurbsProperty(parabola,GLU_DISPLAY_MODE,GLU_FILL);//	gluNurbsCallback(parabola,GLU_ERROR,nurbsError);	gluNurbsCallback(parabola,GLU_NURBS_BEGIN_EXT,beginCallback);	gluNurbsCallback(parabola,GLU_NURBS_VERTEX_EXT,vertexCallback);	gluNurbsCallback(parabola,GLU_NURBS_END_EXT,endCallback);}void winReshapeFcn(int newWidth, int newHeight){	glMatrixMode(GL_PROJECTION);	glLoadIdentity();	gluOrtho2D(0.0, (GLdouble) newWidth, 0.0, (GLdouble) newHeight);	glClear(GL_COLOR_BUFFER_BIT);}void curves(void){	glClear(GL_COLOR_BUFFER_BIT);	glColor3f(1.0,0.0,0.0);	GLfloat knotVector [6] = {0.0,0.0,0.0,1.0,1.0,1.0};	GLfloat ctrlPts [3][3] = {{145.0,140.0,1.0},{105.0,60.0,1.0}, {55.0,140.0,1.0}};		gluBeginCurve(parabola);		gluNurbsCurve (parabola,6,knotVector,3,&ctrlPts[0][0],3,GL_MAP1_VERTEX_3);	gluEndCurve(parabola);	glBegin(GL_LINES);		glVertex2i(190,10);		glVertex2i(190,140);		glVertex2i(190,140);		glVertex2i(145,140);		glVertex2i(55,140);		glVertex2i(10,140);		glVertex2i(10,140);		glVertex2i(10,10);		glVertex2i(10,10);		glVertex2i(190,10);	glEnd();	glFlush();}int _tmain(int argc, char** argv){	int j=0;	FILE *fp;	glutInit(&argc, argv);	glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);	glutInitWindowPosition(50,100);	glutInitWindowSize(400,300);	glutCreateWindow("An Example OpenGL Program");	init();	glutDisplayFunc(curves);	printf("%d", i);		fp = fopen("dataforvetex.txt","w");	for(j=0;j<i;j++)	{		fprintf(fp, "%5.3f, %5.3f, %5.3f \n",array[j][0], array[j][1], array[j][2]);	}	fclose(fp);	glutMainLoop();	return 0;}


[Edited by - phantom on September 8, 2005 8:15:25 AM]

This topic is closed to new replies.

Advertisement