PDA

View Full Version : Sort'a starting GLSL



M/\dm/\n
02-19-2004, 05:39 AM
I've one shader up and running, but I still can't figure out how to bind samplers to fp. Documentation is still messy & I didn't noticed any PFNGS that included sampler in'em.
BTW, is there some sort of offline compiler to check is the program valid. Spent 8 hours till I realized that the problem is in my shading code http://www.opengl.org/discussion_boards/ubb/frown.gif

PanzerSchreck
02-19-2004, 08:05 AM
You need glUniform1iARB to tell the sampler what TMU to access :


glUniform1iARB(glGetUniformLocationARB(ProgramObje ct, PGLCharARB('mysampler')), 1);


As for checking the program, this function will give a any error-messages that can happen. How detailed they are is depending on your glSlang-Implementation :


function glSlang_GetInfoLog(glObject : GLHandleARB) : String;
var
blen,slen : GLInt;
InfoLog : PGLCharARB;
begin
glGetObjectParameterivARB(glObject, GL_OBJECT_INFO_LOG_LENGTH_ARB , @blen);
if blen > 1 then
begin
GetMem(InfoLog, blen*SizeOf(GLCharARB));
glGetInfoLogARB(glObject, blen, slen, InfoLog);
Result := PChar(InfoLog);
Dispose(InfoLog);
end;
end;

Ostsol
02-19-2004, 07:40 PM
For the Pascal illiterate (untested code). . .



char* glSlang_GetInfoLog (GLHandleARB glObject)
{
GLint blen, slen;
GLcharARB *InfoLog;

glGetObjectParameterivARB (glObject, GL_OBJECT_INFO_LOG_LENGTH_ARB , &blen);

if blen > 1 then
{
InfoLog = (GLcharARB*) malloc (sizeof (GLcharARB) * blen);

glGetInfoLogARB (glObject, blen, slen, InfoLog);

return InfoLog;
}
}