SFML community forums

Help => General => Topic started by: henrikno on January 18, 2012, 09:51:35 pm

Title: Weird crash in glDrawArrays
Post by: henrikno on January 18, 2012, 09:51:35 pm
Hello,
I am getting a crash with SFML from current git HEAD on this code: http://sprunge.us/BcDG

Backtrace:
Quote

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000000
0x0000000101bab554 in gleRunVertexSubmitImmediate ()
(gdb) bt
#0  0x0000000101bab554 in gleRunVertexSubmitImmediate ()
#1  0x0000000101baa5db in gleLLVMArrayFunc ()
#2  0x0000000101baa5ab in gleSetVertexArrayFunc ()
#3  0x0000000101b95f03 in gleDrawArraysOrElements_ExecCore ()
#4  0x0000000101b206b8 in glDrawArrays_Exec ()
#5  0x00000001000016b2 in DrawCube () at src/DrawCube.cpp:49
#6  0x0000000100001815 in main () at src/DrawCube.cpp:67


Happens on win/linux/mac.
Did I do something wrong or did I stumble upon a bug?
I tried running the same Draw function in GLFW and it worked.
Title: Weird crash in glDrawArrays
Post by: Laurent on January 18, 2012, 10:58:39 pm
You must call glDisableClientState for texture coordinates and color components.
Title: Weird crash in glDrawArrays
Post by: henrikno on January 19, 2012, 08:16:38 pm
Oh, then I have some more questions.

1. Why?
2. Do I need to do it once or every frame?
3. Are there more opengl settings I need to set to make it act as if it's a new context?
4. Is there a way to avoid having to set them?
Title: Weird crash in glDrawArrays
Post by: Laurent on January 19, 2012, 09:56:59 pm
Quote
1. Why?

SFML sets these states once during initialization, setting them everytime Draw is called would be redundant.
Use sf::Window if you want to draw with OpenGL instead of SFML.

Quote
2. Do I need to do it once or every frame?

Just once but then Draw() is unlikely to work correctly after you do so. But you probably won't call it, so use sf::Window instead.

Quote
3. Are there more opengl settings I need to set to make it act as if it's a new context?

Yes. Use a sf::Window instead.

Quote
4. Is there a way to avoid having to set them?

Use sf::Window.