PDA

View Full Version : delphi 2009 string vs opengl shader commands



noeska
14-12-2009, 01:54 PM
System: WindowsXP
Compiler/IDE: Delphi2009
Libraries/API: DglOpengl

I am puzzled again with the new delphi string and the likes :-(
On calling a shader with parameters the actual parameter is never set.

procedure TGLSLProgram.SetF(aname: string; arg: GLFloat);
begin
glUniform1fARB(glGetUniformLocationARB(FProgramObj ect, @aname ), arg);
end;

But when is use the variable name directly here:

procedure TGLSLProgram.SetF(aname: string; arg: GLFloat);
begin
glUniform1fARB(glGetUniformLocationARB(FProgramObj ect, 'test' ), arg);
end;

Then it does works.

But for now i am unable to provide a working type. String / AnsiString / PChar / PAnsiChar but none seem to work :-(

JSoftware
14-12-2009, 02:13 PM
Try

procedure TGLSLProgram.SetF(aname: string; arg: GLFloat);
begin
glUniform1fARB(glGetUniformLocationARB(FProgramObj ect, pchar(aname) ), arg);
end;

noeska
14-12-2009, 02:46 PM
Nope, that does not work as delphi 2009 starts to complain about pansichar and pchar not being the same thing and gives an compile error.

Looking at the type of the command i came up with this:

procedure TGLSLProgram.SetF(aname: PGLcharARB; arg: GLFloat);
begin
glUniform1fARB(glGetUniformLocationARB(FProgramObj ect, aname ), arg);
end; And that works :-)

But i dont like using PGLcharARB in a class it want to use string. But again this does NOT work:

procedure TGLSLProgram.SetF(aname: string; arg: GLFloat);
begin
glUniform1fARB(glGetUniformLocationARB(FProgramObj ect, PGLcharARB(aname) ), arg);
end; Sigh ....

noeska
14-12-2009, 03:01 PM
Ok final working version:

procedure TGLSLProgram.SetF(aname: string; arg: GLFloat);
begin
glUniform1fARB(glGetUniformLocationARB(FProgramObj ect, PGLcharARB(ansistring(aname)) ), arg);
end;

Andreaz
15-12-2009, 06:58 AM
you can use builtin delphi types aswell;




procedure TGLSLProgram.SetF(aname: string; arg: GLFloat);
begin
glUniform1fARB(glGetUniformLocationARB(FProgramObj ect, PAnsiChar(AnsiString(aname)) ), arg);
end;



I'm currently at work converting all my code to be compatible with Delphi 2009, alot of this small stuff.