Raydium 3D Game Engine

Official forum for everything about Raydium, ManiaDrive, MeMak, ...
It is currently Thu Mar 28, 2024 11:50 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Thu Oct 02, 2008 12:27 am 
Offline

Joined: Wed Oct 01, 2008 11:53 pm
Posts: 6
Hello People,
i made simple pascal wrapper for raydium. I want extend it when i can solve the following problem. I wrote the skel.c example from raydium-sdk in pascal. Its same as your skel.c. When i load 'cocorobix.tri' my program, it crashes with "division by zero"-Exception occured by "raydium_normal_generate_lastest_tangent" in raydium.dll. I can load other *.tri's like paradise.tri, hills.tri but some other .tri's crashes too with same error. I put my programm and your skel.exe in the same bin folder "\raydium\bin". Api-example can load "cocorobix.tri" without error but my proggi crashes. Are you know where the error is? Look program-code for error position.

My system is: WinXP-Prof Sp3, AMD64AX2, Geforce Go 6100, 1GB Ram,

Here my program:
Code:
// pascalversion von skel.c programm
program r4p;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Classes
  { you can add units after this }, raydium;

procedure Display;
begin
  //Keyboard and Joystick don't needed yet
  //..

  //* [ place your camera here ] */
  raydium_camera_look_at(10,-2,2,0,0,0);
  //* [ draw here ] */
  raydium_ode_draw_all(0);
  raydium_rendering_finish;
end;

var trifilename: pchar;
begin
 //usage: r4p trifilename
 if paramcount>0 then trifilename:=PChar(ParamStr(1)) else trifilename:='cocorobix.tri';

 raydium_init_args_hack(argc,argv); //achtung manchmal wird in dll auch als raydium_init_args verwendet
 raydium_window_create(640,480,RAYDIUM_RENDERING_WINDOW,'FreePascal');

 raydium_texture_filter_change(RAYDIUM_TEXTURE_FILTER_TRILINEAR);
 raydium_window_view_perspective(60,0.01,2500); // fov 60 + near and far planes

 raydium_fog_disable();
 raydium_light_enable();
 raydium_light_on(0);

 raydium_light_conf_7f(0,50,150,200,1000000,1,0.9,0.7); // id, pos, intensity and color (RGB)
 raydium_background_color_change(1,0.9,0.7,1);

 raydium_sky_box_cache();


 //Program runs until here correct!
 //intern "raydium_normal_generate_lastest_tangent" function called by
 //"raydium_ode_ground_set_name" creates Division By Zero-exception
 //raydium_ode_ground_set_name(pchar('cocorobix.tri')); //cocorobix.tri
 raydium_ode_ground_set_name(trifilename);

 writeln('TEST:entering callback');

 raydium_callback(@display);

end.


raydium-wrapper:
Code:
unit raydium;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils;

// EIGENE TYPEN
const
  RaydiumLib = 'raydium.dll';

// OPENGL SPEZIFISCH *******************************************************
type
  //from raydium/codeblocks/mingw/include/gl/gl.h
  GLfloat= Single; //typedef float           GLfloat;        /* single precision float */
  GLuint = Longword; //Cardinal //typedef unsigned int    GLuint;         /* 4-byte unsigned */

//RAYDIUM SPEZIFISCH *******************************************************
 {ShortInt= signed char}
const
  RAYDIUM_RENDERING_WINDOW           = 0;  //raydium_window_create(..;rendering;...
  RAYDIUM_RENDERING_FULLSCREEN       = 1;
  RAYDIUM_RENDERING_NONE             = 2;

  RAYDIUM_TEXTURE_FILTER_NONE        = 0; //für raydium_texture_filter_change(filter)
  RAYDIUM_TEXTURE_FILTER_BILINEAR    = 1;
  RAYDIUM_TEXTURE_FILTER_TRILINEAR = 2;
  RAYDIUM_TEXTURE_FILTER_ANISO     = 3;



