jaese
jaese

Reputation: 165

Segmentation fault when calling glDrawElementsInstanced

I found that changing glDrawElements to glDrawElementInstanced results in segfault in otherwise valid program. No problem compiling. gdb says that glDrawElementInstanced is what segfaults. Can anyone guess a problem?

Running on x86_64 GNU/Linux.

Part of CMakeLists.txt:

cmake_minimum_required (VERSION 2.6)
project (sph)

find_package(OpenGL REQUIRED)

include_directories(
    /usr/nvidia-current
.
)

set(ALL_LIBS
    ${OPENGL_LIBRARY}
    glfw
    GLEW
)

add_definitions(
    -D_CRT_SECURE_NO_WARNINGS
)

target_link_libraries(sph
    ${ALL_LIBS}
)

Site of segfault:

glDrawElementsInstanced(
            GL_TRIANGLES,
            indices.size(),
            GL_UNSIGNED_SHORT,
            (void *)0,
            2
        );

Upvotes: 1

Views: 898

Answers (1)

Kornel Kisielewicz
Kornel Kisielewicz

Reputation: 57625

  1. Did you make sure that you have at least a OpenGL 3.1 context available?
  2. Did you check if the glDrawElementInstanced is not NULL after loading it via GLEW?

Upvotes: 3

Related Questions