PDA

View Full Version : new glsl need some basic simple help :)



noobscratcher
10-15-2011, 07:55 AM
hello


Okay so im already able to do alot with opengl such as alpha blending on texels, texture mapping of different image formats(tga,png,bmp) with sdl data i know the lot :).

What i dont know is how to work with GLSL :(


can you tell me how and why i can't get this to work ?


char maxlength = 100;
void glGetShaderInfoLog(GLuint shader,GLsizei maxlength, GLsizei length,GLchar *infoLog);


fprintf(stderr,infoLog);


your gonna wonder what and why :D perhaps...

and if so read this!

i'll explain i need the output of infoLog in a stderr text file now i have never come across anything like this for example the infoLog while using OpenGL so i'm curious to the hows and whys of this

so please do enlighten me on this subject and give me any pointers,tips, and help to solving this


thanks in advance


if you have any good tutorials for GLSL please provide some too i need as much help as i can get for this shader language of sorts :D

im pretty sure my code up there is messed up lol so please do give me any tips nicely

noobscratcher
10-15-2011, 01:31 PM
any help? :D

Dark Photon
10-15-2011, 05:10 PM
can you tell me how and why i can't get this to work ?


char maxlength = 100;
void glGetShaderInfoLog(GLuint shader,GLsizei maxlength, GLsizei length,GLchar *infoLog);
fprintf(stderr,infoLog);



glGetObjectParameterivARB( handle, GL_OBJECT_INFO_LOG_LENGTH_ARB, & maxlen );

char *log = new char[ maxlen ];
glGetInfoLogARB ( handle, maxlen, &length, log ) ;

if ( length > 0 && log[0] != '\0' )
fprintf( stderr, "%s\n", log ) ;

delete [] log;


Call this with a shader object after:



glGetShaderiv( handle, GL_COMPILE_STATUS, &compiled );


if it returns !compiled, and call this with a program object after:



glGetProgramiv ( handle, GL_LINK_STATUS, & linked );


and:



glGetProgramiv( handle, GL_VALIDATE_STATUS, & validated );


if they return !linked (or !validated).

noobscratcher
10-16-2011, 12:40 AM
thanks very much :D

noobscratcher
10-16-2011, 02:46 AM
im getting quite alot of declaration issues and i was just wondering how to declare inside a parameter or rather declare so it works within the code you gave me to learn from any ideas? iv looked at this site http://www.cplusplus.com/doc/tutorial/functions/ and have not found anything that has worked sorry to bug you, i would also like to ask why there is such a lack of information GLSL not to bash them or anything but its been very tuff to find information

ugluk
10-16-2011, 03:53 PM
Try this:


//////////////////////////////////////////////////////////////////////////////
std::string gl_get_shader_error(GLuint handle)
{
boost::scoped_array<GLchar> buffer;
GLint size;

if (glIsProgram(handle))
{
glGetProgramiv(handle, GL_INFO_LOG_LENGTH, &amp;size);
buffer.reset(new GLchar[size]);
glGetProgramInfoLog(handle, size, 0, buffer.get());
}
else if (glIsShader(handle))
{
glGetShaderiv(handle, GL_INFO_LOG_LENGTH, &amp;size);
buffer.reset(new GLchar[size]);
glGetShaderInfoLog(handle, size, 0, buffer.get());
}
else
{
BOOST_VERIFY(!"wrong program or shader handle provided");
}

return buffer.get();
}