Skip to main content
gamedev.net
🔒 Locked

GLSL compile problems

Started by painofangels 2 replies 3.9k views
Original Post
painofangels
painofangels
I'm currently having trouble to get my GLSL vertex shader code to compile within my OpenGL program.
My Vertex shader is pretty basic for testing purposes:

#version 140 uniform Transformation{    mat4 projection_matrix;    mat4 modelview_matrix;}; in vec3 vertex; void main(){    gl_Position = projection_matrix * modelview_matrix * vec4(vertex, 1.0);}


and now I try to set the shader source and compile it with OpenGL:

m_uVertexShader = glCreateShader( GL_VERTEX_SHADER );std::string szShaderCode = FileReader::ReadTextFile( szVertexShaderPath );const char* szTemp =  szShaderCode.c_str(); glShaderSource(m_uVertexShader, 1, &szTemp, NULL);glCompileShader( m_uVertexShader );


after that I query the success of the compile with glGetShaderiv( m_uVertexShader, GL_COMPILE_STATUS, &iResult ) which returns GL_FALSE :(

But when I want to retrieve the log information of the shader with glGetShaderInfoLog(m_uVertexShader, 1, &iLength, szInfo) then iLength is 0 - so my log is empty...

what I know for certain is that the file is read correctly with ReadTextFile().

I also tried switching to the ARB-methods - same result...

I hope someone has some hints for me on how to proceed in my error-investigation from here on...

P.S.:
I'm on a MacBook (Late 2008 ) with a GeForce 9400M and OSX 10.6. I use OpenGL with XCode in an SDL-created window.
karwosts
karwosts
I think you have a problem with your glGetShaderInfoLog call, the second argument. This is supposed to be the maximum length that you want to retrieve from the info log, and you are saying: "I'd only like to retrieve one byte from the info log". This is to prevent opengl from overwriting the end of the char array you supply as the last argument.

The length that is returned is the length read (excluding null character), so I think your log is only returning a null character. Try this instead:

int infologlength;glGetShader(m_uVertexShader, GL_INFO_LOG_LENGTH, &infologlength);char* szInfo = new char[infologlength];glGetShaderInfoLog(m_uVertexShader, infologlength, &iLength, szInfo);
[size=2]My Projects:
[size=2]Portfolio Map for Android - Free Visual Portfolio Tracker
[size=2]Electron Flux for Android - Free Puzzle/Logic Game
painofangels
painofangels
whooops - you're right^^
But actually I already had this correct initially - must have accidently changed a "1024" to a "1" in the argument list...
Good, now I'm getting the error information I used to get earlier:

ERROR: 0:1: '' :  Version number not supported by GL2ERROR: 0:3: 'Transformation' : syntax error syntax errorERROR: Parser found no code to compile in source strings.


I assumed that I had something wrong with glShaderSource() - since the last error "found no code to compile.." and the first error " "" : Version number not..." but the char array I pass to the procedure definitively contains my entire sourcecode - even terminated by a "\0" ( I read a missing null-termination also causes problems with glShaderSource() )


karwosts
karwosts
This seems pretty clear to me: "Version number not supported by GL2"

Are you sure that your hardware supports this version of glsl? You can check the current version of your hardware with glGetString(GL_SHADING_LANGUAGE_VERSION).
[size=2]My Projects:
[size=2]Portfolio Map for Android - Free Visual Portfolio Tracker
[size=2]Electron Flux for Android - Free Puzzle/Logic Game

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.