next_inactive up previous


Raydium API Reference

Xfennec / CQFD Corp.

07/09/2002


Contents

1 Introduction

1.1 About

Well, first of all, let me talk about Raydium goals: this project aims to be simple, easy to use, portable, and quite fast.

Raydium is a C written abstract layer, on top of OpenGL, GLU and GLUT: this means you can write an entire 3D application without calling any OpenGL function. Want to draw an object ? call the suitable Raydium function, and all textures and vertices will be loaded, and your object drawn. Want to make an explosion ? Same thing: call the right function. Note that you can call OpenGL functions anyway, if necessary.

About portability, I can say a few things: Raydium was initially planned for linux only, but with an ``clean'' (nearly ANSI) code, and, in facts, we have been able to compile Raydium under VC6 (Windows ) with a very few modifications. So you can expect a correct result on any system providing OpenGL (at least 1.1), GLU, GLUT and a C compiler.

As we (CQFD Corp.) needed a library for our own games, demos, and... and things like that, and as I was interested by OpenGL, I starts to write Raydium.

Raydium is perfect for outdoors spaces, integrating a landscape engine, with suitable physic, supports dynamic lighting, fog, blending, water and waves, terraforming, and more.

This features list will probably grow up during Raydium developpement.

You'll find, in this document, an exhaustive list of all the functions and possibilities of Raydium.

After this short introduction, let's talk about the API itself, starting with the main file (from the programmer's point of vue) of Raydium: index.c

1.2 Defines

As mentioned above, the file index.c is quite interesting, for several reasons: first, as this file includes all others Raydium's files, you can have an overview of the whole project, just by looking at this.

It can also be used as a ``quick help'', since all variables are declared here, and not in the corresponding files. I mean, for example, that ``raydium_light_intensity[...]'' will be declared in index.c, not in light.c . There's many reasons for using such ``style'', but you must only retain that it is simpler for you :)

Ok, after this little disclaimer, we can have a look to the first part of our file.

After usual #include (nothing interesting here), we find some #defines.

1.2.1 generic limits

The first #define block determine limits of your application, and here you are the actual values:

#define RAYDIUM_MAX_VERTICES 500000

#define RAYDIUM_MAX_TEXTURES 256

#define RAYDIUM_MAX_LIGHTS 8

#define RAYDIUM_MAX_NAME_LEN 255

#define RAYDIUM_MAX_OBJECTS 1024

1.2.2 options and parameters

This is the next part of our #define section, I will not explain these constants here, but in respective sections, so you'll have just you to remember they're declared here.

1.3 vars quick view

This section aims to describe each variable Raydium use, one by one. Some (most ?) of them are used internaly only, but you could need to access it. Moreover, you'll better understand how Raydium works by looking at these variables.

1.3.1 keyboard input

Following variables can be found:

raydium_key_last will always contains the last key (normal or special) pressed down. You'll find a explanation about normal & special keys above.

raydium_key[] hosts all special keys state. Currently, you must use GLUT define's (Raydium aliases will come soon), limited to following keys:

These are ``special'' keys: they have 2 states. released (0), and pressed (non zero). It means you can do something (move an object, turn on a light) UNTIL user stops to press the key. ``Normal'' keys have a different behavior: you can do something IF user press a key (exit from application if ESC is pressed, for example). You'll have no information about key's release.

A normal key is sent through raydium_key_last, a special one through raydium_key[] AND raydium_key_last.

You must see raydium_key_last as an ``event'', fired when the user press a key (ANY key: special or not). When a normal key is pressed, you'll get the ASCII value + 1000 assigned to raydium_key_last. (1027 for ``ESC'', for example)

Here is a method to use special keys: if(raydium_key[GLUT_KEY_UP]) move_car();

Yes, it's easy. You can also use if(raydium_key_last==GLUT_KEY_UP) explose(); for example, if you need to carry out a specific action.

It's ok for you ? use raydium_key[] to keep the car moving until user release UP key, or use raydium_key_last to explode the car when the user tries to start it :)

1.3.2 mouse input

