I'm trying to compile a GLSL shader, to which I use the following code.
Initialization
SDL_Window* boringInitStuff(){
SDL_Init(SDL_INIT_VIDEO);
SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, 3 );
SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, 1 );
SDL_GL_SetAttribute( SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE );
Uint32 windowFlags = SDL_WINDOW_OPENGL;
SDL_Window* sdlWindow = SDL_CreateWindow("Boooring", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 400, 400, windowFlags);
SDL_GL_CreateContext(sdlWindow);
glewExperimental = GL_TRUE;
glewInit();
return sdlWindow;
}
File parser
void readFile(std::string path, std::string& data){
std::ifstream f(path.c_str(), std::ios::binary);
data.assign((std::istreambuf_iterator<char>(f)),
(std::istreambuf_iterator<char>()));
}
Main
int main(int argv, char** args) {
SDL_Window* sdlWindow = boringInitStuff();
std::string buffer;
readFile("./compile_test.vert", buffer);
const char* cBuffer = buffer.c_str();
GLuint shaderID = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(shaderID, 1, &cBuffer, nullptr);
glCompileShader(shaderID);
while(!SDL_QuitRequested()){
SDL_GL_SwapWindow(sdlWindow);
}
return 0;
}
But when I try to inspect the source code in gDEBugger, the source code is gone. Linking of course doesn't work aswell. The weird thing is, that the compilation error checking works. EDIT: When I copy & paste the main part into another opengl project, it works.