Jump to content
  • Advertisement
Sign in to follow this  
Thylz

SDL chashes

This topic is 2842 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi!

Please, excuse my bad english.

I use Linux, OpenGL 1.4 (Intel Linux drivers sucks) and SDL 1.2.14

I'm beginning in OpenGL and I'm doing any simple programs to experiment, now I'm exporting a "game" done with GLUT to SDL. g++ don't gives me any error, but when I run the program, it crashes before do anything.

Valgrind says a lot of things, but the latest are:

Quote:
==8410== Invalid read of size 8
==8410== at 0x42E77AF: (within /lib/tls/i686/cmov/libc-2.11.1.so)
==8410== by 0x440E886: XrmGetStringDatabase (in /usr/lib/libX11.so.6.2.0)
==8410== by 0x43EB3B9: (within /usr/lib/libX11.so.6.2.0)
==8410== by 0x43EB5AE: XGetDefault (in /usr/lib/libX11.so.6.2.0)
==8410== by 0x4A77313: _XcursorGetDisplayInfo (in /usr/lib/libXcursor.so.1.0.2)
==8410== by 0x4A7754C: XcursorSupportsARGB (in /usr/lib/libXcursor.so.1.0.2)
==8410== by 0x4A79CA5: XcursorNoticeCreateBitmap (in /usr/lib/libXcursor.so.1.0.2)
==8410== by 0x43E4F74: _XNoticeCreateBitmap (in /usr/lib/libX11.so.6.2.0)
==8410== by 0x43E51CC: XCreatePixmap (in /usr/lib/libX11.so.6.2.0)
==8410== by 0x40C7659: XCreatePixmap (SDL_x11sym.h:38)
==8410== by 0x40D0A3F: X11_CreateWMCursor (SDL_x11mouse.c:104)
==8410== by 0x40D3CED: X11_VideoInit (SDL_x11video.c:691)
==8410== Address 0x4532358 is 0 bytes after a block of size 14,104 alloc'd
==8410== at 0x4025D2E: malloc (vg_replace_malloc.c:207)
==8410== by 0x43F7A23: XOpenDisplay (in /usr/lib/libX11.so.6.2.0)
==8410== by 0x40C7FCD: XOpenDisplay (SDL_x11sym.h:78)
==8410== by 0x40D3A63: X11_VideoInit (SDL_x11video.c:574)
==8410== by 0x40BF032: SDL_VideoInit (SDL_video.c:246)
==8410== by 0x4091C17: SDL_InitSubSystem (SDL.c:70)
==8410== by 0x4091C76: SDL_Init (SDL.c:162)
==8410== by 0x8049C33: AGEGame::createEnv(int, int, int, int, char*, unsigned, int, char**) (AGE_core.cpp:65)
==8410== by 0x804A31A: main (prueba2.cpp:183)


And here is the function createEng, when I don't found any error.


void AGEGame::createEnv (int x, int y, int w, int h, char *name, unsigned int mode, int argc, char* argv[]) {
/*glutInit(&argc, argv);
glutInitDisplayMode(mode);
glutInitWindowPosition(x,y);
glutInitWindowSize(w,h);
glutCreateWindow(name);*/
const SDL_VideoInfo *info = SDL_GetVideoInfo( );
SDL_Init(SDL_INIT_VIDEO);
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
screen = SDL_SetVideoMode(w, h, info->vfmt->BitsPerPixel, SDL_OPENGL);

istimer = false;
env = true;
xpos = x;
ypos = y;
height = h;
width = w;
game_name = name;
gmode = mode;
}


Thanks and, again, excuse my english.

Share this post


Link to post
Share on other sites
Advertisement
Yes! It was! Thanks :D

But, now I've another problem X(. The program runs, but nothing is drawn. I think is a problem with the function SDL_GL_SwapBuffers(); but I don't know when.


Quote:
==9898== Address 0x69a4da8 is 0 bytes after a block of size 24 alloc'd
==9898== at 0x4025D2E: malloc (vg_replace_malloc.c:207)
==9898== by 0x4B23D0C: _mesa_malloc (in /usr/lib/dri/i965_dri.so)
==9898== by 0x4B23D55: _mesa_strdup (in /usr/lib/dri/i965_dri.so)
==9898== by 0x4BAB9E7: _mesa_program_state_string (in /usr/lib/dri/i965_dri.so)
==9898== by 0x4BA7DFB: _mesa_add_state_reference (in /usr/lib/dri/i965_dri.so)
==9898== by 0x4AD7037: (within /usr/lib/dri/i965_dri.so)
==9898== by 0x4AD94FF: (within /usr/lib/dri/i965_dri.so)
==9898== by 0x4ADC0D5: (within /usr/lib/dri/i965_dri.so)
==9898== by 0x4AD1C23: brw_validate_state (in /usr/lib/dri/i965_dri.so)
==9898== by 0x4AC5E0C: (within /usr/lib/dri/i965_dri.so)
==9898== by 0x4AC60C6: brw_draw_prims (in /usr/lib/dri/i965_dri.so)
==9898== by 0x4B6DC84: vbo_exec_vtx_flush (in /usr/lib/dri/i965_dri.so)
==9898==
==9898== Syscall param ioctl(generic) points to uninitialised byte(s)
==9898== at 0x4000832: (within /lib/ld-2.11.1.so)
==9898== by 0x4AAA5F0: LOCK_HARDWARE (in /usr/lib/dri/i965_dri.so)
==9898== by 0x4AA6E42: intelCopyBuffer (in /usr/lib/dri/i965_dri.so)
==9898== by 0x4AA961F: intelSwapBuffers (in /usr/lib/dri/i965_dri.so)
==9898== by 0x4AA05A6: (within /usr/lib/dri/i965_dri.so)
==9898== by 0x4041958: glXSwapBuffers (in /usr/lib/libGL.so.1.2)
==9898== by 0x40CC794: X11_GL_SwapBuffers (SDL_x11gl.c:444)
==9898== by 0x40BCEB0: SDL_GL_SwapBuffers (SDL_video.c:1524)
==9898== by 0x8049DA6: AGEGame::mainLoop() (AGE_core.cpp:17)
==9898== by 0x8049E88: AGEGame::initGame() (AGE_core.cpp:92)
==9898== by 0x804A3EE: main (prueba2.cpp:191)
==9898== Address 0xbea5d624 is on thread 1's stack


And the code...

Quote:
void AGEGame::mainLoop () {
clock_t endwait,startwait;

render_function ();
SDL_GL_SwapBuffers();

endwait = clock () + timer * (CLOCKS_PER_SEC/1000.0);

while (can) { //While the game is playing
handleEvents ();
if (clock () >= endwait) {
if (istimer) { //if isn't paused
timer_function (); //Refresh screen scene data
render_function (); //Draw scene
SDL_GL_SwapBuffers(); //Refresh screen
}
endwait = clock () + timer * (CLOCKS_PER_SEC/1000.0);
}
}
}


Thanks again :).

Share this post


Link to post
Share on other sites
Excuse me for double posting.

I've solved my problem. Just I forgot call the function to manage reshapping, that GLUT calls automatically. Now the programs runs well and better :D

Thanks.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!