PDA

View Full Version : problem with glGetFloatv

dvm
08-08-2003, 03:14 AM
Hi, I'm having a problem when calling glGetFloatv in the following code:

GLfloat smoothLineWidth, smoothLineGran;

glGetFloatv(GL_LINE_WIDTH_RANGE, &smoothLineWidth);
glGetFloatv(GL_LINE_WIDTH_GRANULARITY, &smoothLineGran);

cout << "Smooth Line: " << smoothLineWidth
<< ", Smooth Gran: " << smoothLineGran << endl;

The program compiles fine, but when I try to run it I get the following error:

Debug Error!

Program: C:\Basic\Debug\Basic.exe
Module:
File: i386\chkesp.c
Line: 42

The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.

What could I do? I'm not creating a function pointer, I'm just using a standard OpenGL function. When I found it in the header gl.h the prototype is WINGDIAPI void APIENTRY glGetFloatv (GLenum pname, GLfloat *params);

dvm
08-08-2003, 03:52 AM
I finally found the answer. The problem is that I called glGetFloatv with the wrong arguments. But probably because of all the dll and calling conventions I got the aforementioned error instead of one about wrong arguments. Anyway here is the corrected code:

GLfloat smoothLineWidth[2], smoothLineGran[1];

glGetFloatv(GL_LINE_WIDTH_RANGE, smoothLineWidth);
glGetFloatv(GL_LINE_WIDTH_GRANULARITY, smoothLineGran);

cout << "Smooth Line: " << smoothLineWidth[0] << ", " << smoothLineWidth[1]
<< ", Smooth Gran: " << smoothLineGran[0] << endl;