erik-k
09-22-2004, 09:37 PM
I'm the developer of the Sourceforge project Tronimation. I've been working on some improved primitives, but I'm hitting a stone wall. For some reason, a program that used to be 100% stable now crashes for no apparent reason every 5 minutes.
The improved primitive is currently the cube. Other than changes pieces to handle 7 rather then 2 object variables (not the problem), this is the only thing I can think of that's the problem:
glVertex3f((GLfloat)-values.xsize, (GLfloat)-values.ysize,(GLfloat)-values.zsize); //-1 -1 -1 LEFT SIDE
glVertex3f((GLfloat)-values.xsize, (GLfloat)-values.ysize, (GLfloat)values.zsize); //-1 -1 1
glVertex3f((GLfloat)-values.xsize*values.var0*cosf(deg_to_rad*values.va r5)*cosf(deg_to_rad*values.var6), (GLfloat)values.ysize-values.ysize*sinf(deg_to_rad*values.var4)*sinf(deg _to_rad*values.var5),(GLfloat) values.zsize*values.var2*cosf(deg_to_rad*values.va r4)*cosf(deg_to_rad*values.var6)); //-1 1 1
glVertex3f((GLfloat)-values.xsize*values.var0*cosf(deg_to_rad*values.va r5)*cosf(deg_to_rad*values.var6), (GLfloat)values.ysize-values.ysize*sinf(deg_to_rad*values.var4)*sinf(deg _to_rad*values.var5),(GLfloat)-values.zsize*values.var3*cosf(deg_to_rad*values.va r4)*cosf(deg_to_rad*values. var6)); //-1 1 -1
This is the code for one side of the "cube." Here is the typedef that values refers to:
typedef struct static_object { // Defines values to draw static objects
float xsize, ysize, zsize; // X-Y-Z Scale factors of object
float xpos, ypos, zpos; // Position
float lr,lg,lb, fr, fg, fb, alpha; // (l)ine and (f)ace colors
float xangle, yangle, zangle; // XYZ vectors to rotate around
int groupnum;
float var0, var1, var2, var3, var4, var5, var6; // Seven variables to do whatever you want
short int object_type;
short int object_render_options;
} static_object;
At first I thought that the problem was that I suddenly decided to perform sin/cos math on what were previously just numbers with maybe one multiply while not casting them to GLfloat. But I added GLfloat and it is not helping...
Here's a copy-paste of the console output that happens:
[erik-k@erik Tronimation]$ ./tronimation
5163: binding file /usr/X11R6/lib/libglut.so.3 to /lib/tls/libc.so.6: normal symbol `exit' [GLIBC_2.0]
Segmentation fault
[erik-k@erik Tronimation]$ ./tronimation
5165: binding file ./tronimation to /lib/tls/libc.so.6: normal symbol `sscanf' [GLIBC_2.0]
lookup 0x08048000 0x00000688 -> 0x4026d000 0x0005f780 /1 sscanf
5165: binding file ./tronimation to /usr/lib/tls/libGL.so.1: normal symbol `glColor4f'
lookup 0x08048000 0x00000748 -> 0x40161000 0x00052588 /1 glColor4f
5165: binding file ./tronimation to /usr/lib/tls/libGL.so.1: normal symbol `glBegin'
lookup 0x08048000 0x000004a8 -> 0x40161000 0x00052028 /1 glBegin
5165: binding file ./tronimation to /usr/lib/tls/libGL.so.1: normal symbol `glVertex3f'
lookup 0x08048000 0x000003f8 -> 0x40161000 0x00053e28 /1 glVertex3f
5165: binding file ./tronimation to /lib/tls/libm.so.6: normal symbol `cosf' [GLIBC_2.0]
lookup 0x08048000 0x00000668 -> 0x4024a000 0x0000fd50 /1 cosf
5165: binding file ./tronimation to /lib/tls/libm.so.6: normal symbol `sinf' [GLIBC_2.0]
lookup 0x08048000 0x00000418 -> 0x4024a000 0x00010910 /1 sinf
5165: binding file ./tronimation to /usr/lib/tls/libGL.so.1: normal symbol `glEnd'
lookup 0x08048000 0x00000768 -> 0x40161000 0x00052808 /1 glEnd
Segmentation fault
It's like something is screwing up the internal state of GLUT and I have no idea where the problem is. I'm drawing a major WTF here... Can anyone help? If you want to read the rest of the source, I'm zipping up everything as-is and putting it up as a devel at SourceForge.net/projects/tronimation after I post this.
The improved primitive is currently the cube. Other than changes pieces to handle 7 rather then 2 object variables (not the problem), this is the only thing I can think of that's the problem:
glVertex3f((GLfloat)-values.xsize, (GLfloat)-values.ysize,(GLfloat)-values.zsize); //-1 -1 -1 LEFT SIDE
glVertex3f((GLfloat)-values.xsize, (GLfloat)-values.ysize, (GLfloat)values.zsize); //-1 -1 1
glVertex3f((GLfloat)-values.xsize*values.var0*cosf(deg_to_rad*values.va r5)*cosf(deg_to_rad*values.var6), (GLfloat)values.ysize-values.ysize*sinf(deg_to_rad*values.var4)*sinf(deg _to_rad*values.var5),(GLfloat) values.zsize*values.var2*cosf(deg_to_rad*values.va r4)*cosf(deg_to_rad*values.var6)); //-1 1 1
glVertex3f((GLfloat)-values.xsize*values.var0*cosf(deg_to_rad*values.va r5)*cosf(deg_to_rad*values.var6), (GLfloat)values.ysize-values.ysize*sinf(deg_to_rad*values.var4)*sinf(deg _to_rad*values.var5),(GLfloat)-values.zsize*values.var3*cosf(deg_to_rad*values.va r4)*cosf(deg_to_rad*values. var6)); //-1 1 -1
This is the code for one side of the "cube." Here is the typedef that values refers to:
typedef struct static_object { // Defines values to draw static objects
float xsize, ysize, zsize; // X-Y-Z Scale factors of object
float xpos, ypos, zpos; // Position
float lr,lg,lb, fr, fg, fb, alpha; // (l)ine and (f)ace colors
float xangle, yangle, zangle; // XYZ vectors to rotate around
int groupnum;
float var0, var1, var2, var3, var4, var5, var6; // Seven variables to do whatever you want
short int object_type;
short int object_render_options;
} static_object;
At first I thought that the problem was that I suddenly decided to perform sin/cos math on what were previously just numbers with maybe one multiply while not casting them to GLfloat. But I added GLfloat and it is not helping...
Here's a copy-paste of the console output that happens:
[erik-k@erik Tronimation]$ ./tronimation
5163: binding file /usr/X11R6/lib/libglut.so.3 to /lib/tls/libc.so.6: normal symbol `exit' [GLIBC_2.0]
Segmentation fault
[erik-k@erik Tronimation]$ ./tronimation
5165: binding file ./tronimation to /lib/tls/libc.so.6: normal symbol `sscanf' [GLIBC_2.0]
lookup 0x08048000 0x00000688 -> 0x4026d000 0x0005f780 /1 sscanf
5165: binding file ./tronimation to /usr/lib/tls/libGL.so.1: normal symbol `glColor4f'
lookup 0x08048000 0x00000748 -> 0x40161000 0x00052588 /1 glColor4f
5165: binding file ./tronimation to /usr/lib/tls/libGL.so.1: normal symbol `glBegin'
lookup 0x08048000 0x000004a8 -> 0x40161000 0x00052028 /1 glBegin
5165: binding file ./tronimation to /usr/lib/tls/libGL.so.1: normal symbol `glVertex3f'
lookup 0x08048000 0x000003f8 -> 0x40161000 0x00053e28 /1 glVertex3f
5165: binding file ./tronimation to /lib/tls/libm.so.6: normal symbol `cosf' [GLIBC_2.0]
lookup 0x08048000 0x00000668 -> 0x4024a000 0x0000fd50 /1 cosf
5165: binding file ./tronimation to /lib/tls/libm.so.6: normal symbol `sinf' [GLIBC_2.0]
lookup 0x08048000 0x00000418 -> 0x4024a000 0x00010910 /1 sinf
5165: binding file ./tronimation to /usr/lib/tls/libGL.so.1: normal symbol `glEnd'
lookup 0x08048000 0x00000768 -> 0x40161000 0x00052808 /1 glEnd
Segmentation fault
It's like something is screwing up the internal state of GLUT and I have no idea where the problem is. I'm drawing a major WTF here... Can anyone help? If you want to read the rest of the source, I'm zipping up everything as-is and putting it up as a devel at SourceForge.net/projects/tronimation after I post this.