Easy.

You can get actual mouse position on the window (relative to window's position on screen, I mean) with raydium_mouse_x and raydium_mouse_y (GLuint), starting at (0,0) for upper left (Warning: some GLUT implementation can give mouse position even when mouse is out of the window ! Check boundaries before using these values).

Raydium use: 1 for left button, 2 for right button, and 3 for middle button (0 for none) with raydium_mouse_clic for the last clic value. (generated one time per clic)

You can permanently get a button's state, up (0) or down (non zero), using raydium_mouse_button[x], where x is 0 for left button, 1 for right one, and 2 for middle button.

1.3.3 textures

raydium_texture_index and raydium_texture_current (GLuint) are used internaly to determine repectively how many textures are loaded, wich is the current one.

The next variable, raydium_texture_filter, is very important. You can assign RAYDIUM_TEXTURE_FILTER_NONE (default), RAYDIUM_TEXTURE_FILTER_BILINEAR or RAYDIUM_TEXTURE_FILTER_TRILINEAR (recommended).

Using no texture filter can gives you higher framerate on old 3D hardware, but quite ugly.

You can activate bilinear filtering without any framerate impact on most recent video cards, and get a much more attractive rendering.

Trilinear filtering uses Bilinear filtering and MIPMAPs. A MIPMAPed texture is a duplicated texture (3 times, with Raydium), but at different sizes. A 512x512 texture will generate, for example, a (smoothed) 256x256 texture, and a (smoothed) 128x128 one. Your video card will use these textures according to distance from POV (point of vue), reducing flickering effect.

This is the best filtering Raydium can use, for a great rendering quality. Goog and recent 3D hardware can do trilinear filtering in a single pass, so it must be the default setting for your application.

About raydium_texture_filter itself: changing this variable will not modify the rendering, but the way to load textures. It means you can (for example) use trilinear only for landscape textures, and bilinear for others. It also means you must reload (erase) a texture to change it's filter.

Note that Raydium will never use trilinear filter with blended (transparent) textures, for good reasons :)

Let's talk quickly about next (internal) texture variables: raydium_texture_blended[] is a flag table, where each element is non zero for a blended (RGBA) texture, and 0 for an RGB one.

For Raydium, when a texture does not contain a ``bitmap'' (texture file, for example), it contains a plain color, and this color is stored in raydium_texture_rgb[][4] (4 is for RGBA, values between 0 and 1). You can load an rgb texture with ``rgb'' keyword. For example, instead of loading ``red.tga'', you can load ``rgb(0.8,0.1,0.1)''.

raydium_texture_name[] table simply contains texture filenames.

Last thing, raydium_texture_to_replace, can be used to erase an already loaded texture. Set the variable to n, and load a new texture: texture number ``n'' will be replaced in memory.

1.3.4 projection

Raydium supports 2 types of projection: RAYDIUM_PROJECTION_ORTHO (orthographic) and RAYDIUM_PROJECTION_PERSPECTIVE.

First of all, let us point out what ``projection'' is. Using a ``perspective'' projection, closest objects will looks larger than the orthers. It is typically used in video games (since human eye runs like that), by opposition to orthographic projection, wich is mostly used by 3D modeling tools. The principle is simple, discover it by yourself :)

Raydium reads raydium_projection to determine wich method to use. Each projection is configured with raydium_projection_* variables. Some of these variables are used both by ``perspective'' and ``orthographic'' projections.

Here is what index.c says:

GLFLOAT RAYDIUM_PROJECTION_FOV; // PERSPECTIVE ONLY

GLFLOAT RAYDIUM_PROJECTION_NEAR; // PERSPECTIVE & ORTHO

GLFLOAT RAYDIUM_PROJECTION_FAR; // PERSPECTIVE & ORTHO

GLFLOAT RAYDIUM_PROJECTION_LEFT; // ORTHO ONLY

GLFLOAT RAYDIUM_PROJECTION_RIGHT; // ORTHO ONLY

GLFLOAT RAYDIUM_PROJECTION_BOTTOM; // ORTHO ONLY

GLFLOAT RAYDIUM_PROJECTION_TOP; // ORTHO ONLY

You probably noticed that orthographic projection defines a ``box'' with your screen: near, far, left, right, bottom. Everything out ouf this box will never be displayed.

Perspective projection is based on FOV: Field Of Vision, given in degrees. A common ``human'' fov is 60^, up to 90^ without any noticeable deformation. ``near'' and ``far'' are used for many things: Z-Buffer precision is affected, and clipping too: as with ``orthographic'', nothing will be displayed beyond ``far'', and fog, if enabled, will hide this ``limit''. This is right for ``near'', too, but without fog, obviously :)

Also remember that decreasing FOV will zoom in.

You must call raydium_window_view_update() after any modification on one (or more) of these variables (see ``Window Managment'' section for more information)

1.3.5 frame size and color

raydium_window_tx and raydium_window_ty are read-only variables, providing you actual frame size.

raydium_background_color[4] is an RGBA table, and will be used for frame clearing, and fog color. You can change this variable, and call respective update functions (frame and fog), or simply use raydium_background_color_change(GLfloat r, GLfloat g, GLfloat b, GLfloat a).

More informations in corresponding sections.

1.3.6 vertices

Vertices data structure is distributed in 4 parts:

  1. *raydium_vertex_* : these tables will simply contains vertices coordinates
  2. *raydium_vertex_normal_* : vertices normals. Raydium will maintain two distinct normal tables, and this one will be used for calculations.
  3. *raydium_vertex_normal_visu_* : the other normal table, used for lighting. Smoothing ``visu'' normals will provides a better rendering, and Raydium includes all necessary functions to automate this task.
  4. *raydium_vertex_texture_u, *raydium_vertex_texture_v, *raydium_vertex_texture contains, for each vertex stored in the vertices data structure, u and v mapping information, and associated texture number. U and V are texture mapping coordinates.
Raydium can automatically generates some of these data (normals and uv coords, that is), Read ``Vertices'' section above for more information.

PLEASE, do not write directly in these tables, use dedicated functions.

1.3.7 objects

Objects are loaded in vertices stream, identified by a ``start'' and an ``end'' (raydium_object_start[] and raydium_object_end[]) in this stream. An index is incremented each time you load an object (GLuint raydium_object_index). Filename is also stored in raydium_object_name[][]. Go to ``Objects'' section to know more.

1.3.8 lights

First of all, raydium_light_enabled_tag contains 0 when light is disabled, non-zero otherwise. This is a read-only variable, so use suitable functions.

Currently, for Raydium, a light can have 3 states: on, off, or blinking.raydium_light_internal_state[] stores this.

Next comes all light's features: position, color, intensity. You can modify directly these variables, and call update fonctions, if needed (not recommended).

Next, raydium_light_blink_* are used internaly for blinking lights, setting lowest, higher light intensity, and blinking speed. Do noy modify these variables, use suitable functions.

1.3.9 fog

Only one variable, here: raydium_fog_enabled_tag, switching from zero to non zero if fog is enabled. Do NOT use this variable to enable or disable fog, but suitable functions, this variable is just a tag.

1.3.10 camera

Since many calls to camera functions are done during one frame, Raydium must track if any call to these functions was already done, using raydium_frame_first_camera_pass boolean.

raydium_camera_pushed, also used as a boolean, stores stack state. When you place your camera in the scene with Raydium, it pushes matrix on top of the stack, so you can modify it (the matrix), placing an object for example, an restore it quickly after, by popping matrix off.

1.3.11 particles

Particles and explosions are in early release stage and not documented yet.

2 Maths

2.1 introduction to trigo.c

2.2 Details

2.2.1 GLfloat raydium_trigo_cos(GLfloat i)

2.2.2 GLfloat raydium_trigo_sin(GLfloat i)

2.2.3 GLfloat raydium_trigo_cos_inv(GLfloat i)

2.2.4 GLfloat raydium_trigo_sin_inv(GLfloat i)

2.2.5 raydium_trigo_abs(A)

3 Messages, Console

3.1 Introduction to log.c

3.2 Details

3.2.1 void raydium_log(unsigned char *format, ...)

4 Random

4.1 Introduction to random.c

4.2 Details

4.2.1 void raydium_random_randomize(void)

4.2.2 GLfloat raydium_random_pos_1(void)

4.2.3 GLfloat raydium_random_neg_pos_1(void)

5 Fog

5.1 Introduction to fog.c

5.2 Details

5.2.1 void raydium_fog_enable(void)

5.2.2 void raydium_fog_disable(void)

5.2.3 void raydium_fog_color_update(void)

5.2.4 void raydium_fog_mode(void)

6 Window managment

6.1 Introduction to window.c

6.2 Details

6.2.1 void raydium_window_create(GLuint tx, GLuint ty,char rendering,char *name,int *argc, char **argv)

6.2.2 void raydium_window_resize_callback(GLsizei Width, GLsizei Height)

6.2.3 void raydium_window_view_update(void)

7 Capture

7.1 capture.c : quick overview of void raydium_capture_frame(char *filename)

8 Background, frame clearing

8.1 Introduction to background.c and clear.c

8.2 background.c

8.2.1 void raydium_background_color_change(GLfloat r, GLfloat g, GLfloat b, GLfloat a)

8.3 clear.c

8.3.1 void raydium_clear_frame(void)

8.3.2 void raydium_clear_color_update(void)

9 Lights

9.1 Introduction to Raydium light system (light.c)

9.2 Details

9.2.1 void raydium_light_enable(void)

9.2.2 void raydium_light_disable(void)

9.2.3 GLuint raydium_light_to_GL_light(GLuint l)

9.2.4 void raydium_light_on(GLuint l)

9.2.5 void raydium_light_off(GLuint l)

9.2.6 void raydium_light_switch(GLuint l)

9.2.7 void raydium_light_update_position(GLuint l)

9.2.8 void raydium_light_update_intensity(GLuint l)

9.2.9 void raydium_light_update_all(GLuint l)

9.2.10 void raydium_light_move(GLuint l,GLfloat *vect)

9.2.11 void raydium_light_reset(GLuint l)

9.2.12 void raydium_light_blink_internal_update(GLuint l)

9.2.13 void raydium_light_blink_start(GLuint l,int fpc)

9.2.14 void raydium_light_callback(void)

10 Keyboard & keys

10.1 Introduction to key.c

10.2 Details

10.2.1 void raydium_key_normal_callback(int key, int x, int y)

10.2.2 void raydium_key_special_callback(int key, int x, int y)

10.2.3 void raydium_key_special_up_callback(int key, int x, int y)

11 Mouse

11.1 Introduction to mouse.c

11.2 Details

11.2.1 void raydium_mouse_clic_callback(int but,int state,int x,int y)

11.2.2 void raydium_mouse_move_callback(int x, int y)

12 Textures

12.1 Introduction to texture.c

12.2 Details

12.2.1 GLuint raydium_texture_load(char *filename)

12.2.2 GLuint raydium_texture_load_erase(char *filename, GLuint to_replace)

12.2.3 char raydium_texture_current_set(GLuint current)

12.2.4 char raydium_texture_current_set_name(char *name)

13 Rendering

13.1 Introduction to render.c

13.2 Details

13.2.1 void raydium_rendering_internal_prepare_texture_render(GLuint tex)

13.2.2 void raydium_rendering_internal_restore_render_state(void)

13.2.3 void raydium_rendering_from_to(GLuint from, GLuint to)

13.2.4 void raydium_rendering(void)

13.2.5 void raydium_rendering_finish(void)

14 Particles and Explosions

14.1 Introduction to particle.c

14.2 Details

14.2.1 void raydium_particle_init(GLuint expl, GLuint part)

14.2.2 void raydium_explosion_reset(GLuint exp)

14.2.3 char raydium_particle_life(GLuint expl, GLuint part, GLuint *created)

14.2.4 void raydium_explosion_life(GLuint expl)

14.2.5 void raydium_explosion_callback(void)

14.2.6 void raydium_explosion_draw_particles(GLuint expl)

14.2.7 void raydium_explosion_draw_all(void)

15 Callbacks

15.1 Introduction to callback.c

15.2 Details

15.2.1 void raydium_callback_image(void)

15.2.2 void raydium_callback_set(void)

15.2.3 void raydium_callback(void (*loop) )

16 Normals

16.1 Introduction to normal.c

16.2 Details

16.2.1 void raydium_normal_generate_lastest_triangle(int default_visu)

16.2.2 void raydium_normal_restore_all(void)

16.2.3 void raydium_normal_smooth_all(void)

17 Vertices

17.1 Introduction to vertex.c

17.2 Details

17.2.1 void raydium_vertex_add(GLfloat x, GLfloat y, GLfloat z)

17.2.2 void raydium_vertex_uv_add(GLfloat x, GLfloat y, GLfloat z,GLfloat u, GLfloat v)

17.2.3 void raydium_vertex_uv_normals_add(GLfloat x, GLfloat y, GLfloat z, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat u, GLfloat v)

18 Land

18.1 Introduction to land.c

18.2 Details

18.2.1 GLfloat raydium_land_internal_landtmp(GLfloat x,GLfloat y,GLfloat phase,GLfloat ampl, GLfloat periode)

18.2.2 void raydium_land_draw_water(GLfloat phase, GLfloat ampl, GLfloat periode, int sub, char *texture)

18.2.3 GLfloat raydium_land_surface(GLfloat x, GLfloat y, GLfloat *nx, GLfloat *ny, GLfloat *nz)

19 Sky and environement boxes

19.1 Introduction to sky.c

19.2 void raydium_sky_box_render(GLfloat x, GLfloat y, GLfloat z)

20 ``Internal'' informations acces

20.1 internal.c : void raydium_internal_dump(void)

21 Files

21.1 Warnings

21.2 Introduction to file.c

21.3 Details

21.3.1 void dump_vertex_to(char *filename)

21.3.2 void read_vertex_from(char *filename)

22 Camera

22.1 Introduction to camera.c

22.2 Details

22.2.1 void raydium_camera_internal(GLfloat x, GLfloat y, GLfloat z)

22.2.2 void raydium_camera_place(GLfloat x, GLfloat y, GLfloat z, GLfloat lacet, GLfloat tangage, GLfloat roulis)

22.2.3 void raydium_camera_look_at(GLfloat x, GLfloat y, GLfloat z, GLfloat x_to, GLfloat y_to, GLfloat z_to)

22.2.4 void raydium_camera_replace(void)

23 Objects

23.1 Introduction to object.c

23.2 Details

23.2.1 void raydium_object_reset(GLuint o)

23.2.2 int raydium_object_load(char *filename)

23.2.3 void raydium_object_draw(GLuint o)

23.2.4 void raydium_object_draw_name(char *name)

24 Initialization

24.1 Introduction to init.c

24.2 Details

24.2.1 void raydium_init_lights(void)

24.2.2 void raydium_init_objects(void)

24.2.3 void raydium_init_explosions(void)

24.2.4 void raydium_init_key(void)

24.2.5 void raydium_init_mouse(void)

24.2.6 void raydium_init_reset(void)

24.2.7 void raydium_init_engine(void)

25 Miscalleneous

25.1 License

25.2 About CQFD Corp.

25.3 Links

25.4 Greets

About this document ...

Raydium API Reference

This document was generated using the LaTeX2HTML translator Version 2K.1beta (1.62)

Copyright © 1993, 1994, 1995, 1996, Nikos Drakos, Computer Based Learning Unit, University of Leeds.
Copyright © 1997, 1998, 1999, Ross Moore, Mathematics Department, Macquarie University, Sydney.

The command line arguments were:
latex2html -no_subdir -split 0 -show_section_numbers /tmp/lyx_tmpdir2201fxoKxL/lyx_tmpbuf0/api.tex

The translation was initiated by on 2002-09-08


next_inactive up previous
2002-09-08