procedure raydium_init_args(argc : longint; argv: ppchar); cdecl; external RaydiumLib;
procedure raydium_init_args_hack(argc : longint; argv: ppchar); cdecl; external RaydiumLib; // in dll wird das benutzt
                     // void raydium_init_args(int argc, char * *argv)
procedure raydium_window_create(tx, ty:GLuint; rendering: ShortInt; name: PChar); cdecl; external RaydiumLib;
                    //void raydium_window_create (GLuint tx, GLuint ty, signed char rendering, char *name)

procedure raydium_texture_filter_change(filter:GLuint); cdecl; external RaydiumLib;
                    //void raydium_texture_filter_change (GLuint filter):
procedure raydium_window_view_perspective(fov, fnear, ffar: GLfloat); cdecl; external RaydiumLib;
                    //void raydium_window_view_perspective(GLfloat fov, GLfloat fnear, GLfloat ffar):

procedure raydium_fog_enable();cdecl; external RaydiumLib;
                    //void raydium_fog_enable (void):
procedure raydium_fog_disable(); cdecl; external RaydiumLib;
                    //void raydium_fog_disable (void):
//light.h
procedure raydium_light_enable(); cdecl; external RaydiumLib;
                    //void raydium_light_enable(void)
procedure raydium_light_on(l : GLuint); cdecl; external RaydiumLib;
                    //void raydium_light_on(GLuint l)
procedure raydium_light_off(l : GLuint); cdecl; external RaydiumLib;
                    //void raydium_light_off(GLuint l)
procedure raydium_light_switch(l : GLuint); cdecl; external RaydiumLib;
                    //void raydium_light_switch(GLuint l)
procedure raydium_light_conf_7f(l :GLuint; px, py, pz, intensity, r, g, b:GLfloat); cdecl; external RaydiumLib;
                    //void raydium_light_conf_7f(GLuint l,GLfloat px, GLfloat py, GLfloat pz, GLfloat intensity, GLfloat r, GLfloat g, GLfloat b)
//background.h
procedure raydium_background_color_change (r, g, b, a: GLfloat); cdecl; external RaydiumLib;
                    //void raydium_background_color_change (GLfloat r, GLfloat g, GLfloat b, GLfloat a);
//sky.h
procedure raydium_sky_box_cache(); cdecl; external RaydiumLib;
                    //void raydium_sky_box_cache (void);
//callback.h
procedure raydium_callback (loop : Pointer); cdecl; external RaydiumLib;
                    //void raydium_callback (void (*loop));
//clear.h
procedure raydium_clear_frame(); cdecl; external RaydiumLib;
                    //void raydium_clear_frame (void);
//camera.h
procedure raydium_camera_look_at(x, y, z, x_to, y_to, z_to :GLfloat); cdecl; external RaydiumLib;
                    //void raydium_camera_look_at (GLfloat x, GLfloat y, GLfloat z, GLfloat x_to, GLfloat y_to, GLfloat z_to);
//ode.h
procedure raydium_ode_ground_set_name(name: PChar); cdecl; external RaydiumLib;
                    //void raydium_ode_ground_set_name (char *name);
procedure raydium_ode_draw_all(names :ShortInt); cdecl; external RaydiumLib;
                    //void raydium_ode_draw_all (signed char names);
//render.h
procedure raydium_rendering_finish(); cdecl; external RaydiumLib;
                    //void raydium_rendering_finish (void);
implementation

end.


