Results 1 to 6 of 6

Thread: Bug with JEDI-SDL and lighting

  1. #1

    Bug with JEDI-SDL and lighting

    Ok, i've this nasty bug. I have a program with JEDI-SDL and OpenGL, running on windows and linux.
    The bug happends only when i compile the program on windows with FPC (any 1.9.x version). With Delphi or on linux (both kylix and fpc) the bug disappears.
    The problem is that when i try to render anything with GL_LIGHTING turned on, i have a EDivByZero exception. The exception starts inside OpenGl code, so i can't track it.
    If i render with GL_LIGHTING disabled than it runs fine.
    This happends almost in any program, for example it happends on lesson7 of JEDI-SDL version NeHe.

    I've come to the conclusion that (maybe) it could be a bug in FPC for which it passes some malformed data to OpenGl (wich pass silently) but when rendering it gets DivByZero.

    Anyone experienced this too ? If it's needed i'll post executables this evening.

    Here's the output:
    An unhandled exception occurred at 0x08AD2593 :
    EDivByZero : Division by zero
    $08AD2593
    $0896A4A4
    $00080100
    $18FF3635
    An unhandled exception occurred at 0x004156DA :
    EAccessViolation : Access violation
    $004156DA
    $00416B84
    $0006FF44
    $0896A4A4
    $00080100
    $24FF1C1B
    An unhandled exception occurred at 0x004156DA :
    EAccessViolation : Access violation
    $004156DA
    $00416B84
    $0006FCD4
    $00416B84
    $0006FF44
    $0896A4A4
    $00080100
    $24FF1C1B
    An unhandled exception occurred at 0x004156DA :
    EAccessViolation : Access violation
    $004156DA
    $00416B84
    $0006FA64
    $00416B84
    $0006FCD4
    $00416B84
    $0006FF44
    $0896A4A4
    $00080100
    $24FF1C1B
    If you save your data in a proprietary format, the owner of the format owns your data.
    <br /><A href="http://msx80.blogspot.com">http://msx80.blogspot.com</A>

  2. #2

    Bug with JEDI-SDL and lighting

    Do you mask FPU exceptions? Try adding this code to one of your units.

    [pascal]var
    Saved8087CW: Word;

    {$ifdef FPC} //FPC do not have this function in its RTL
    const
    Default8087CW = $1332; //according to the FPC site it's the value used in the
    //startup code.
    procedure Set8087CW( value :word ); Assembler;
    asm
    FLDCW value
    end;
    {$endif}


    initialization
    { Save the current FPU state and then disable FPU exceptions }
    Saved8087CW := Default8087CW;
    Set8087CW($133f); { Disable all fpu exceptions }

    finalization
    { Reset the FPU to the previous state }
    Set8087CW(Saved8087CW);[/pascal]

  3. #3

    Bug with JEDI-SDL and lighting

    I can't compile, it says:
    TestUnit.pas(19,11) Error: Asm: [fldcw reg16] invalid combination of opcode and
    operands
    TestUnit.pas(33,1) Fatal: There were 1 errors compiling module, stopping
    Is there some compiler directive to enable somewhere ?

    BTW What does this code do? And is it already present in Delphi ? And about Linux ?

    Thanks!
    If you save your data in a proprietary format, the owner of the format owns your data.
    <br /><A href="http://msx80.blogspot.com">http://msx80.blogspot.com</A>

  4. #4

    Bug with JEDI-SDL and lighting

    Ok, i've found by myself.. Btw Savege had the same problem Thank you savage

    It now works with light. I still don't understand why is this needed.. Does Opengl continuosly rise error on the FPU ?

    Btw now i have the same problem when i exit from the program... meybe restoring the value can cause the error?
    If you save your data in a proprietary format, the owner of the format owns your data.
    <br /><A href="http://msx80.blogspot.com">http://msx80.blogspot.com</A>

  5. #5

    Bug with JEDI-SDL and lighting

    Hi MSX, I thought I had some floating point switch code in one the JEDI-SDL units that worked with Delphi and FPC. I will have to check it when I get home.
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  6. #6

    Bug with JEDI-SDL and lighting

    That code was copied from fmod.pas. I believe it was Dominique who added the FPC code into it.

    Borland compilers do not mask FPU exceptions by default. Microsoft compilers do. When working with 3D APIs such as Direct3D and OpenGL, it is often helpful to mask FPU exceptions.

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
  •