Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Weird crash in glDrawArrays  (Read 2984 times)

0 Members and 1 Guest are viewing this topic.

henrikno

  • Newbie
  • *
  • Posts: 8
    • View Profile
Weird crash in glDrawArrays
« 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Weird crash in glDrawArrays
« Reply #1 on: January 18, 2012, 10:58:39 pm »
You must call glDisableClientState for texture coordinates and color components.
Laurent Gomila - SFML developer

henrikno

  • Newbie
  • *
  • Posts: 8
    • View Profile
Weird crash in glDrawArrays
« Reply #2 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?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Weird crash in glDrawArrays
« Reply #3 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.
Laurent Gomila - SFML developer