Debug-Output from my program with "cocorobix.tri" . It crashes.
Code:
\raydium\bin>r4p.exe
Raydium: Raydium 3D Game Engine
Raydium: version 0.800
Raydium: command line args: OK
Raydium: chdir to 'D:\AppDev\raydium\bin\': OK
Raydium: using 'C:\Dokumente und Einstellungen\Suny/.raydium' as home dir
Raydium: Requesting 640x480:32 mode
Raydium: Found 640x480 with 32 bpp color and 24 bits zbuffer (stencil is 8)
Raydium: using GeForce Go 6100/PCI/SSE2/3DNOW!, from NVIDIA Corporation (version 2.0.1)
Raydium: Signal Handlers: OK
Raydium: OpenGL extensions: OK
Raydium: Platform "4xfloat" vector size is: 16 byte(s) long
Raydium: OpenGL implementation maximum texture size: 4096x4096
Raydium: OpenGL hardware providing 4 texture unit(s), Raydium deals with 4
Raydium: OpenGL anisotropy max level is 16.00
Raydium: OpenGL texture compression available
Raydium: vertex arrays memory: OK
Raydium: path: OK
Raydium: keyboard: OK
Raydium: mouse: OK
Raydium: Joystick 0 not connected
Raydium: sound: Buffer creation successfull
Raydium: sound: OK, using 'Generic Software'
Raydium: PHP R3S Scripts: ../raydium/rayphp
Raydium: PHP support: OK
Raydium: atexit functions: OK
Raydium: lights: OK
Raydium: fog: OK
Raydium: Sky: OK
Raydium: objects: OK
Raydium: network: OK
Raydium: timecall: win32 modulo every 19.98 minutes, modulodiv is 2^0
Raydium: timer: detection: 1 iterations: diff: 8 steps (3579545/sec)
Raydium: timecall: method accuracy = 0.002 ms (447443.13 Hz)
Raydium: timecall: Using basic gettimeofday() method
Raydium: timecall: OK (447443 Hz)
Raydium: timecall: softcall 0: 1 Hz (3579545 clocks interval)
Raydium: particle: OK
Raydium: gui: OK
Raydium: video (live): OK
Raydium: shadow: OK
Raydium: HDR: OK
Raydium: shaders: OK (version 1.10 NVIDIA via Cg 1.3 compiler)
Raydium: webserver: OK
Raydium: Raydium engine reseted to original state
Raydium: timecall: callback 1: 400 Hz (8948 clocks interval)
Raydium: physics: ODE Net: 10 element(s)/packet
Raydium: physics: OK
Raydium: RegAPI: OK
Raydium: Engine is now ready.
    -----------------------------------------------------------
Raydium: Texture num 1 (BOXfront.tga) loaded: 512x512, 3 Bpp (b0 lm0 hdr0 f1)
Raydium: Texture num 2 (BOXback.tga) loaded: 512x512, 3 Bpp (b0 lm0 hdr0 f1)
Raydium: Texture num 3 (BOXleft.tga) loaded: 512x512, 3 Bpp (b0 lm0 hdr0 f1)
Raydium: Texture num 4 (BOXright.tga) loaded: 512x512, 3 Bpp (b0 lm0 hdr0 f1)
Raydium: Texture num 5 (BOXbottom.tga) loaded: 512x512, 3 Bpp (b0 lm0 hdr0 f1)
Raydium: Texture num 6 (BOXtop.tga) loaded: 512x512, 3 Bpp (b0 lm0 hdr0 f1)
Raydium: Object: loading "cocorobix.tri", version 1
Raydium: Texture num 7 (ground.tga) loaded: 256x256, 3 Bpp (b0 lm0 hdr0 f1)
Raydium: Texture num 8 (t_circuit-2f.tga) loaded: 2048x1024, 3 Bpp (b0 lm0 hdr0 f0)

An unhandled exception occurred at $6C888563 :
EDivByZero : Division by zero
  $6C888563 of raydium.pas
  $6C888BA4 of raydium.pas
  $6C89B0DD of raydium.pas
  $6C89CD31 of raydium.pas
  $6C8A1FF5 of raydium.pas
  $0040171E  main,  line 50 of r4p.lpr
The exception created by:
"raydium_normal_generate_lastest_tangent" - function


