I am not sure what's going on, this was working before and all of a sudden it's just acting really crazy on me.
this is a cmake and sdl project. cmakelists.txt
PROJECT(ren_opengl)
SET(SRC_FILES ren_opengl.c)
set(CMAKE_MACOSX_RPATH 1)
FIND_PACKAGE(SDL2 REQUIRED)
INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIR})
FIND_PACKAGE(OPENGL REQUIRED)
INCLUDE_DIRECTORIES( ${OPENGL_INCLUDE_DIR})
ADD_EXECUTABLE(ren_opengl ${SRC_FILES})
TARGET_LINK_LIBRARIES(ren_opengl ${SDL2_LIBRARY} ${OPENGL_LIBRARIES})
included headers
#include <SDL2/SDL.h>
#include <OpenGL/gl3.h>
#include <SDL2/SDL_opengl.h>
Init SDL in ren_opengl.c
int init_sdl(int width, int height, char* title, double fps)
{
if (SDL_Init(SDL_INIT_EVERYTHING) != 0)
{
SDL_Log("sdl failed to init");
SDL_Quit();
return -1;
}
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
window = SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN);
if(window == NULL)
{
SDL_Log("sdl failed to create window");
SDL_Quit();
return -1;
}
maincontext = SDL_GL_CreateContext(window);
if(maincontext == NULL)
{
SDL_Log("sdl failed to create opengl context");
SDL_Quit();
return -1;
}
SDL_GL_SetSwapInterval(1);
return 1;
}
at the end of init sdl everything is working, I ca
void render()
{
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
SDL_GL_SwapWindow(window);
}
if I create a GLuint vao; that causes no problems, as soon as I try to do glGenBuffers(1, &vao); That line above keeps giving segmentation fault.
I even just updated to sdl 2.0.4 but i am really not sure what's going on now.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire