, or it is somehow getting initialised properly and it can't find the uniform, which is a 2D sampler.
1. It was so NICE of them to declare GLcharARB = Char; PGLcharARB = ^GLcharARB; when Char could be UnicodeChar and OpenGL *only* understands 8-bit strings.
2. It's capricious. Try
Code:
glGetUniformLocation(<program>, PAnsiChar(RawByteString('my_uniform_name'#0)));
3. It can return -1 if your uniform was not used and the GLSL compiler eliminated it.
P.S. I always play it overly safe using wrappers like this one:
Code:
class function TGAPI.SafeGetUniformLocation(prog: GLuint; name: RawByteString): GLint;
var
error: UnicodeString;
begin
try
case Mother^.GAPI.Mode of
{$ifndef glesonly}
gapi_GL21,
{$endif glesonly}
gapi_GLES2: begin
Result:= glGetUniformLocation(prog, PAnsiChar(name + #0));
CheckGLError(true);
end;
else
DieUnsupportedGLMode;
end;
except
Die(RuEn(
'Не удалось получить расположение постоянной %1 для программы %0',
'Failed to get uniform %1 location for program %0'
), [prog, name]);
end;
end;
where
Code:
procedure CheckGlError(DieAnyway: boolean);
var ec: GLenum;
begin
{$if defined(cpuarm) and not defined(debug)}
//Raspberry Pi
//some shit of a driver spams console with "glGetError 0x500"
// thus bringing FPS to its knees
if not DieAnyway then Exit;
{$endif}
ec:= glGetError();
if ec <> 0 then
if DieAnyway or Mother^.Debug.StopOnOpenGlErrors
then Die(RuEn(
'Ошибка OpenGL, %0',
'OpenGL error, %0'
),
[GlErrorCodeToString(ec)])
else
if Mother^.Debug.Verbose then AddLog(RuEn(
'Ошибка OpenGL, %0',
'OpenGL error, %0'
),
[GlErrorCodeToString(ec)]);
end;
-- flying over paranoiac's nest
Bookmarks