Debug-Output from my skel.c with "cocorobix.tri". Working good.
Code:
\raydium\bin>skel.exe
Raydium: Raydium 3D Game Engine
Raydium: version 0.800
Raydium: command line args: OK
Raydium: chdir to './': OK
Raydium: using 'C:\Dokumente und Einstellungen\Suny/.raydium' as home dir
Raydium: Requesting 640x480:32 mode
Raydium: Found 640x480 with 32 bpp color and 24 bits zbuffer (stencil is 8)
Raydium: using GeForce Go 6100/PCI/SSE2/3DNOW!, from NVIDIA Corporation (versio
 2.0.1)
Raydium: Signal Handlers: OK
Raydium: OpenGL extensions: OK
Raydium: Platform "4xfloat" vector size is: 16 byte(s) long
Raydium: OpenGL implementation maximum texture size: 4096x4096
Raydium: OpenGL hardware providing 4 texture unit(s), Raydium deals with 4
Raydium: OpenGL anisotropy max level is 16.00
Raydium: OpenGL texture compression available
Raydium: vertex arrays memory: OK
Raydium: path: OK
Raydium: keyboard: OK
Raydium: mouse: OK
Raydium: Joystick 0 not connected
Raydium: sound: Buffer creation successfull
Raydium: sound: OK, using 'Generic Software'
Raydium: PHP R3S Scripts: ../raydium/rayphp
Raydium: PHP support: OK
Raydium: atexit functions: OK
Raydium: lights: OK
Raydium: fog: OK
Raydium: Sky: OK
Raydium: objects: OK
Raydium: network: OK
Raydium: timecall: win32 modulo every 19.98 minutes, modulodiv is 2^0
Raydium: timer: detection: 1 iterations: diff: 7 steps (3579545/sec)
Raydium: timecall: method accuracy = 0.002 ms (511363.57 Hz)
Raydium: timecall: Using basic gettimeofday() method
Raydium: timecall: OK (511363 Hz)
Raydium: timecall: softcall 0: 1 Hz (3579545 clocks interval)
Raydium: particle: OK
Raydium: gui: OK
Raydium: video (live): OK
Raydium: shadow: OK
Raydium: HDR: OK
Raydium: shaders: OK (version 1.10 NVIDIA via Cg 1.3 compiler)
Raydium: webserver: OK
Raydium: Raydium engine reseted to original state
Raydium: timecall: callback 1: 400 Hz (8948 clocks interval)
Raydium: physics: ODE Net: 10 element(s)/packet
Raydium: physics: OK
Raydium: RegAPI: OK
Raydium: Engine is now ready.
         -----------------------------------------------------------
Raydium: Texture num 1 (BOXfront.tga) loaded: 512x512, 3 Bpp (b0 lm0 hdr0 f1)
Raydium: Texture num 2 (BOXback.tga) loaded: 512x512, 3 Bpp (b0 lm0 hdr0 f1)
Raydium: Texture num 3 (BOXleft.tga) loaded: 512x512, 3 Bpp (b0 lm0 hdr0 f1)
Raydium: Texture num 4 (BOXright.tga) loaded: 512x512, 3 Bpp (b0 lm0 hdr0 f1)
Raydium: Texture num 5 (BOXbottom.tga) loaded: 512x512, 3 Bpp (b0 lm0 hdr0 f1)
Raydium: Texture num 6 (BOXtop.tga) loaded: 512x512, 3 Bpp (b0 lm0 hdr0 f1)
Raydium: Object: loading "cocorobix.tri", version 1
Raydium: Texture num 7 (ground.tga) loaded: 256x256, 3 Bpp (b0 lm0 hdr0 f1)
Raydium: Texture num 8 (t_circuit-2f.tga) loaded: 2048x1024, 3 Bpp (b0 lm0 hdr0
f0)
Raydium: shadow: ground (0) modelsize is 52.23, center factors : 0.50/0.50
Raydium: Object: creating display list for object cocorobix.tri
Raydium: timecall: warning: time modulo detected: workarounding
Raydium: timecall: warning: time modulo detected: workarounding
Raydium: Internal buffers:
Raydium: -----------------
Raydium: Total of 28386 vertex(s) loaded:
Raydium: Texture 1: 0 vert, as "BOXfront.tga" (1.33 MB)
Raydium: Texture 2: 0 vert, as "BOXback.tga" (1.33 MB)
Raydium: Texture 3: 0 vert, as "BOXleft.tga" (1.33 MB)
Raydium: Texture 4: 0 vert, as "BOXright.tga" (1.33 MB)
Raydium: Texture 5: 0 vert, as "BOXbottom.tga" (1.33 MB)
Raydium: Texture 6: 0 vert, as "BOXtop.tga" (1.33 MB)
Raydium: Texture 7: 0 vert, as "ground.tga" (0.33 MB)
Raydium: Texture 8: 28386 vert, as "t_circuit-2f.tga" (10.67 MB)
Raydium: Estimated total: 19.00 MB used for textures.
Raydium: Using 1 object(s):
Raydium: Object 0: 28386 vert, as "cocorobix.tri"
Raydium: sound: Deleting sources
Raydium: sound: Deleting buffers
Raydium: sound: Releasing OpenAL
Raydium: path: read: "C:\Dokumente und Einstellungen\Suny/.raydium/data"
Raydium: path: write: "C:\Dokumente und Einstellungen\Suny/.raydium/data"


Debug-Output from my program with "paradise.tri" . It's working good :).
Code:
\raydium\bin>r4p.exe paradise.tri
Raydium: Raydium 3D Game Engine
Raydium: version 0.800
Raydium: command line args: OK
Raydium: chdir to 'D:\AppDev\raydium\bin\': OK
Raydium: using 'C:\Dokumente und Einstellungen\Suny/.raydium' as home dir
Raydium: Requesting 640x480:32 mode
Raydium: Found 640x480 with 32 bpp color and 24 bits zbuffer (stencil is 8)
Raydium: using GeForce Go 6100/PCI/SSE2/3DNOW!, from NVIDIA Corporation (version 2.0.1)
Raydium: Signal Handlers: OK
Raydium: OpenGL extensions: OK
Raydium: Platform "4xfloat" vector size is: 16 byte(s) long
Raydium: OpenGL implementation maximum texture size: 4096x4096
Raydium: OpenGL hardware providing 4 texture unit(s), Raydium deals with 4
Raydium: OpenGL anisotropy max level is 16.00
Raydium: OpenGL texture compression available
Raydium: vertex arrays memory: OK
Raydium: path: OK
Raydium: keyboard: OK
Raydium: mouse: OK
Raydium: Joystick 0 not connected
Raydium: sound: Buffer creation successfull
Raydium: sound: OK, using 'Generic Software'
Raydium: PHP R3S Scripts: ../raydium/rayphp
Raydium: PHP support: OK
Raydium: atexit functions: OK
Raydium: lights: OK
Raydium: fog: OK
Raydium: Sky: OK
Raydium: objects: OK
Raydium: network: OK
Raydium: timecall: win32 modulo every 19.98 minutes, modulodiv is 2^0
Raydium: timer: detection: 1 iterations: diff: 8 steps (3579545/sec)
Raydium: timecall: method accuracy = 0.002 ms (447443.13 Hz)
Raydium: timecall: Using basic gettimeofday() method
Raydium: timecall: OK (447443 Hz)
Raydium: timecall: softcall 0: 1 Hz (3579545 clocks interval)
Raydium: particle: OK
Raydium: gui: OK
Raydium: video (live): OK
Raydium: shadow: OK
Raydium: HDR: OK
Raydium: shaders: OK (version 1.10 NVIDIA via Cg 1.3 compiler)
Raydium: webserver: OK
Raydium: Raydium engine reseted to original state
Raydium: timecall: callback 1: 400 Hz (8948 clocks interval)
Raydium: physics: ODE Net: 10 element(s)/packet
Raydium: physics: OK
Raydium: RegAPI: OK
Raydium: Engine is now ready.
    -----------------------------------------------------------
Raydium: Texture num 1 (BOXfront.tga) loaded: 512x512, 3 Bpp (b0 lm0 hdr0 f1)
Raydium: Texture num 2 (BOXback.tga) loaded: 512x512, 3 Bpp (b0 lm0 hdr0 f1)
Raydium: Texture num 3 (BOXleft.tga) loaded: 512x512, 3 Bpp (b0 lm0 hdr0 f1)
Raydium: Texture num 4 (BOXright.tga) loaded: 512x512, 3 Bpp (b0 lm0 hdr0 f1)
Raydium: Texture num 5 (BOXbottom.tga) loaded: 512x512, 3 Bpp (b0 lm0 hdr0 f1)
Raydium: Texture num 6 (BOXtop.tga) loaded: 512x512, 3 Bpp (b0 lm0 hdr0 f1)
Raydium: Object: loading "paradise.tri", version 1
Raydium: Texture num 7 (ground.tga) loaded: 256x256, 3 Bpp (b0 lm0 hdr0 f1)
Raydium: Texture num 8 (paradise_island.tga) loaded: 512x512, 3 Bpp (b0 lm0 hdr0 f0)
Raydium: Texture num 9 (paradise_ground.tga) loaded: 64x64, 3 Bpp (b0 lm0 hdr0 f0)
Raydium: shadow: ground (0) modelsize is 133.28, center factors : 0.46/0.49
Raydium: Object: creating display list for object paradise.tri


Last edited by sunji on Thu Oct 02, 2008 1:23 pm, edited 1 time in total.

Top
 Profile  
 
PostPosted: Thu Oct 02, 2008 7:25 am 
Offline

Joined: Tue Jul 08, 2008 2:37 am
Posts: 181
Hi sunji,

welcome to the forum oder besser gesagt, willkommen im Forum. ;)

Nice to see someone from the pascal world here! :D
FreePascal is also my favorite Pascal compiler, I've done some little projects with it some time ago, must be before the initial 2.0 release with version 1.0.10 and perhaps at the beginnings of the FPC 2.0 version. I've worked mostly under GNU/Linux these days.

Perhaps the following document may be of interest for you. Look out: "How to use C code in Free Pascal projects". :roll:

I haven't installed FPC on my system yet, but I'll try to reproduce this behavior of your issue as soon as possible.
Thanks for working on this Raydium wrapper for FPC! Perhaps this project will extend to some ready to use Raydium classes, which internally access the Raydium registered functions within the wrapper functions, but lets solve this issue first before talking about further features.

Best regards,
st


Last edited by st on Wed Feb 15, 2012 6:45 pm, edited 1 time in total.

Top
 Profile  
 
PostPosted: Thu Oct 02, 2008 9:15 am 
Offline

Joined: Tue Jul 08, 2008 2:37 am
Posts: 181
I've installed FPC version 2.2.2 on my system. You are running into an arithmetic exception (SIGFPE), because of an unexpected type overflow (man signal under *nix for more information). Please try the following...

Use the "official" header files from FreePascal instead of your own type declarations in the Raydium wrapper.
Remove the current OpenGL types and add the GL header that comes with FreePascal (GL.pp).

This should than look something like this in the Raydium.pp file:
Code:
uses Classes, SysUtils, GL;


Top
 Profile  
 
PostPosted: Thu Oct 02, 2008 1:19 pm 
Offline

Joined: Wed Oct 01, 2008 11:53 pm
Posts: 6
uses Classes, SysUtils, GL; <-That is it!
I used yet GLfloat and GLuint from GL-Unit and commented my definitions out. It runs! :lol: :lol:
Thank you Sebastian! danke, danke, danke!
I can continue with complete the wrapper. I will make it usable for freepascal and delphi too. I can write programs in C/C++ but my favorite language is pascal.
Is this engine fast enough? I don't see any complex example to compare it with others.

I put win-executable of my program to attachment.


Attachments:
File comment: You can load *.tri files. Put in your raydium\bin folder. Usage: r4p.exe yourtrifile.tri
r4p.zip [67.67 KiB]
Downloaded 539 times
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 28 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group