Page 1 of 4 123 ... LastLast
Results 1 to 10 of 33

Thread: OpenGL command crashing under Lazarus but not Dephi 5

  1. #1

    OpenGL command crashing under Lazarus but not Dephi 5

    Hi all, I use the ScreenToWorld method (below) like so:

    Method using code
    Code:
    Begin
    {...}
            p0 := ScreenToWorld(FMousePosX,FMousePosY,0);
            p1 := ScreenToWorld(FMousePosX,FMousePosY,1);
    {...}
    End;
    Method being used
    Code:
    Function  TAbaloneGL.ScreenToWorld(AScreenX, AScreenY, AScreenZ : GLdouble) : TVector3f;
    Var
        Viewport : TViewPortArray;
        MVMat    : T16dArray;
        PJMat    : T16dArray;
        ObjX     : GLdouble;
        ObjY     : GLdouble;
        ObjZ     : GLdouble;
    Begin
        // Retrieves the viewport
        glGetIntegerv(GL_VIEWPORT, @Viewport);
        // Retrieve the matrices
        glGetDoublev(GL_MODELVIEW_MATRIX, @MVMat[0]);
        glGetDoublev(GL_PROJECTION_MATRIX, @PJMat[0]);
        
        // Unproject screen coordinates
        gluUnProject(
            AScreenX,
            Viewport[3] - AScreenY,
            AScreenZ,
            MVMat, PJMat, Viewport,
            @ObjX, @ObjY, @ObjZ);
            
        Result := V3(ObjX, ObjY, ObjZ);
    End;

    This works just find under Delphi 5 without any issues, but when I compile and run it using Lazarus (latest version 0.9.1, it crashes on the gluUnProject line with an access violation

    If I run it through the debugger it gives this error:

    "Project raised exception class 'External: SIGSEGV"

    I can't seem to figure it out...

    PS I am using the GL.pas and GLU.pas files that come with JEDI-SDL if that helps...

    cheers,
    Paul.
    Games:
    Seafox


    Pages:
    Syntax Error Software itch.io page

    Online Chess
    http://gameknot.com/#paul_nicholls

  2. #2

    OpenGL command crashing under Lazarus but not Dephi 5

    This is strange. I have function like Yours and it runs ok. The only difference is that I have

    [pascal]
    glGetDoublev(GL_MODELVIEW_MATRIX, @MVMat);
    glGetDoublev(GL_PROJECTION_MATRIX, @PJMat);
    [/pascal]

    instead of

    [pascal]
    glGetDoublev(GL_MODELVIEW_MATRIX, @MVMat[0]);
    glGetDoublev(GL_PROJECTION_MATRIX, @PJMat[0]);
    [/pascal]

    But I don't know if this is the problem. If you were compiling on Linux, I would say that probably glu library is not loaded.

  3. #3

    OpenGL command crashing under Lazarus but not Dephi 5

    It's probably nothing to do with the actual OpenGL calls being made, but rather, with the link between Delphi/Lazerus and the opengl32.dll file.

    Normally these access violations also occur when you forget to bind the opengl functions in delphi with their external addresses in the DLL file.
    My site: DelphiTuts.com (coming soon)...

    Download Font Studio 4.21 here.

  4. #4

    OpenGL command crashing under Lazarus but not Dephi 5

    Quote Originally Posted by grudzio
    This is strange. I have function like Yours and it runs ok. The only difference is that I have

    [pascal]
    glGetDoublev(GL_MODELVIEW_MATRIX, @MVMat);
    glGetDoublev(GL_PROJECTION_MATRIX, @PJMat);
    [/pascal]

    instead of

    [pascal]
    glGetDoublev(GL_MODELVIEW_MATRIX, @MVMat[0]);
    glGetDoublev(GL_PROJECTION_MATRIX, @PJMat[0]);
    [/pascal]

    But I don't know if this is the problem. If you were compiling on Linux, I would say that probably glu library is not loaded.
    IIRC there is some difference either in Delphi and FPC or in static and dynamic arrays referenced by @X and @X[0]. It can give either address of first array element or address of dynamic array pointer. So you better verify this issue.

    And yes, it should not be related to OpenGL stuff at all, just to compilers.
    There are only 10 types of people in this world; those who understand binary and those who don't.

  5. #5

    OpenGL command crashing under Lazarus but not Dephi 5

    [quote="Nitrogen"]It's probably nothing to do with the actual OpenGL calls being made, but rather, with the ]

    I thought maybe that Lazarus/Freepascal wasn't calling the Initialization and Finalization sections of the GL and GLU pas files as breakpoints don't stop the program there.

    So I added the

    LoadOpenGL( GLLibName );
    LoadGLu( GLuLibName );

    and

    FreeGLu;
    FreeOpenGL

    calls around running the main program but it still crashes

    Any ideas?

    cheers,
    Paul.
    Games:
    Seafox


    Pages:
    Syntax Error Software itch.io page

    Online Chess
    http://gameknot.com/#paul_nicholls

  6. #6

    OpenGL command crashing under Lazarus but not Dephi 5

    Quote Originally Posted by Clootie
    Quote Originally Posted by grudzio
    This is strange. I have function like Yours and it runs ok. The only difference is that I have

    [pascal]
    glGetDoublev(GL_MODELVIEW_MATRIX, @MVMat);
    glGetDoublev(GL_PROJECTION_MATRIX, @PJMat);
    [/pascal]

    instead of

    [pascal]
    glGetDoublev(GL_MODELVIEW_MATRIX, @MVMat[0]);
    glGetDoublev(GL_PROJECTION_MATRIX, @PJMat[0]);
    [/pascal]

    But I don't know if this is the problem. If you were compiling on Linux, I would say that probably glu library is not loaded.
    IIRC there is some difference either in Delphi and FPC or in static and dynamic arrays referenced by @X and @X[0]. It can give either address of first array element or address of dynamic array pointer. So you better verify this issue.

    And yes, it should not be related to OpenGL stuff at all, just to compilers.
    I have tried both versions, with the [0] and without the [0] to no avail

    cheers,
    Paul.
    Games:
    Seafox


    Pages:
    Syntax Error Software itch.io page

    Online Chess
    http://gameknot.com/#paul_nicholls

  7. #7

    OpenGL command crashing under Lazarus but not Dephi 5

    what is the content of those variables? perhaps it is NAN or something similar, due to memory corruption, just check it out, ok?
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  8. #8

    OpenGL command crashing under Lazarus but not Dephi 5

    Quote Originally Posted by Delfi
    what is the content of those variables? perhaps it is NAN or something similar, due to memory corruption, just check it out, ok?
    Code:
    MVmat = {
     -1            ,1.86e-008,-1.56e-008,0,
      0             ,0.64        ,0.766       ,0,
      2.43e-008,0.766       ,-0.642     ,0,
      0            ,10            ,-400        ,1}
    
    
    PJMat = {
    1.81,0    ,0    ,0,
    0    ,2.41,0    ,0,
    0    ,0     ,-1.0,-1,
    0    ,0     ,02  ,0
    }
    I dunno if this helps...

    Paul.
    Games:
    Seafox


    Pages:
    Syntax Error Software itch.io page

    Online Chess
    http://gameknot.com/#paul_nicholls

  9. #9

    OpenGL command crashing under Lazarus but not Dephi 5

    Hi all,
    To try and track down the gluUnproject issue I am having, I have whipped up a minimal SDL Lazarus project that is available for download here (approximately 700Kb):

    http://abalonegl.eonclash.com/gluunproject_test.zip

    If someone could find the time to download and try the file it would be excellent. This issue is driving me nuts!!

    After downloading the zip file, build it in Lazarus (under windows), run it and see if the problem happens.

    When run, a SDL window opens up.

    Escape will close the program.
    Right-click in the window will attempt to call the gluUnproject routine via the ScreenToWorld() function and it should crash...

    If someone could help it would be great!

    Thanks

    cheers,
    Paul.
    Games:
    Seafox


    Pages:
    Syntax Error Software itch.io page

    Online Chess
    http://gameknot.com/#paul_nicholls

  10. #10

    OpenGL command crashing under Lazarus but not Dephi 5

    i can't debug it, it can't find any dlls and they are in same folder with the exe
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

Page 1 of 4 123 ... LastLast

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
  •