I compiled both sdlmame 0.115u4 and 0.116 (the link seems to work
) on Windows XP, and it always crashes in opengl mode, unlike sdlmame 0.115. I debugged a little and it seems that VBO or PBO support is the problem. I have an NVIDIA GeForce Go 7200, and I tried a different set of drivers with no success.
Here's the output on startup:
Using SDL single-window OpenGL driver (SDL 1.2)
OpenGL: NVIDIA Corporation
OpenGL: GeForce Go 7200/PCI/SSE2
OpenGL: non-power-of-2 textures supported (new method)
OpenGL: vertex buffer object
OpenGL: pixel buffers supported
OpenGL: max texture size 4096 x 4096
OpenGL: VBO PBO supported
Here's a snap of the gdb session:
texture_update (sdl=0x40ddb10, prim=0x40df590) at src/osd/sdl/drawsdl.c:1557
texture_update (sdl=0x40ddb10, prim=0x40df590) at src/osd/sdl/drawsdl.c:1589
1589 pfn_glBufferData( GL_ARRAY_BUFFER_ARB, 4*2*sizeof(GLfloat), texture->texCoord, GL_STATIC_DRAW_ARB );
0x696309d0 in _libuser32_a_iname ()
Single stepping until exit from function _libuser32_a_iname,
which has no line number information.
Program received signal SIGSEGV, Segmentation fault.
0x69668666 in _libuser32_a_iname ()
I tried to see the backtrace, but it only shows that _libuser32_a_iname. Perhaps there's stack corruption.
I then edited loadGLExtensions() to set usevbo and usepbo to false. Setting both or usevbo to false fixes it, setting only usepbo to false still crashes. I don't understand why does it crash as I'm not much into opengl.
PS: Further disassembling reveals compilation fault. The parameter assignment is made with moves instead of pushes, and it overrides the address of variable "texture" (as well as du and dv). My guess is that it only crashes in this function because the previous two only override du and dv.
And further googling, adding __stdcall before the * in PFNGL... declarations resolves it, the compiler sets the stack pointer correctly before assigning parameters. Seems to be windows specific, I don't know.
diff -r -N -U3 src/osd/sdl/drawsdl.c_ src/osd/sdl/drawsdl.c
--- src/osd/sdl/drawsdl.c_ Sun May 27 13:33:02 2007
+++ src/osd/sdl/drawsdl.c Thu Jun 14 19:27:59 2007
@@ -31,12 +31,17 @@
#if defined(SDLMAME_MACOSX) || defined(SDLMAME_WIN32)
-typedef void (* PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers);
-typedef void (* PFNGLBINDBUFFERPROC) (GLenum, GLuint);
-typedef void (* PFNGLBUFFERDATAPROC) (GLenum, GLsizeiptr, const GLvoid *, GLenum);
-typedef GLvoid* (* PFNGLMAPBUFFERPROC) (GLenum, GLenum);
-typedef GLboolean (* PFNGLUNMAPBUFFERPROC) (GLenum);
-typedef void (* PFNGLDELETEBUFFERSPROC) (GLsizei, const GLuint *);
+#define APIENTRY __stdcall
+typedef void (APIENTRY * PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers);
+typedef void (APIENTRY * PFNGLBINDBUFFERPROC) (GLenum, GLuint);
+typedef void (APIENTRY * PFNGLBUFFERDATAPROC) (GLenum, GLsizeiptr, const GLvoid *, GLenum);
+typedef GLvoid* (APIENTRY * PFNGLMAPBUFFERPROC) (GLenum, GLenum);
+typedef GLboolean (APIENTRY * PFNGLUNMAPBUFFERPROC) (GLenum);
+typedef void (APIENTRY * PFNGLDELETEBUFFERSPROC) (GLsizei, const GLuint *);
// make sure the extensions compile OK everywhere