DGL
https://delphigl.com/forum/

delphi2009 string vs opengl shader commands problems
https://delphigl.com/forum/viewtopic.php?f=19&t=8861
Seite 1 von 1

Autor:  noeska [ Mo Dez 14, 2009 14:57 ]
Betreff des Beitrags:  delphi2009 string vs opengl shader commands problems

I am puzzled again with the new delphi string and the likes :-(
On calling a shader with parameters the actual parameter is never set.
Code:
  1. procedure TGLSLProgram.SetF(aname: string; arg: GLFloat);
  2. begin
  3.   glUniform1fARB(glGetUniformLocationARB(FProgramObject, @aname ), arg);
  4. end;


But when is use the variable name directly here:
Code:
  1. procedure TGLSLProgram.SetF(aname: string; arg: GLFloat);
  2. begin
  3.   glUniform1fARB(glGetUniformLocationARB(FProgramObject, 'test' ), arg);
  4. 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 :-(

Autor:  Coolcat [ Mo Dez 14, 2009 15:08 ]
Betreff des Beitrags:  Re: delphi2009 string vs opengl shader commands problems

I'm not a Delphi user, but google found this link which looks helpful:
http://compaspascal.blogspot.com/2008/1 ... ed-by.html

Maybe rawbytestring or utf8string?

Autor:  noeska [ Mo Dez 14, 2009 15:51 ]
Betreff des Beitrags:  Re: delphi2009 string vs opengl shader commands problems

Hmm, that only confuses me more ... (if only there was a way delphi2009 could behave like delphi always did on only support fancy string when needed)

Looking at the type of the command i came up with this:
Code:
  1. procedure TGLSLProgram.SetF(aname: PGLcharARB; arg: GLFloat);
  2. begin
  3.   glUniform1fARB(glGetUniformLocationARB(FProgramObject, aname ), arg);
  4. end;
And that works :-)

But i dont like using PGLcharARB in a class it want to use string or ansistring there. But again this does NOT work:
Code:
  1. procedure TGLSLProgram.SetF(aname: string; arg: GLFloat);
  2. begin
  3.   glUniform1fARB(glGetUniformLocationARB(FProgramObject, PGLcharARB(aname) ), arg);
  4. end;
Sigh ....

Autor:  noeska [ Mo Dez 14, 2009 16:02 ]
Betreff des Beitrags:  Re: delphi2009 string vs opengl shader commands problems

Ok final working version:
Code:
  1. procedure TGLSLProgram.SetF(aname: string; arg: GLFloat);
  2. begin
  3.   glUniform1fARB(glGetUniformLocationARB(FProgramObject, PGLcharARB(ansistring(aname)) ), arg);
  4. end;

Autor:  Lord Horazont [ Mo Dez 14, 2009 17:13 ]
Betreff des Beitrags:  Re: delphi2009 string vs opengl shader commands problems

Yep, the problem is, that the newer delphis use WideString instead of AnsiString when you just say "String". So if you explicitly need an AnsiString, you should tell this to Delphi. Probably even in the method declaration.

greetings

Seite 1 von 1 Alle Zeiten sind UTC + 1 Stunde
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/