Results 1 to 5 of 5

Thread: delphi 2009 string vs opengl shader commands

  1. #1

    delphi 2009 string vs opengl shader commands

    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.
    Code:
    procedure TGLSLProgram.SetF(aname: string; arg: GLFloat);
    begin
     glUniform1fARB(glGetUniformLocationARB(FProgramObject, @aname ), arg);
    end;
    But when is use the variable name directly here:
    Code:
    procedure TGLSLProgram.SetF(aname: string; arg: GLFloat);
    begin
     glUniform1fARB(glGetUniformLocationARB(FProgramObject, '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 :-(
    http://3das.noeska.com - create adventure games without programming

  2. #2

    Re: delphi 2009 string vs opengl shader commands

    Try
    [pascal]
    procedure TGLSLProgram.SetF(aname: string; arg: GLFloat);
    begin
    glUniform1fARB(glGetUniformLocationARB(FProgramObj ect, pchar(aname) ), arg);
    end;
    [/pascal]
    Peregrinus, expectavi pedes meos in cymbalis
    Nullus norvegicorum sole urinat

  3. #3

    Re: delphi 2009 string vs opengl shader commands

    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:
    Code:
    procedure TGLSLProgram.SetF(aname: PGLcharARB; arg: GLFloat);
    begin
     glUniform1fARB(glGetUniformLocationARB(FProgramObject, 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:
    Code:
    procedure TGLSLProgram.SetF(aname: string; arg: GLFloat);
    begin
     glUniform1fARB(glGetUniformLocationARB(FProgramObject, PGLcharARB(aname) ), arg);
    end;
    Sigh ....
    http://3das.noeska.com - create adventure games without programming

  4. #4

    Re: delphi 2009 string vs opengl shader commands

    Ok final working version:
    Code:
    procedure TGLSLProgram.SetF(aname: string; arg: GLFloat);
    begin
     glUniform1fARB(glGetUniformLocationARB(FProgramObject, PGLcharARB(ansistring(aname)) ), arg);
    end;
    http://3das.noeska.com - create adventure games without programming

  5. #5

    Re: delphi 2009 string vs opengl shader commands


    you can use builtin delphi types aswell;

    Code:
    procedure TGLSLProgram.SetF(aname: string; arg: GLFloat);
    begin
     glUniform1fARB(glGetUniformLocationARB(FProgramObject, 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.



    Amnoxx

    Oh, and this code appears to be an approximate replacement for return(random() & 0x01);

    Phoenix Wiki
    http://www.phoenixlib.net/

    Phoenix Forum
    http://www.pascalgamedevelopment.com/viewforum.php?f=71

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •