🎉 Added files
This commit is contained in:
52
raydium/headers/atexit.h
Normal file
52
raydium/headers/atexit.h
Normal file
@ -0,0 +1,52 @@
|
||||
#ifndef _ATEXIT__H
|
||||
#define _ATEXIT__H
|
||||
#include "../atexit.h"
|
||||
|
||||
/*=
|
||||
Atexit functions
|
||||
4400
|
||||
**/
|
||||
|
||||
// Introduction
|
||||
/**
|
||||
Raydium provides its own atexit function, since Win32 DLL requires a bit
|
||||
of magic for such things. This support is mainly here for internal reasons,
|
||||
you can continue to use regular atexit() in your applications.
|
||||
**/
|
||||
|
||||
|
||||
__rayapi int raydium_atexit(void (*func)(void));
|
||||
/**
|
||||
As the original atexit():
|
||||
Register a function to be called at norma program termination.
|
||||
Functions so registered are called in the reverse order of their
|
||||
registration; no arguments are passed.
|
||||
Returns 0 if successful.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_atexit_call(void);
|
||||
/**
|
||||
Internal use. Will call all registered functions.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_atexit_init(void);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
// Hack. See cli.h header for more information.
|
||||
#ifdef RAYDLL
|
||||
#define raydium_init_args(argc,argv)\
|
||||
{\
|
||||
atexit(raydium_atexit_call);\
|
||||
raydium_init_args_hack(argc,argv);\
|
||||
}
|
||||
|
||||
#define raydium_init_args_name(argc,argv,app_name)\
|
||||
{\
|
||||
atexit(raydium_atexit_call);\
|
||||
raydium_init_args_name_hack(argc,argv,app_name);\
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
14
raydium/headers/background.h
Normal file
14
raydium/headers/background.h
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef _BACKGROUND_H
|
||||
#define _BACKGROUND_H
|
||||
/*=
|
||||
Background
|
||||
800
|
||||
**/
|
||||
|
||||
__rayapi void raydium_background_color_change (GLfloat r, GLfloat g, GLfloat b, GLfloat a);
|
||||
/**
|
||||
Will change ##raydium_background_color## array and apply this modification.
|
||||
(will update fog color, obviously).
|
||||
**/
|
||||
|
||||
#endif
|
34
raydium/headers/callback.h
Normal file
34
raydium/headers/callback.h
Normal file
@ -0,0 +1,34 @@
|
||||
#ifndef _CALLBACK_H
|
||||
#define _CALLBACK_H
|
||||
|
||||
/*=
|
||||
Callbacks
|
||||
1500
|
||||
**/
|
||||
|
||||
// Introduction
|
||||
/**
|
||||
This file contains many initializations, a few internal callbacks, but
|
||||
will provides a very important function for end-user, wich will
|
||||
gives user display function to Raydium: see below
|
||||
**/
|
||||
|
||||
|
||||
__rayapi void raydium_callback_image (void);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_callback_set (void);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_callback (void (*loop));
|
||||
/**
|
||||
This function will loop over the provided display function, indefinitely.
|
||||
"loop" must be:
|
||||
%%(c) void loop(void) %%
|
||||
**/
|
||||
|
||||
#endif
|
173
raydium/headers/camera.h
Normal file
173
raydium/headers/camera.h
Normal file
@ -0,0 +1,173 @@
|
||||
#ifndef _CAMERA_H
|
||||
#define _CAMERA_H
|
||||
|
||||
/*=
|
||||
Camera
|
||||
2200
|
||||
**/
|
||||
|
||||
// Introduction
|
||||
/**
|
||||
Raydium provides camera management functions, allowing the coder to
|
||||
move camera with very simple functions, even for complex moves.
|
||||
You have to place your camera once per frame (not more, not less).
|
||||
|
||||
"look_at" style functions can be affected by ##raydium_camera_look_at_roll##
|
||||
global variable, if needed.
|
||||
|
||||
A few words about camera path: Take a look to a .cam file if you want to
|
||||
understand this simple file format, but you probably only need the ##cam.c##
|
||||
application, dedicated to camera path creation.
|
||||
|
||||
Some camera functions are provided by physics module, see suitable chapter.
|
||||
**/
|
||||
|
||||
|
||||
__rayapi void raydium_camera_vectors (GLfloat * res3);
|
||||
/**
|
||||
This function will return two vectors (2 * 3 * GLfloat), giving the camera
|
||||
orientation (front vector and up vector). At this day, the up vector is
|
||||
always the same as the world up vector, even if the camera is rotated
|
||||
or upside down (and yes, this MUST be corrected :).
|
||||
|
||||
Designed for internal uses, before all.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_camera_internal_prepare(void);
|
||||
/**
|
||||
Internal use. (pre)
|
||||
**/
|
||||
|
||||
__rayapi void raydium_camera_internal (GLfloat x, GLfloat y, GLfloat z);
|
||||
/**
|
||||
Internal use. (post)
|
||||
**/
|
||||
|
||||
__rayapi void raydium_camera_place (GLfloat x, GLfloat y, GLfloat z, GLfloat lacet, GLfloat tangage, GLfloat roulis);
|
||||
/**
|
||||
Sets the camera at (x,y,z) position, and using (lacet,tangage,roulis)
|
||||
as rotation angles.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_camera_look_at (GLfloat x, GLfloat y, GLfloat z, GLfloat x_to, GLfloat y_to, GLfloat z_to);
|
||||
/**
|
||||
Sets the camera at (x,y,z) position, and looks at (x_to,y_to,z_to).
|
||||
**/
|
||||
|
||||
__rayapi void raydium_camera_replace (void);
|
||||
/**
|
||||
You'll need to reset camera position and orientation after each object drawing.
|
||||
If this is unclear to you, read the "example" section, below.
|
||||
|
||||
You will need to make your own 3D transformations (GLRotate, GLTranslate,
|
||||
...) to draw your objects, or you can use the following function.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_camera_replace_go (GLfloat * pos, GLfloat * R);
|
||||
/**
|
||||
This function will replace the camera, as ##raydium_camera_replace()##,
|
||||
but will place "3D drawing cursor" at position ##pos## (3 GLfloat) with
|
||||
rotation ##R## (4 GLfloat quaternion).
|
||||
|
||||
No eulers (rotx, roty, rotz) version of this function is provided for now..
|
||||
Do you really need it ?
|
||||
**/
|
||||
|
||||
// Example of camera use
|
||||
/**
|
||||
1. place camera
|
||||
2. move "drawing cursor" to object's place
|
||||
3. draw object
|
||||
4. reset camera to initial place (the one given at step 1)
|
||||
5. move "drawing cursor" to another object's place
|
||||
6. draw another object
|
||||
7. [...]
|
||||
|
||||
Steps 4 and 5 can be done with raydium_camera_replace_go().
|
||||
**/
|
||||
|
||||
__rayapi void raydium_camera_rumble(GLfloat amplitude, GLfloat ampl_evo, GLfloat secs);
|
||||
/**
|
||||
Camera (any type) will rumble for ##secs## seconds, with ##amplitude## (radians).
|
||||
This ##amplitude## will be incremented of ##ampl_evo## every second (negative
|
||||
values are allowed for ##ampl_evo##).
|
||||
An ##amplitude## is always positive.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_camera_smooth (GLfloat px, GLfloat py, GLfloat pz, GLfloat lx, GLfloat ly, GLfloat lz, GLfloat zoom, GLfloat roll, GLfloat step);
|
||||
/**
|
||||
Smooth style clone of ##raydium_camera_look_at##.
|
||||
Roll is given by ##roll## and not global variable ##raydium_camera_look_at_roll##
|
||||
as for regular look_at function.
|
||||
##zoom## is the requested FOV.
|
||||
Play with step to modify smoothing level of the movement. A good way to use
|
||||
this function is the following usage :
|
||||
%%(c) raydium_camera_smooth(cam[0],cam[1],cam[2],pos[1],-pos[2],pos[0],70,0,raydium_frame_time*3); %%
|
||||
**/
|
||||
|
||||
__rayapi void raydium_camera_path_init (int p);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_camera_path_init_all (void);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_camera_path_find (char *name);
|
||||
/**
|
||||
Lookups path's id using filename ##name##.
|
||||
This function will not try to load a camera path if it's not found, and
|
||||
will return -1.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_camera_path_load (char *filename);
|
||||
/**
|
||||
Obvious : use this function to load a camera path.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_camera_path_draw (int p);
|
||||
/**
|
||||
Draws ##p## camera path, as red lines. This must be done at each frame.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_camera_path_draw_name (char *path);
|
||||
/**
|
||||
Same as above, but using camera path's name.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_camera_smooth_path (char *path, GLfloat step, GLfloat * x, GLfloat * y, GLfloat * z, GLfloat * zoom, GLfloat * roll);
|
||||
/**
|
||||
Returns the (##x,y,z##) point of the camera path for step ##step##, using
|
||||
provided ##zoom## (FOV) and ##roll## angle.
|
||||
It's important to note that ##step## is a float.
|
||||
Mostly for internal use.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_camera_path_reset(void);
|
||||
/**
|
||||
Next smooth call will be instantaneous.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_camera_smooth_path_to_pos (char *path, GLfloat lx, GLfloat ly, GLfloat lz, GLfloat path_step, GLfloat smooth_step);
|
||||
/**
|
||||
"Camera on path looking at a point".
|
||||
Simple ##raydium_camera_smooth## version: give a path name, a "look_at"
|
||||
point (##lx,ly,lz##), a current ##step##, anda ##smooth_step## time
|
||||
factor (see ##raydium_camera_smooth## example above).
|
||||
**/
|
||||
|
||||
__rayapi void raydium_camera_smooth_pos_to_path (GLfloat lx, GLfloat ly, GLfloat lz, char *path, GLfloat path_step, GLfloat smooth_step);
|
||||
/**
|
||||
"Camera on point looking at a path".
|
||||
Same style as previous function.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_camera_smooth_path_to_path (char *path_from, GLfloat path_step_from, char *path_to, GLfloat path_step_to, GLfloat smooth_step);
|
||||
/**
|
||||
"Camera on a path looking at another path".
|
||||
Same style as previous functions.
|
||||
**/
|
||||
|
||||
#endif
|
76
raydium/headers/capture.h
Normal file
76
raydium/headers/capture.h
Normal file
@ -0,0 +1,76 @@
|
||||
#ifndef _CAPTURE_H
|
||||
#define _CAPTURE_H
|
||||
/*=
|
||||
Capture (2D)
|
||||
700
|
||||
**/
|
||||
|
||||
// Quickview
|
||||
/**
|
||||
Captures are made in TGA (without RLE compression) or JPEG formats and saved into
|
||||
the current directory.
|
||||
These functions may fail (garbage in resulting capture) if frame size if
|
||||
not "standard", mostly after a window resize.
|
||||
|
||||
Also there are "auto" functions that provide a simplest method to make an screen
|
||||
capture. So,the following example (put into the ##display()## function), allows jpeg
|
||||
screenshots just pressing F9 key:
|
||||
##
|
||||
if(raydium_key_last==9) raydium_capture_frame_jpeg_auto();
|
||||
##
|
||||
|
||||
Raydium also allow you to capture movies: activate ##DEBUG_MOVIE## option
|
||||
in ##raydium/config.h## with the needed framerate, and press F11. Raydium
|
||||
will use a dedicated time line, allowing smooth capture. This system may cause
|
||||
strange behaviours with movies providing network action.
|
||||
The movie is stored in multiples files in ##movie## directory, and you can
|
||||
use mencoder like this:
|
||||
##mencoder -ovc lavc -lavcopts vcodec=mpeg4:vhq:vbitrate=780
|
||||
mf://\*.tga -vf scale=320:240 -mf fps=25 -o ~/ray.avi##
|
||||
You can also use audio file adding this:
|
||||
## -audiofile audio.mp3 -oac copy## for example.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_capture_frame(char *filename);
|
||||
/**
|
||||
Capture current frame to ##filename##.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_capture_frame_auto(void);
|
||||
/**
|
||||
Same as above, but to an auto-generated filename (raycap*).
|
||||
**/
|
||||
|
||||
__rayapi void raydium_capture_frame_jpeg(char *filename);
|
||||
/**
|
||||
Same as ##raydium_capture_frame()## but using JPEG image format.
|
||||
See ##raydium/config.h## for quality setting.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_capture_frame_now(char *filename);
|
||||
/**
|
||||
Same as ##raydium_capture_frame()##, but without waiting the end of the frame,
|
||||
saving the hardware color buffer, whatever it contains. Use with caution.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_capture_frame_jpeg_now(char *filename);
|
||||
/**
|
||||
Same as above, but using JPEG image format.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_capture_filename_auto(char *dest,char *format);
|
||||
/**
|
||||
Internal Use. Generates filenames for new screenshots.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_capture_frame_auto(void);
|
||||
/**
|
||||
Capture the current frame giving the resulting file and automatic name.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_capture_frame_jpeg_auto(void);
|
||||
/**
|
||||
Same as above, but using JPEG image format.
|
||||
**/
|
||||
|
||||
#endif
|
17
raydium/headers/clear.h
Normal file
17
raydium/headers/clear.h
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef _CLEAR_H
|
||||
#define _CLEAR_H
|
||||
/*=
|
||||
Frame clearing
|
||||
801
|
||||
**/
|
||||
|
||||
__rayapi void raydium_clear_frame (void);
|
||||
/**
|
||||
You need to call this function every frame to clear all hardware buffers.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_clear_color_update (void);
|
||||
/**
|
||||
Will apply background color modification. Probably useless for you.
|
||||
**/
|
||||
#endif
|
84
raydium/headers/cli.h
Normal file
84
raydium/headers/cli.h
Normal file
@ -0,0 +1,84 @@
|
||||
#ifndef _CLI_H
|
||||
#define _CLI_H
|
||||
/*=
|
||||
Command Line Interface
|
||||
2401
|
||||
**/
|
||||
|
||||
// Introduction
|
||||
/**
|
||||
Here, you'll find a few functions to deal with command line
|
||||
interface of Raydium.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_init_cli_option(char *option, char *value);
|
||||
/**
|
||||
This function will search command line ##option##.
|
||||
If this option is found, the functions stores any argument to ##value## and
|
||||
returns 1.
|
||||
The function will return 0 if ##option## is not found.
|
||||
|
||||
Example (search for: ##--ground##)
|
||||
%%(c)
|
||||
char model[RAYDIUM_MAX_NAME_LEN];
|
||||
if(raydium_init_cli_option("ground",model))
|
||||
{
|
||||
setground(model);
|
||||
}
|
||||
%%
|
||||
**/
|
||||
|
||||
__rayapi int raydium_init_cli_option_default(char *option, char *value, char *default_value);
|
||||
/**
|
||||
Same as above, but allows you to provide a default value (##default##) if
|
||||
the ##option## is not found on command line.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_init_internal_homedir_find(char *);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
#ifndef RAYDLL
|
||||
__rayapi void raydium_init_args(int argc, char **argv);
|
||||
/**
|
||||
You must use this function, wich send application arguments to Raydium
|
||||
and external libs (GLUT, OpenAL, ...).
|
||||
This must be done **before** any other call to Raydium.
|
||||
Example:
|
||||
%%(c)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
raydium_init_args(argc,argv);
|
||||
[...]
|
||||
%%
|
||||
**/
|
||||
#endif
|
||||
|
||||
#ifndef RAYDLL
|
||||
__rayapi void raydium_init_args_name(int argc, char **argv, char *app_name);
|
||||
/**
|
||||
Same as above, but with application short name. This string is used to
|
||||
build things like runtime configuration directory name (~/.raydium/ by default).
|
||||
Use this wrapper if you don't want to share your configuration with Raydium.
|
||||
**/
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
Ok ... all this is a very ugly part: under win32, a DLL use a different
|
||||
atexit() queue than the application. We can't use the DLL_PROCESS_DETACH
|
||||
DLL reason, since it seems that OpenAL DLL is unloaded *before* raydium.dll !
|
||||
|
||||
So the idea here is to provide a wrapper to the application for these two
|
||||
init functions so they use their own atexit() queue, in a transparent way.
|
||||
|
||||
See atexit.h header for wrappers.
|
||||
*/
|
||||
#ifdef RAYDLL
|
||||
__rayapi void raydium_init_args_hack(int argc, char **argv);
|
||||
__rayapi void raydium_init_args_name_hack(int argc, char **argv, char *app_name);
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
122
raydium/headers/console.h
Normal file
122
raydium/headers/console.h
Normal file
@ -0,0 +1,122 @@
|
||||
#ifndef _CONSOLE_H
|
||||
#define _CONSOLE_H
|
||||
/*=
|
||||
In-game console
|
||||
3000
|
||||
**/
|
||||
|
||||
// Introduction
|
||||
/**
|
||||
This chapter introduce Raydium console, allowing applications to take
|
||||
user keyboard input (game commands, chat, ...) and to send informations
|
||||
to this console.
|
||||
The end user can call the console using "the key below esc".
|
||||
|
||||
By default, if PHP support is enabled, all user commands will be redirected
|
||||
to PHP engine. Each command will get his own context, don't expect to create
|
||||
anything else than "single line PHP scripts" with the console. See PHP chapter
|
||||
for more informations.
|
||||
The console allows the user to prefix command with the following characters:
|
||||
|
||||
- ##/##: Non PHP command. The command will be sent to application (see
|
||||
##raydium_console_gets_callback##, below.
|
||||
|
||||
- ##>##: Will launch argument as a PHP script (identical to ##include("...")##)
|
||||
|
||||
- ##!##: Will launch argument as a sequence script
|
||||
|
||||
Command history is saved to ##raydium_history## file when application exits.
|
||||
|
||||
You can use a ##void prompt(char *)## callback to get user commands. Your
|
||||
callback must be registered thru ##raydium_console_gets_callback##:
|
||||
%%(c) raydium_console_gets_callback=prompt; %%
|
||||
|
||||
This console provides auto-completion of register functions and variables.
|
||||
See the suitable chapter for more information.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_console_init (void);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_console_history_save (void);
|
||||
/**
|
||||
Internal use (will flush console history to disk).
|
||||
You can call it by yourself if needed.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_console_gets (char *where);
|
||||
/**
|
||||
**DISABLED**.
|
||||
Use ##raydium_console_gets_callback## function pointer instead.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_console_history_previous (void);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_console_history_next (void);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_console_history_add (char *str);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_console_exec_script (char *file);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_console_exec_last_command (void);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_console_line_add (char *format, ...);
|
||||
/**
|
||||
Mostly reserved for internal use, but unless ##raydium_log##, this function will
|
||||
add the provided data only to ingame console, and not to "native" console.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_console_history_read(char **hist);
|
||||
/**
|
||||
This function will build an history list.
|
||||
See this example :
|
||||
%%(c)
|
||||
char *hist[RAYDIUM_CONSOLE_MAX_LINES];
|
||||
int i,n;
|
||||
n=raydium_console_history_read(hist);
|
||||
for(i=0;i<n;i++)
|
||||
printf("> %s\n",hist[i]);
|
||||
%%
|
||||
**Warning**: Be sure that there's no new history line between the call and
|
||||
the end of ##hist## usage (Or copy ##hist## to a safer place).
|
||||
**/
|
||||
|
||||
|
||||
__rayapi void raydium_console_event (void);
|
||||
/**
|
||||
Internal use. Will switch console up and down.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_console_draw (void);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_console_internal_isalphanumuscore (char c);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_console_complete (char *str);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
#endif
|
108
raydium/headers/file.h
Normal file
108
raydium/headers/file.h
Normal file
@ -0,0 +1,108 @@
|
||||
#ifndef _FILE_H
|
||||
#define _FILE_H
|
||||
/*=
|
||||
Files (generic)
|
||||
2100
|
||||
**/
|
||||
|
||||
// Introduction
|
||||
/**
|
||||
File support is now splitted in two parts: generic functions and TRI format
|
||||
specific functions. This chapter talks about generic part, where you'll find
|
||||
some libc replacements and wrappers, and functions dealing with
|
||||
"private directory" of the current user.
|
||||
**/
|
||||
|
||||
|
||||
__rayapi void raydium_file_dirname(char *dest,char *from);
|
||||
/**
|
||||
Reliable and portable version of libc's ##dirname## function.
|
||||
This function extracts directory from ##from## filename, and writes it
|
||||
to ##dest##.
|
||||
No memory allocation will be done by the function.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_file_basename(char *dest,char *from);
|
||||
/**
|
||||
Another libc clone, for ##basename## function. Extracts file name from a
|
||||
path into ##dest## string.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_file_ext(char *dest, char *from);
|
||||
/**
|
||||
Return the extension of ##from## filename (can be a complete path), without
|
||||
the . (dot), or an empty string if extension is not found.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_file_directory_writable(char *path);
|
||||
/**
|
||||
Return **1** if ##path## directory is writable, **0** otherwise.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_file_readable(char *filename);
|
||||
/**
|
||||
Return **1** if ##filename## exists and is readable, **0** otherwise.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_file_log_fopen_display(void);
|
||||
/**
|
||||
Display (console) all filenames that were opened before the call.
|
||||
##--files## command line option will call this function at the application's
|
||||
exit, closed or not.
|
||||
**/
|
||||
|
||||
__rayapi FILE *raydium_file_fopen(char *file, char *mode);
|
||||
/**
|
||||
Raydium wrapper to libc's ##fopen## function.
|
||||
This function will:
|
||||
- Update some stats
|
||||
- Try to download the file from repositories if no local version is found, or
|
||||
will try to update the file if asked (##--repository-refresh## or
|
||||
##repository-force##). See R3S on Raydium's Wiki.
|
||||
- You can disable R3S client (for a "local only" file) adding a 'l'
|
||||
in ##mode## ("rl" or "rbl" for example).
|
||||
- Use Raydium paths (see suitable chapter)
|
||||
**/
|
||||
|
||||
#ifdef PHP_SUPPORT
|
||||
__rayapi int raydium_rayphp_repository_file_get(char *file);
|
||||
#else
|
||||
#define raydium_php_repository_file_get fopen
|
||||
#endif
|
||||
|
||||
|
||||
__rayapi unsigned long raydium_file_sum_simple(char *filename);
|
||||
/**
|
||||
This function will generate a very simple checksum on ##filename##.
|
||||
**/
|
||||
|
||||
unsigned long raydium_file_sum_simple_mode(char *filename,char *mode);
|
||||
/**
|
||||
Same as above, but you can pass a fopen ##mode## ("rt", or "rbl" for example).
|
||||
See ##raydium_file_fopen()## for more informations about ##mode##.
|
||||
**/
|
||||
|
||||
__rayapi char * raydium_file_home_path(char *file);
|
||||
/**
|
||||
This function will return an absolute file path for ##file## in the home
|
||||
directory of the current user.
|
||||
Returned value is a pointer to static memory. Do not free this memory and use
|
||||
it before any other call to this function, since it will be overwritten.
|
||||
Example:
|
||||
for ##test.cfg##, this function will return ##/home/me/.raydium/test.cfg##
|
||||
See also ##raydium_init_args_name()## if you want to tune this result.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_file_home_path_cpy(char *file, char *dest);
|
||||
/**
|
||||
Same as above, but you must provide memory with ##dest##.
|
||||
**/
|
||||
|
||||
__rayapi char *raydium_file_load(char *filename);
|
||||
/**
|
||||
This function loads ##filename## (as a binary file under win32, no matter
|
||||
under Linux) in a string, and returns its address. **You** must free this
|
||||
memory when finished.
|
||||
**/
|
||||
|
||||
#endif
|
85
raydium/headers/file_tri.h
Normal file
85
raydium/headers/file_tri.h
Normal file
@ -0,0 +1,85 @@
|
||||
#ifndef _FILE_TRI_H
|
||||
#define _FILE_TRI_H
|
||||
/*=
|
||||
Files (TRI format)
|
||||
2101
|
||||
**/
|
||||
|
||||
// Warning
|
||||
/**
|
||||
It's important to use only functions with ##raydium_file_*## prefix.
|
||||
All other functions may change or disappear. Upper level functions are
|
||||
available (see ##object.c##).
|
||||
**/
|
||||
|
||||
// Introduction
|
||||
/**
|
||||
##file.c## use .tri mesh files (text), available in 4 versions:
|
||||
|
||||
1. version 1: providing normals and uv texture mapping informations.
|
||||
2. version 0: providing uv texture mapping.
|
||||
3. version -1: only providing vertices.
|
||||
4. version 2: mesh animation support
|
||||
|
||||
Version 1 example file:
|
||||
%%
|
||||
1
|
||||
5.1 15.75 -3.82 0.0000 0.0000 -1.0000 0.5158 0.5489 rgb(0.5,0.5,0.5)
|
||||
6.3 11.75 -3.82 0.0000 0.0000 -1.0000 0.5196 0.5365 rgb(0.5,0.5,0.5)
|
||||
5.0 11.75 -3.82 0.0000 0.0000 -1.0000 0.5158 0.5365 rgb(0.5,0.5,0.5)
|
||||
...
|
||||
%%
|
||||
|
||||
You can find the file version on first line, and then data.
|
||||
Next lines: vertex position (x,y,z), normal (x,y,z), texture mapping (u,v)
|
||||
and texture (string).
|
||||
|
||||
Version 2 files are a bit different, as showed below:
|
||||
%%
|
||||
2
|
||||
3 1743
|
||||
0 39 stand
|
||||
40 45 run
|
||||
46 53 attack
|
||||
1
|
||||
5.1 15.75 -3.82 0.0000 0.0000 -1.0000 0.5158 0.5489 rgb(0.5,0.5,0.5)
|
||||
6.3 11.75 -3.82 0.0000 0.0000 -1.0000 0.5196 0.5365 rgb(0.5,0.5,0.5)
|
||||
5.0 11.75 -3.82 0.0000 0.0000 -1.0000 0.5158 0.5365 rgb(0.5,0.5,0.5)
|
||||
...
|
||||
%%
|
||||
|
||||
You may have seen that headers are longer for v2 files. You'll find (just
|
||||
after the version number) how many "anims" are hosted by this file, and how
|
||||
many vertices are required for one frame. Then you'll find one line per
|
||||
"anim", with starting frame, ending frame and anim's name.
|
||||
Then starts a regular tri file ("sub-file", with its own version number)
|
||||
with ALL concatened frames.
|
||||
**/
|
||||
|
||||
|
||||
#define DONT_SAVE_DUMMY_TEXTURE
|
||||
__rayapi void dump_vertex_to (char *filename);
|
||||
/**
|
||||
This function save all scene to filename (.tri file) in version 1.
|
||||
Vertice may be sorted.
|
||||
Please, try to do not use this function.
|
||||
**/
|
||||
|
||||
__rayapi void dump_vertex_to_alpha (char *filename);
|
||||
/**
|
||||
Now useless and deprecated.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_file_set_textures (char *name);
|
||||
/**
|
||||
Internal use.
|
||||
This function analyze texture filename, and search for extended multitexturing
|
||||
informations (u,v and another texture).
|
||||
**/
|
||||
|
||||
__rayapi void read_vertex_from (char *filename);
|
||||
/**
|
||||
Loads filename. Again, avoid use of this function.
|
||||
**/
|
||||
|
||||
#endif
|
137
raydium/headers/fog.h
Normal file
137
raydium/headers/fog.h
Normal file
@ -0,0 +1,137 @@
|
||||
#ifndef _FOG_H
|
||||
#define _FOG_H
|
||||
/*=
|
||||
Fog
|
||||
500
|
||||
**/
|
||||
|
||||
// Introduction
|
||||
/**
|
||||
Fog is usefull for two major reasons:
|
||||
|
||||
1. Realism: Just try, and you'll understand:
|
||||
amazing depth impression, no ?
|
||||
|
||||
2. Speed: For a correct fog effect (i'm talking
|
||||
about estetic aspect), you must bring near_clipping to a closer value,
|
||||
reducing the overall number of triangles displayed at the same time.
|
||||
|
||||
There are 3 types of fog. They are:
|
||||
|
||||
* Linear:
|
||||
|
||||
Far-z
|
||||
fog= ---------
|
||||
Far-Near
|
||||
|
||||
* Exp:
|
||||
|
||||
(-density*z)
|
||||
fog= e^
|
||||
|
||||
* Exp2:
|
||||
|
||||
(-density*z)^2
|
||||
fog= e^
|
||||
|
||||
Above ##z## is the distance to the calculated point from the camera.
|
||||
As you can see, linear mode doesn't use ##Density##; and Exp & Exp2 modes don't
|
||||
use near and far values. Remember that.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_fog_enable (void);
|
||||
/**
|
||||
Obvious
|
||||
**/
|
||||
|
||||
__rayapi void raydium_fog_disable (void);
|
||||
/**
|
||||
Obvious
|
||||
**/
|
||||
|
||||
__rayapi void raydium_fog_color_update (void);
|
||||
/**
|
||||
If you have modified ##raydium_background_color## array, you must
|
||||
call this function, applying the specified color to hardware.
|
||||
See also: ##raydium_background_color_change##
|
||||
**/
|
||||
|
||||
__rayapi void raydium_fog_mode(GLuint mode);
|
||||
/**
|
||||
The fog mode can be change with this function. There are 3 different ways
|
||||
to apply the fog:
|
||||
|
||||
1. ##RAYDIUM_FOG_MODE_LINEAR## - Used by default, the fog is directly applied
|
||||
according the distance. Not real world fog, but used to avoid drawing
|
||||
too distant objects.
|
||||
##IMPORTANT##: EXP mode ignores the ##density## value,
|
||||
only uses ##near## and ##far##.
|
||||
|
||||
2. ##RAYDIUM_FOG_MODE_EXP## - The fog grows exponentially with the distance.
|
||||
Usual mist in the real world.
|
||||
##IMPORTANT##: EXP mode ignores the ##near## and ##far## values,
|
||||
only uses the ##density##.
|
||||
|
||||
3. ##RAYDIUM_FOG_MODE_EXP2## - The fog grows twice exponentially with the
|
||||
distance. Used when the observer is inside a cloud/mist.
|
||||
##IMPORTANT##: EXP2 mode ignores the ##near## and ##far## values,
|
||||
only uses the ##density##.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_fog_density(GLfloat density);
|
||||
/**
|
||||
Sets the density of the fog.
|
||||
Useless if you are using LINEAR mode.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_fog_near(GLfloat near);
|
||||
/**
|
||||
Sets the near point to apply the fog.
|
||||
Useless if you are using EXP or EXP2 modes.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_fog_far(GLfloat far);
|
||||
/**
|
||||
Sets the far point of the fog.
|
||||
Useless if you are using EXP or EXP2 modes.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_fog_apply(void);
|
||||
/**
|
||||
Used to apply changes in your setup of fog.
|
||||
Also is used to continue a previously stopped fog.
|
||||
See: ##raydium_fog_wait()## below.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_fog_wait(void);
|
||||
/**
|
||||
With this function you can deactivate TEMPORALY the fog, but the internal state
|
||||
of the fog in Raydium won't change, so when you use raydium_fog_apply, the fog
|
||||
will continue like it was before being stoped.
|
||||
It's very usefull for certain rendering effects that need to
|
||||
stop the fog temporaly.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_fog_volumetric_support(void);
|
||||
/**
|
||||
With this function, you're saying to Raydium that you want a support
|
||||
for volumetric fog in you application. Call this function as soon as possible
|
||||
after engine init, since it will change the way Raydium renders objects (think
|
||||
about display lists).
|
||||
**/
|
||||
|
||||
__rayapi void raydium_fog_volumetric_enable(void);
|
||||
/**
|
||||
When you call this function, fog is no more applied using fragment depth,
|
||||
but using ##RENDER_VOLUMETRIC_FOG_AXIS## (see config.h).
|
||||
You must have called ##raydium_fog_volumetric_support()## before enabling
|
||||
volumetric fog.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_fog_volumetric_disable(void);
|
||||
/**
|
||||
Reset fog sytem to default behavior (fragment depth).
|
||||
**/
|
||||
|
||||
|
||||
#endif
|
428
raydium/headers/gui.h
Normal file
428
raydium/headers/gui.h
Normal file
@ -0,0 +1,428 @@
|
||||
#ifndef _GUI_H
|
||||
#define _GUI_H
|
||||
|
||||
#include "../gui.h"
|
||||
|
||||
/*=
|
||||
Graphic User Interfaces
|
||||
3200
|
||||
**/
|
||||
|
||||
// Introduction
|
||||
/**
|
||||
Raydium provides a support for simple GUI definitions thru a set of
|
||||
functions (RayPHP interface is available).
|
||||
Raydium's GUI are themable, using ".gui" theme text files. A default "full"
|
||||
theme is provided as "theme-raydium2.gui" (and suitable ".tga" file) on the
|
||||
data repository.
|
||||
Complete informations about theme building are readable in this file.
|
||||
**/
|
||||
|
||||
// Vocabulary
|
||||
/**
|
||||
This API will allow declaration of:
|
||||
- "widgets" (label, button, edit box, track bar, check box, combo box, zone)
|
||||
- "windows" (containers for widgets)
|
||||
|
||||
"Focus" is supported for windows and widgets. The final user will not have
|
||||
any control on windows focus. "Tab" key is used for widget focus cycling.
|
||||
|
||||
Widgets and windows are identified by a name or by a unique numeric id.
|
||||
**/
|
||||
|
||||
|
||||
// Building
|
||||
/**
|
||||
The idea is simple: build a window (position and size), and create
|
||||
widgets over this window.
|
||||
All widgets are created using the current sizes (x,y and font). See
|
||||
suitable function).
|
||||
Buttons provides a simple callback, and all other widgets (but label)
|
||||
provides an unified "read" function. Window deletion is also possible.
|
||||
|
||||
You must set current theme before any of this operations (see below).
|
||||
A void(void) callback is available if you want to draw something **over**
|
||||
the GUI, named ##raydium_gui_AfterGuiDrawCallback##.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_gui_window_init(int window);
|
||||
/**
|
||||
Internal use. Will reset ##window##.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_gui_init(void);
|
||||
/**
|
||||
Internal use. Will init all GUI API. Called once by Raydium.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_gui_theme_init(void);
|
||||
/**
|
||||
Internal use. Will init theme.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_gui_theme_load(char *filename);
|
||||
/**
|
||||
This function will load and set current theme (".gui" files). You must load
|
||||
a theme by yourself, since Raydium will never do it for you.
|
||||
This function must be called before GUI building.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_gui_window_isvalid(int i);
|
||||
/**
|
||||
Mostly internal. Will check if ##i## window is valid.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_gui_window_find(char *name);
|
||||
/**
|
||||
Will search ##name## window's numeric id.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_gui_window_OnDelete(int window, void *OnDelete);
|
||||
/**
|
||||
This function sets OnDelete callback for ##window## deletion.
|
||||
This callback must follow void f(void) prototype. The call is done **before**
|
||||
window deletion.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_gui_window_OnDelete_name(char *window, void *OnDelete);
|
||||
/**
|
||||
Same as above, but using ##window## name.
|
||||
**/
|
||||
|
||||
|
||||
__rayapi signed char raydium_gui_widget_isvalid(int i, int window);
|
||||
/**
|
||||
Mostly internal. Will check if ##i## widget of ##window## is valid.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_gui_widget_find(char *name, int window);
|
||||
/**
|
||||
Will search ##name## widget numeric id (for ##window##).
|
||||
**/
|
||||
|
||||
__rayapi void raydium_gui_widget_next(void);
|
||||
/**
|
||||
Mostly internal. Cycle focus.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_gui_widget_draw_internal(GLfloat *uv, GLfloat *xy);
|
||||
/**
|
||||
Internal use. Generic drawing function.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_gui_button_draw(int w, int window);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_gui_track_draw(int w, int window);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_gui_label_draw(int w, int window);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_gui_edit_draw(int w, int window);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_gui_check_draw(int w, int window);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_gui_combo_draw(int w, int window);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_gui_zone_draw(int w, int window);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_gui_window_draw(int window);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_gui_draw(void);
|
||||
/**
|
||||
Internal use. GUI drawing callback.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_gui_button_read(int window, int widget, char *str);
|
||||
/**
|
||||
Internal use. Button read accessor (dummy).
|
||||
**/
|
||||
|
||||
__rayapi int raydium_gui_button_write(int window, int widget, char *str);
|
||||
/**
|
||||
Internal use. Button write accessor.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_gui_label_read(int window, int widget, char *str);
|
||||
/**
|
||||
Internal use. Label read accessor (dummy).
|
||||
**/
|
||||
|
||||
__rayapi int raydium_gui_label_write(int window, int widget, char *str);
|
||||
/**
|
||||
Internal use. Label write accessor.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_gui_track_read(int window, int widget, char *str);
|
||||
/**
|
||||
Internal use. Track read accessor.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_gui_track_write(int window, int widget, int value);
|
||||
/**
|
||||
Internal use. Track write accessor.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_gui_edit_read(int window, int widget, char *str);
|
||||
/**
|
||||
Internal use. Edit read accessor.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_gui_edit_write(int window, int widget, char *str);
|
||||
/**
|
||||
Internal use. Edit write accessor.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_gui_check_read(int window, int widget, char *str);
|
||||
/**
|
||||
Internal use. Check read accessor.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_gui_check_write(int window, int widget, int value);
|
||||
/**
|
||||
Internal use. Check write accessor.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_gui_combo_read(int window, int widget, char *str);
|
||||
/**
|
||||
Internal use. Combo read accessor.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_gui_combo_write(int window, int widget, int value);
|
||||
/**
|
||||
Internal use. Combo write accessor.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_gui_zone_read(int window, int widget, char *str);
|
||||
/**
|
||||
Internal use. Zone read accessor.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_gui_show(void);
|
||||
/**
|
||||
Will show current built GUI.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_gui_hide(void);
|
||||
/**
|
||||
Will hide current built GUI. This is the default state.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_gui_isvisible(void);
|
||||
/**
|
||||
Will return current visibility of GUI.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_gui_window_delete(int window);
|
||||
/**
|
||||
Will delete ##window##. No further access to widgets is possible.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_gui_window_delete_name(char *window);
|
||||
/**
|
||||
Same as above, but using ##window##'s name.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_gui_widget_sizes(GLfloat sizex, GLfloat sizey, GLfloat font_size);
|
||||
/**
|
||||
Each widget is created using 3 size: X size, Y size and font size. This
|
||||
function will allow you to set all sizes for a widget or a group of widget.
|
||||
Unit: percents (screen)
|
||||
**/
|
||||
|
||||
__rayapi int raydium_gui_window_create(char *name, GLfloat px, GLfloat py, GLfloat sizex, GLfloat sizey);
|
||||
/**
|
||||
Obviously, this function will create a new window. This window will take focus
|
||||
and overlap any previous window.
|
||||
##px## and ##py## for X and Y position on the screen, and ##sizex## and ##sizey##
|
||||
for sizes, obviously.
|
||||
Unit: percents (screen)
|
||||
**/
|
||||
|
||||
__rayapi int raydium_gui_internal_object_create(char *name, int window, signed char type, GLfloat px, GLfloat py, GLfloat sizex, GLfloat sizey, GLfloat font_size);
|
||||
/**
|
||||
Internal use.
|
||||
Small (and ugly) tip: you can build many widgets with the same name, prefixing
|
||||
the name with '*'.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_gui_button_create(char *name, int window, GLfloat px, GLfloat py, char *caption, void *OnClick);
|
||||
/**
|
||||
This function will create a new button, with ##name## and with ##window## for
|
||||
parent.
|
||||
You need to provide a ##caption## ("title") and a OnClick callback function.
|
||||
This callback must follow this prototype:
|
||||
%%(c)void btnButtonClick(raydium_gui_Object *w)%%
|
||||
You can find ##raydium_gui_Object## structure declaration in ##raydium/gui.h##,
|
||||
if needed.
|
||||
|
||||
Unit for position (##px## and ##py##): percents (**window**)
|
||||
**/
|
||||
|
||||
__rayapi int raydium_gui_button_create_simple(char *name, int window, GLfloat px, GLfloat py, char *caption);
|
||||
/**
|
||||
Same as above, but no OnClick callback function is asked. This type of button
|
||||
is "readable" thru ##raydium_gui_button_clicked()##.
|
||||
**/
|
||||
|
||||
|
||||
__rayapi int raydium_gui_label_create(char *name, int window, GLfloat px, GLfloat py, char *caption, GLfloat r, GLfloat g, GLfloat b);
|
||||
/**
|
||||
This function will create a new label, with ##name## and with ##window## for
|
||||
parent.
|
||||
You need to provide a ##caption## ("title") and an RGB color (0..1 interval)
|
||||
|
||||
Unit for position (##px## and ##py##): percents (**window**)
|
||||
**/
|
||||
|
||||
__rayapi int raydium_gui_track_create(char *name, int window, GLfloat px, GLfloat py, int min, int max, int current);
|
||||
/**
|
||||
This function will create a new trackbar, with ##name## and with ##window## for
|
||||
parent.
|
||||
You need to provide a ##min## interger value, a ##max## and ##current## value.
|
||||
|
||||
Unit for position (##px## and ##py##): percents (**window**)
|
||||
**/
|
||||
|
||||
__rayapi int raydium_gui_edit_create(char *name, int window, GLfloat px, GLfloat py, char *default_text);
|
||||
/**
|
||||
This function will create a new edit box, with ##name## and with ##window##
|
||||
for parent.
|
||||
You may provide a default text (or an empty string), if needed. Unless all
|
||||
others Raydium's data, max string length is ##RAYDIUM_GUI_DATASIZE## and
|
||||
not ##RAYDIUM_MAX_NAME_LEN##, since this component may handle bigger strings.
|
||||
See ##raydium/gui.h## for more informations.
|
||||
|
||||
Unit for position (##px## and ##py##): percents (**window**)
|
||||
**/
|
||||
|
||||
__rayapi int raydium_gui_check_create(char *name, int window, GLfloat px, GLfloat py, char *caption, signed char checked);
|
||||
/**
|
||||
This function will create a new check box, with ##name## and with ##window##
|
||||
for parent.
|
||||
You need to provide a ##caption## ("title") and a boolean state (checked or not).
|
||||
|
||||
Unit for position (##px## and ##py##): percents (**window**)
|
||||
**/
|
||||
|
||||
__rayapi int raydium_gui_combo_create(char *name, int window, GLfloat px, GLfloat py, char *items, int current);
|
||||
/**
|
||||
This function will create a new edit box, with ##name## and with ##window##
|
||||
for parent.
|
||||
##items## is a string, using '\n' as a separator. It's allowed to create an
|
||||
empty item.
|
||||
##current## is the default selected item in ##items##. (first = 0)
|
||||
Unless all others Raydium's data, max string length is ##RAYDIUM_GUI_DATASIZE##
|
||||
and not ##RAYDIUM_MAX_NAME_LEN##, since this component may handle bigger
|
||||
strings. See ##raydium/gui.h## for more informations.
|
||||
|
||||
Unit for position (##px## and ##py##): percents (**window**)
|
||||
**/
|
||||
|
||||
__rayapi int raydium_gui_zone_create(char *name, int window, GLfloat px, GLfloat py, GLfloat sx, GLfloat sy, int tag, void *OnClick);
|
||||
/**
|
||||
This function will create a "zone" with ##name## and with ##window## for
|
||||
parent. A zone will act like a button, but will highlight a rectangular area
|
||||
of the window.
|
||||
|
||||
This widget will return its ##tag## when you'll read it, and will
|
||||
update ##raydium_gui_button_clicked()## value when clicked.
|
||||
|
||||
Unit for position/size (##px##, ##py##, ##sx## and ##sy##): percents (**window**)
|
||||
**/
|
||||
|
||||
__rayapi int raydium_gui_read(int window, int widget, char *str);
|
||||
/**
|
||||
Use this function to get ##widget##'s state (for ##window##).
|
||||
This function will always return this information thru two variable:
|
||||
an integer (returned value) and a string (##str##).
|
||||
This information is specific to ##widget##'s type (checked or not for a
|
||||
checkbox, current choice for a combo, current string for an edit box, ...)
|
||||
Please, note ##str## must be allocated before function call. This is also
|
||||
the case for PHP scripts :
|
||||
%%(php)
|
||||
$str=str_pad("",256); // "pre-alloc"
|
||||
$val=raydium_gui_read_name("main","track",$str);
|
||||
echo "value=$val, string='$str'";
|
||||
%%
|
||||
**/
|
||||
|
||||
__rayapi int raydium_gui_read_name(char *window, char *widget, char *str);
|
||||
/**
|
||||
Same as above, but ##window## and ##widget## are resolved thru names, and
|
||||
not numeric id.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_gui_read_widget(raydium_gui_Object *w, char *str);
|
||||
/**
|
||||
Same as ##raydium_gui_read()##, but using a ##raydium_gui_Object## pointer.
|
||||
Useful for button callbacks, for example.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_gui_write(int window, int widget, char *str, int value);
|
||||
/**
|
||||
With this function, you can change the value of a ##widget## on a ##window##.
|
||||
- With buttons, you must use ##str## to change caption.
|
||||
- With labels, you must use ##str## to change caption.
|
||||
- With tracks, you must use ##value## to change the current value.
|
||||
- With edits, you must use ##str## to change text.
|
||||
- With cheks, you must use ##value##: ##1## means "checked", ##0## "unchecked".
|
||||
- With combos, you must use ##value## as an ID to change wich entry is selected.
|
||||
|
||||
Returns 1 when all is OK, 0 when it fails and -1 when nothing was changed.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_gui_write_name(char *window, char *widget, char *str, int value);
|
||||
/**
|
||||
Same as above, but ##window## and ##widget## are resolved thru names, and
|
||||
not numeric id.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_gui_button_clicked(void);
|
||||
/**
|
||||
This function will return the id of the last clicked button,
|
||||
or -1 if none were clicked.
|
||||
The id is built like this : ##window * 1000 + widget_id##
|
||||
Usefull for PHP scripts, since it's not possible to create callback for
|
||||
buttons with RayPHP.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_gui_list_id(char *item, char *list);
|
||||
/**
|
||||
This function will return ##item##'s id in ##list##. Returns -1 if not found.
|
||||
Useful for combo index, for example.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_gui_widget_focus(int widget, int window);
|
||||
/**
|
||||
Sets focus on ##widget## for ##window##.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_gui_widget_focus_name(char *widget, char *window);
|
||||
/**
|
||||
Same as above, but using widget and window names
|
||||
**/
|
||||
|
||||
#endif
|
77
raydium/headers/hdr.h
Normal file
77
raydium/headers/hdr.h
Normal file
@ -0,0 +1,77 @@
|
||||
#ifndef _HDR_H
|
||||
#define _HDR_H
|
||||
|
||||
/*=
|
||||
Pseudo HDR
|
||||
4300
|
||||
**/
|
||||
|
||||
// Introduction
|
||||
/**
|
||||
**/
|
||||
|
||||
__rayapi void raydium_hdr_init(void);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_hdr_enable(void);
|
||||
/**
|
||||
**/
|
||||
|
||||
__rayapi void raydium_hdr_disable(void);
|
||||
/**
|
||||
**/
|
||||
|
||||
__rayapi void raydium_hdr_internal_window_malloc(void);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_hdr_block(signed char blocking);
|
||||
/**
|
||||
**/
|
||||
|
||||
__rayapi void raydium_hdr_blur(unsigned char *in, unsigned char *out);
|
||||
/**
|
||||
**/
|
||||
|
||||
__rayapi void raydium_hdr_map(void);
|
||||
/**
|
||||
**/
|
||||
|
||||
__rayapi void raydium_hdr_map_apply(void);
|
||||
/**
|
||||
**/
|
||||
|
||||
__rayapi void raydium_hdr_settings_color_local(GLfloat r, GLfloat g, GLfloat b, GLfloat a);
|
||||
/**
|
||||
**/
|
||||
|
||||
__rayapi void raydium_hdr_settings_color_ambient(GLfloat r, GLfloat g, GLfloat b, GLfloat a);
|
||||
/**
|
||||
**/
|
||||
|
||||
__rayapi void raydium_hdr_settings_eye(float speed, float alpha_max);
|
||||
/**
|
||||
**/
|
||||
|
||||
__rayapi void raydium_hdr_settings(GLfloat *color_local, GLfloat *color_ambient, float eye_speed, float alpha_max);
|
||||
/**
|
||||
**/
|
||||
|
||||
|
||||
__rayapi signed char raydium_hdr_texture(int texture, signed char hdr); // display lists !!
|
||||
/**
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_hdr_texture_name(char *texture, signed char hdr);
|
||||
/**
|
||||
Same as above, but using ##texture## name.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_hdr_texture_reset(void); // display lists !!
|
||||
/**
|
||||
**/
|
||||
|
||||
#endif
|
50
raydium/headers/init.h
Normal file
50
raydium/headers/init.h
Normal file
@ -0,0 +1,50 @@
|
||||
#ifndef _INIT_H
|
||||
#define _INIT_H
|
||||
/*=
|
||||
Initialization
|
||||
2400
|
||||
**/
|
||||
|
||||
// Introduction
|
||||
/**
|
||||
This file is mainly designed for internal uses, but there's anyway
|
||||
some interesting functions.
|
||||
**/
|
||||
|
||||
__rayapi char *raydium_version(void);
|
||||
/**
|
||||
Return Raydium Engine version as a static string. Format is "x.yyy".
|
||||
You can also find defines for this, named ##RAYDIUM_MAJOR## (x)
|
||||
and ##RAYDIUM_MINOR## (yyy).
|
||||
**/
|
||||
|
||||
__rayapi void raydium_init_lights (void);
|
||||
/**
|
||||
Internal use. Must be moved to light.c.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_init_objects (void);
|
||||
/**
|
||||
Internal use. Must be moved to object.c.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_init_key (void);
|
||||
/**
|
||||
Internal use. Must be moved to key.c.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_init_reset (void);
|
||||
/**
|
||||
This function is supposed to reset the whole Raydium engine:
|
||||
textures, vertices, lights, objects, ...
|
||||
Never tested yet, and probaly fails for many reasons when called more than
|
||||
one time.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_init_engine (void);
|
||||
/**
|
||||
Internal use. **Never** call this function by yourself, it may cause
|
||||
huge memory leaks.
|
||||
**/
|
||||
|
||||
#endif
|
26
raydium/headers/internal.h
Normal file
26
raydium/headers/internal.h
Normal file
@ -0,0 +1,26 @@
|
||||
#ifndef _INTERNAL_H
|
||||
#define _INTERNAL_H
|
||||
|
||||
/*=
|
||||
"Internal" informations access
|
||||
2000
|
||||
**/
|
||||
|
||||
__rayapi void raydium_internal_dump (void);
|
||||
/**
|
||||
This function is now systematically called by Raydium at application's exit,
|
||||
displaying some informations about loaded textures, objects, registered data,
|
||||
network statistics.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_internal_dump_matrix (int n);
|
||||
/**
|
||||
Dumps matrix to console.
|
||||
##n## values are:
|
||||
%%
|
||||
0 for GL_PROJECTION_MATRIX
|
||||
1 for GL_MODELVIEW_MATRIX
|
||||
%%
|
||||
**/
|
||||
|
||||
#endif
|
71
raydium/headers/joy.h
Normal file
71
raydium/headers/joy.h
Normal file
@ -0,0 +1,71 @@
|
||||
#ifndef _JOY_H
|
||||
#define _JOY_H
|
||||
/*=
|
||||
Joysticks, pads and force feedback
|
||||
3100
|
||||
**/
|
||||
|
||||
// Introduction
|
||||
/**
|
||||
Raydium supports Joysticks, joypads, steering wheels, force feedback devices,
|
||||
keyboard emulation, for Linux only.
|
||||
|
||||
Since API could change during Win32 integration, there is no particular
|
||||
documentation about this subject.
|
||||
|
||||
Interesting variables:
|
||||
%%(c)
|
||||
signed char raydium_joy_button[RAYDIUM_BUTTONS_MAX_BUTTONS];
|
||||
signed char raydium_joy_click;
|
||||
GLfloat raydium_joy_x;
|
||||
GLfloat raydium_joy_y;
|
||||
GLfloat raydium_joy_z;
|
||||
int raydium_joy;
|
||||
|
||||
char raydium_joy_n_axes;
|
||||
char raydium_joy_n_buttons;
|
||||
GLfloat raydium_joy_axis[RAYDIUM_JOY_MAX_AXIS]; // "raw" axes data
|
||||
%%
|
||||
Buttons are booleans, joy x,y and z are -1 <= (x,y,z) <= 1 and 0 means "center".
|
||||
**/
|
||||
|
||||
/*
|
||||
#define JS_EVENT_BUTTON 0x01
|
||||
#define JS_EVENT_AXIS 0x02
|
||||
#define JS_EVENT_INIT 0x80
|
||||
extern char number_of_axes, number_of_buttons;
|
||||
extern int raydium_joy_event_handle;
|
||||
#ifndef WIN32
|
||||
struct ff_effect effect_tremble;
|
||||
#endif
|
||||
extern struct ff_effect effect_tremble;
|
||||
extern char effect_tremble_state;
|
||||
extern clock_t last_event;
|
||||
*/
|
||||
|
||||
__rayapi void raydium_joy_init_vars (void);
|
||||
|
||||
__rayapi void raydium_joy_key_emul (void);
|
||||
/**
|
||||
Emulate keyboard (directional pad) with joy, if any.
|
||||
**/
|
||||
|
||||
#ifndef WIN32
|
||||
__rayapi int raydium_joy_process_event (struct js_event e);
|
||||
#endif
|
||||
__rayapi void raydium_joy_callback (void);
|
||||
__rayapi void raydium_joy_ff_autocenter (int perc);
|
||||
/**
|
||||
Set Force Feedback autocenter factor.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_joy_init (void);
|
||||
__rayapi void raydium_joy_close (void);
|
||||
__rayapi void raydium_joy_ff (void);
|
||||
__rayapi void raydium_joy_ff_tremble_set (GLfloat period, GLfloat force);
|
||||
/**
|
||||
Send tremble effect to Force Feedback device for a determined period,
|
||||
at a particular force. (no units yet).
|
||||
**/
|
||||
|
||||
#endif
|
36
raydium/headers/key.h
Normal file
36
raydium/headers/key.h
Normal file
@ -0,0 +1,36 @@
|
||||
#ifndef _KEY_H
|
||||
#define _KEY_H
|
||||
/*=
|
||||
Keyboard & keys
|
||||
1000
|
||||
**/
|
||||
|
||||
// Introduction
|
||||
/*=
|
||||
Keyboard API is already described at the top of this guide,
|
||||
see section "keyboard input".
|
||||
**/
|
||||
|
||||
__rayapi void raydium_key_normal_callback (GLuint key, int x, int y);
|
||||
/**
|
||||
Internal callback.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_key_special_callback (GLuint key, int x, int y);
|
||||
/**
|
||||
Internal callback.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_key_special_up_callback (GLuint key, int x, int y);
|
||||
/**
|
||||
Internal callback.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_key_pressed (GLuint key);
|
||||
/**
|
||||
Will return state of ##key## in the ##raydium_keys[]## array.
|
||||
This function is usefull to test keyboard from PHP, since RayPHP doest not
|
||||
support array for now.
|
||||
**/
|
||||
|
||||
#endif
|
19
raydium/headers/land.h
Normal file
19
raydium/headers/land.h
Normal file
@ -0,0 +1,19 @@
|
||||
#ifndef _LAND_H
|
||||
#define _LAND_H
|
||||
|
||||
/*=
|
||||
Land
|
||||
1800
|
||||
**/
|
||||
|
||||
// Introduction
|
||||
/**
|
||||
Historically, this file was quite complex, since Raydium was using
|
||||
his own physic. Now, this file is almost empty, since ODE integration
|
||||
now provides new landscape functions.
|
||||
**/
|
||||
|
||||
__rayapi GLfloat raydium_land_internal_landtmp (GLfloat x, GLfloat y, GLfloat phase, GLfloat ampl, GLfloat periode);
|
||||
__rayapi void raydium_land_draw_water (GLfloat phase, GLfloat ampl, GLfloat periode, int sub, GLfloat pas, char *texture);
|
||||
__rayapi GLfloat raydium_land_surface (GLfloat x, GLfloat y, GLfloat * nx, GLfloat * ny, GLfloat * nz);
|
||||
#endif
|
130
raydium/headers/light.h
Normal file
130
raydium/headers/light.h
Normal file
@ -0,0 +1,130 @@
|
||||
#ifndef _LIGHT_H
|
||||
#define _LIGHT_H
|
||||
/*=
|
||||
Lights
|
||||
900
|
||||
**/
|
||||
|
||||
// Introduction to Raydium light system
|
||||
/**
|
||||
When we starts Raydium development, the main idea was to use native OpenGL
|
||||
lights, and not lightmaps or another method.
|
||||
|
||||
This method (native lights) provides 8 simultaneous movable lights,
|
||||
and is quite effective with recent OpenGL hardware.
|
||||
|
||||
You can modify intensity, position, color, you can turn on any light at
|
||||
any time, make them blinking... Mixing all theses features can result
|
||||
many effects, as realtime sunset, flashing lights for cars, explosions, ...
|
||||
|
||||
Usage is very easy: no need to create lights, just turn them on.
|
||||
|
||||
See also: LightMaps
|
||||
**/
|
||||
|
||||
__rayapi void raydium_light_enable (void);
|
||||
/**
|
||||
Obvious.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_light_disable (void);
|
||||
/**
|
||||
Obvious.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_light_texture(int texture, signed char enable);
|
||||
/**
|
||||
Texture ##l## will not use lighting if ##enable## is set to 0. Call this
|
||||
function **before** loading any object using this texture, because
|
||||
of display lists. Same way, it's not possible to change back this value
|
||||
after the first object drawing without disabling display lists.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_light_texture_name(char *name, signed char enable);
|
||||
/**
|
||||
Same as above, but using texture ##name##.
|
||||
**/
|
||||
|
||||
__rayapi GLuint raydium_light_to_GL_light (GLuint l);
|
||||
/**
|
||||
Probably useless for end user. (internal uses)
|
||||
**/
|
||||
|
||||
__rayapi void raydium_light_on (GLuint l);
|
||||
/**
|
||||
Turns ##l## light on ( 0 <= l <= RAYDIUM_MAX_LIGHTS )
|
||||
**/
|
||||
|
||||
__rayapi void raydium_light_off (GLuint l);
|
||||
/**
|
||||
Turns ##l## light off
|
||||
**/
|
||||
|
||||
__rayapi void raydium_light_switch (GLuint l);
|
||||
/**
|
||||
Will swith ##l## light state (from "on" to "off", for example).
|
||||
**/
|
||||
|
||||
__rayapi void raydium_light_update_position (GLuint l);
|
||||
/**
|
||||
Updates ##raydium_light_position[l]## array changes to hardware.
|
||||
This function is now used internaly by Raydium,
|
||||
so you have no reasons to call it by yourself.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_light_update_position_all (void);
|
||||
/**
|
||||
See above.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_light_update_intensity (GLuint l);
|
||||
/**
|
||||
See above.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_light_update_all (GLuint l);
|
||||
/**
|
||||
See above.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_light_move (GLuint l, GLfloat * vect);
|
||||
/**
|
||||
Moves light to position ##vect## for light ##l## (vect is GLfloat[4]: x,y,z,dummy).
|
||||
|
||||
Just move your lights before camera placement, or your changes
|
||||
will be applied to the next frame only.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_light_move_3f(GLuint l,GLfloat px, GLfloat py, GLfloat pz);
|
||||
/*
|
||||
Same as above, but using 3 GLfloat values
|
||||
*/
|
||||
|
||||
__rayapi void raydium_light_conf_7f(GLuint l,GLfloat px, GLfloat py, GLfloat pz, GLfloat intensity, GLfloat r, GLfloat g, GLfloat b);
|
||||
/*
|
||||
Full settings for light ##l##: position, intensity and color, using GLfloat
|
||||
values.
|
||||
*/
|
||||
|
||||
__rayapi void raydium_light_reset (GLuint l);
|
||||
/**
|
||||
This function will restore all defaults for ##l## light.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_light_blink_internal_update (GLuint l);
|
||||
/**
|
||||
Useless for end-user.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_light_blink_start (GLuint l, int fpc);
|
||||
/**
|
||||
Makes ##l## light blinking at ##fpc## (frames per cycle) rate.
|
||||
This function will use timecalls soon ("fpc" -> "hertz")
|
||||
**/
|
||||
|
||||
__rayapi void raydium_light_callback (void);
|
||||
/**
|
||||
Useless for end-user.
|
||||
**/
|
||||
|
||||
#endif
|
204
raydium/headers/live.h
Normal file
204
raydium/headers/live.h
Normal file
@ -0,0 +1,204 @@
|
||||
#ifndef _LIVE_H
|
||||
#define _LIVE_H
|
||||
#include "../live.h"
|
||||
|
||||
|
||||
/*=
|
||||
Live textures and videos API
|
||||
3800
|
||||
**/
|
||||
|
||||
// Introduction
|
||||
/**
|
||||
Live API features two distinct parts:
|
||||
|
||||
1 - It provides an easy way to create and manage dynamic textures, since you
|
||||
just have to give a pointer to your image data, and call suitable function
|
||||
each time this image is changing.
|
||||
|
||||
2 - This API also supports video4linux (aka V4L), as an extension of
|
||||
the Live API. The main goal is to link a video4linux device (webcam,
|
||||
tv card, ...) to a texture. A callback is also available if you want to
|
||||
get (and transform) data of every capture.
|
||||
|
||||
You'll find detailed informations for each domain below.
|
||||
**/
|
||||
|
||||
|
||||
// Color conversion
|
||||
/**
|
||||
Live API used to work with RGB and RGBA color formats. Since some V4L
|
||||
devices use other patterns, Live API needs conversion functions.
|
||||
You've no need to do color conversion by yourself, consider all this
|
||||
as internal functions.
|
||||
**/
|
||||
|
||||
void v4l_copy_420_block (int yTL, int yTR, int yBL, int yBR, int u, int v, int rowPixels, unsigned char *rgb, int bits);
|
||||
/**
|
||||
YUV420P block copy.
|
||||
This code is not native.
|
||||
**/
|
||||
|
||||
int v4l_yuv420p2rgb (unsigned char *rgb_out, unsigned char *yuv_in, int width, int height, int bits);
|
||||
/**
|
||||
YUV420P to RGB conversion.
|
||||
This code is not native.
|
||||
**/
|
||||
|
||||
// Live Video API
|
||||
/**
|
||||
This part of the Live API id dedicated to video devices. For now, the
|
||||
support is limited to Linux thru V4L API. Every V4L compatible device
|
||||
should work with Live Video, but for any advanced setup of your video
|
||||
device (tuner configuration, source, FPS, ...), you must use an external
|
||||
tool.
|
||||
By default, Live API supports up to 4 simultaneous devices.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_live_video_isvalid(int i);
|
||||
/**
|
||||
Internal use, but you can call this function if you want to verify if a
|
||||
live video device id is valid (in bounds, open, and ready to capture).
|
||||
**/
|
||||
|
||||
__rayapi int raydium_live_video_find_free(void);
|
||||
/**
|
||||
Internal use.
|
||||
Finds a free live video device slot.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_live_video_open(char *device, int sizex, int sizey);
|
||||
/**
|
||||
This is where you should start. This function opens ##device## (something
|
||||
like "/dev/video0"), requesting ##sizex## x ##sizey## resolution.
|
||||
If ##device## is ##RAYDIUM_LIVE_DEVICE_AUTO##, Raydium will use a default device,
|
||||
hardcoded or given thru commande line (##--video-device##).
|
||||
Same story for sizes, with ##RAYDIUM_LIVE_SIZE_AUTO##.
|
||||
This function will try to detect a compatible palette (grayscale, rgb,
|
||||
yuv420p, with 4, 6, 8, 15, 16 and 24 bits per pixel) and capture
|
||||
method (##read()## or ##mmap()##).
|
||||
Returns -1 in case or error, device id otherwise.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_live_video_open_auto(void);
|
||||
/**
|
||||
Same as above, but with full autodetection.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_live_video_read(raydium_live_Device *dev);
|
||||
/**
|
||||
Internal V4L read function.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_internal_live_video_callback(void);
|
||||
/**
|
||||
internal frame callback.
|
||||
**/
|
||||
|
||||
// Live API Core
|
||||
/**
|
||||
the main goal of the Live API is to allow you to create your own
|
||||
dynamic textures. The first method is to provide your own picture data thru a
|
||||
pointer, the second method is to use a Live Video device (see above) as
|
||||
data source.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_internal_live_close(void);
|
||||
/**
|
||||
Internal close function.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_live_init(void);
|
||||
/**
|
||||
Internal init function.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_live_texture_isvalid(int i);
|
||||
/**
|
||||
Internal use, but you can call this function if you want to verify if a
|
||||
live texture id is valid (in bounds, open, and ready to capture).
|
||||
**/
|
||||
|
||||
__rayapi int raydium_live_texture_find_free(void);
|
||||
/**
|
||||
Internal use.
|
||||
Finds a free live texture slot.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_live_texture_find(int original_texture);
|
||||
/**
|
||||
Resolvs ##original_texture## id (native Raydium texture id) to a
|
||||
live texture id, if any.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_live_texture_create(char *as, unsigned char *data_source, int tx, int ty, int bpp);
|
||||
/**
|
||||
Create a new Live Texture with ##as## name. You must provide a ##data_source##
|
||||
with RGB or RGBA format, with ##tx## and ##ty## size.
|
||||
Possible bpp values are 24 (RGB) and 32 (RGBA).
|
||||
Returns the live texture id, or -1 when it fails.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_live_texture_video(int device_id, char *as);
|
||||
/**
|
||||
This is another way to create a Live Texture, but using a Live Video device
|
||||
for data source. Provide texture name (##as##) and Live ##device_id##.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_live_texture_refresh(int livetex);
|
||||
/**
|
||||
When your data source have changed, call this function to refresh new
|
||||
data to hardware. Obviously, this function is useless for Live Video textures
|
||||
since Raydium will automatically refresh data.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_live_texture_refresh_name(char *texture);
|
||||
/**
|
||||
Same as above, but using ##texture## name.
|
||||
**/
|
||||
|
||||
|
||||
__rayapi void raydium_live_texture_refresh_callback_set(int livetex, void *callback);
|
||||
/**
|
||||
You can create a "OnRefresh" callback for any Live Texture (##livetex## is an
|
||||
id to this texture). This is mostly usefull for Live Video texture.
|
||||
Your callback must follow this prototype :
|
||||
##int refresh_callback(unsigned char *data, int tx, int ty, int bpp)##
|
||||
You have full write access to ##data##, allowing you to draw over
|
||||
the provided picture (warning: for non video Live textures, ##data## pointer
|
||||
is not owned by Raydium and may be "read only")
|
||||
You must return 1 to confirm data flushing, or 0 to cancel this refresh.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_live_texture_refresh_callback_set_name(char *texture, void *callback);
|
||||
/**
|
||||
Same as above, but using ##texture## name.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_live_texture_mask(int livetex, GLfloat alpha);
|
||||
/**
|
||||
This function will draw a fullscreen mask using ##livetex## Live Texture id and
|
||||
##alpha## opacity (0 means transparent, 1 means fully opaque, allowing any
|
||||
intermediate value). Use this function at any place of your rendering
|
||||
function AFTER camera call and obviously before ##raydium_rendering_finish##.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_live_texture_mask_name(char *texture, GLfloat alpha);
|
||||
/**
|
||||
Same as above, but using ##texture## name.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_live_texture_draw(int livetex, GLfloat alpha,GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2);
|
||||
/**
|
||||
This function is a clone of ##raydium_osd_draw()##, dedicated to live textures.
|
||||
This function will draw the video ##livetex## on the screen, from (x1,y1) to
|
||||
(x2,y2).
|
||||
**/
|
||||
|
||||
__rayapi void raydium_live_texture_draw_name(char *texture, GLfloat alpha,GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2);
|
||||
/**
|
||||
Same as above, but using ##texture## name.
|
||||
**/
|
||||
|
||||
#endif
|
||||
|
31
raydium/headers/log.h
Normal file
31
raydium/headers/log.h
Normal file
@ -0,0 +1,31 @@
|
||||
#ifndef _LOG_H
|
||||
#define _LOG_H
|
||||
|
||||
/*=
|
||||
Logging
|
||||
300
|
||||
**/
|
||||
|
||||
// Introduction to log.c
|
||||
/**
|
||||
Raydium uses and provides his own logging system,
|
||||
hidden behind a single function, as shown below.
|
||||
**/
|
||||
|
||||
#ifndef RAYDIUM_NETWORK_ONLY
|
||||
__rayapi void raydium_console_line_add (char *format, ...);
|
||||
#endif
|
||||
__rayapi void raydium_log (char *format, ...);
|
||||
/**
|
||||
This function must be used like "printf", using a format
|
||||
("%s, %i, %x, ...") and then, suitable variables,
|
||||
but without the end-line char ('\n')
|
||||
|
||||
%%(c)
|
||||
raydium_log("You are player %i, %s",player_number,player_name);
|
||||
%%
|
||||
|
||||
For now, this function writes to the parent terminal and the in-game console, with "Raydium: " string prefix.
|
||||
The user can force logging to a file, using ##--logfile## command line switch.
|
||||
**/
|
||||
#endif
|
369
raydium/headers/main.h
Normal file
369
raydium/headers/main.h
Normal file
@ -0,0 +1,369 @@
|
||||
/*=
|
||||
Introduction to Raydium
|
||||
100
|
||||
**/
|
||||
|
||||
// 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,
|
||||
and [[GLU]]: 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 a "clean" (nearly [[ANSI]]) code,
|
||||
and, in facts, we have been able to compile Raydium under Visual Studio (Windows)
|
||||
and mingw with a very few modifications.
|
||||
So you can expect a correct result on any system providing
|
||||
OpenGL (at least 1.2), [[GLU]] and a C compiler. Using Raydium as a shared
|
||||
library (.so or DLL), you can also use C++ language for you own applications
|
||||
|
||||
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, reflections, and more, but also provides everything for indoor,
|
||||
with radiosity lightmaps for example.
|
||||
|
||||
Some other advanced features are available : physics, scripting,
|
||||
live video, transparent networking, GUI, shaders, ...
|
||||
|
||||
This features list will probably grow up during Raydium developpement, see
|
||||
Raydium website: http://raydium.org/
|
||||
|
||||
You'll find, in this document, a list of many functions and possibilities
|
||||
of [[Raydium]], but if it's your first view of Raydium, you should
|
||||
start with tutorials ( http://wiki.raydium.org/wiki/RaydiumTutorials ) and
|
||||
packaged demo programs.
|
||||
|
||||
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]]: common.c
|
||||
**/
|
||||
|
||||
|
||||
// Defines
|
||||
/**
|
||||
As mentioned above, the file common.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 common.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.
|
||||
|
||||
===generic limits===
|
||||
|
||||
The first #define block determine limits of your application,
|
||||
and here you are the actual values for basic defines:
|
||||
%%(c)
|
||||
#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
|
||||
%%
|
||||
|
||||
- As you may expect, ##MAX_VERTICES## defines the amount of memory you'll
|
||||
waste with vertex tables. These tables will contain all loaded objects,
|
||||
then remember each time you draw something (object),
|
||||
[[Raydium]] loads it (if not already done). Currently, there is no "delete"
|
||||
mechanism implemented (except by deleting all objects).
|
||||
Let me give you a scale: with an Athlon XP1900+, [[GeForce]] 3,
|
||||
actual [[Raydium]] devel. version 0.31, with around 100 000 vertices,
|
||||
losts of options (sky, blending, 2 lights, 15 textures, ...),
|
||||
Raydium renders ~ 45 FPS. Beyond this, a very correct object uses less
|
||||
than 10 000 vertices. So 500 000 vertices, the actual default,
|
||||
is quite large. It's also important to talk about memory: Linux is
|
||||
very efficient on this point, and allocates only "really used" memory.
|
||||
Under Linux, with the above scene, Raydium used about 20 MB (data only),
|
||||
instead of "much more" (~ 5x). I haven't made any test about this under
|
||||
Windows, but we can expect worse results.
|
||||
|
||||
- There's nothing really important to say about ##MAX_TEXTURES##,
|
||||
since that doesn't influence the amount of memory used. You are not
|
||||
limited to 8 bits values, but 256 seems very comfortable (and you must
|
||||
pay attention to the capacities of your 3D hardware !)
|
||||
|
||||
- The next define, ##MAX_LIGHTS## is very important: OpenGL, for now
|
||||
(version 1.3 and lower), impose 8 lights at least, and all current
|
||||
hardware doesn't manage more. If this situation is likely to evolve,
|
||||
we will move this #define to a variable, and will ask hardware for its
|
||||
capacities at initialization, but, for the moment, do not exceed 8.
|
||||
|
||||
- Next, ##NAME_LEN##, limits the maximum length of strings (textures and
|
||||
objects names) used by Raydium. Default value should be perfect.
|
||||
(avoid higher values, since it could slow down name searches)
|
||||
|
||||
- ##MAX_OBJECTS## use the same mechanism as ##MAX_TEXTURES##, and addition
|
||||
with the fact that hardware is not concerned, it can be ignored.
|
||||
|
||||
===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.
|
||||
**/
|
||||
|
||||
// Basic vars
|
||||
/**
|
||||
|
||||
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.
|
||||
|
||||
===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 and 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:
|
||||
|
||||
- ##GLUT_KEY_F1## to ##GLUT_KEY_F12##
|
||||
- ##GLUT_KEY_LEFT##, ##GLUT_KEY_RIGHT##, ##GLUT_KEY_UP##, ##GLUT_KEY_DOWN##
|
||||
- ##GLUT_KEY_PAGE_UP##, ##GLUT_KEY_PAGE_DOWN##
|
||||
- ##GLUT_KEY_HOME##, ##GLUT_KEY_END##, ##GLUT_KEY_INSERT##
|
||||
|
||||
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:
|
||||
%%(c) if(raydium_key[GLUT_KEY_UP]) move_car(); %%
|
||||
|
||||
Yes, it's easy. You can also use
|
||||
%%(c) 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 :)
|
||||
|
||||
===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]] implementations 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_click## for the last click
|
||||
value. (generated one time per click)
|
||||
Raydium will now use 4 (up) and 5 (down) for mouse wheel, if any.
|
||||
|
||||
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.
|
||||
|
||||
===Textures===
|
||||
|
||||
##raydium_texture_index## and ##raydium_texture_current_main## (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 this is 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.
|
||||
Good 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.
|
||||
|
||||
===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 common.c says:
|
||||
|
||||
%%(c)
|
||||
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've 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<36>, up to 90<39> 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)
|
||||
|
||||
===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 a 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.
|
||||
|
||||
===Vertices===
|
||||
|
||||
Vertices data structure is distributed in 4 parts:
|
||||
|
||||
- ##raydium_vertex_*## : these tables will simply contains vertices coordinates
|
||||
|
||||
- ##raydium_vertex_normal_*## : vertices normals. Raydium will maintain
|
||||
two distinct normal tables, and this one will be used for calculations.
|
||||
|
||||
- ##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.
|
||||
|
||||
- ##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.
|
||||
|
||||
===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.
|
||||
|
||||
===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.
|
||||
|
||||
You should read the chapter dedicated to lights for more information.
|
||||
|
||||
===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.
|
||||
|
||||
===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.
|
||||
|
||||
**/
|
60
raydium/headers/misc.h
Normal file
60
raydium/headers/misc.h
Normal file
@ -0,0 +1,60 @@
|
||||
// This file is a footer for Raydium documention
|
||||
// No compilation is required.
|
||||
|
||||
/*=
|
||||
Miscalleneous
|
||||
9000
|
||||
**/
|
||||
|
||||
// License
|
||||
/**
|
||||
Raydium engine and provided applications are released under GPL version 2.
|
||||
You can found the original text of this license here :
|
||||
http://www.gnu.org/licenses/gpl.txt
|
||||
**/
|
||||
|
||||
// About CQFD Corp Raydium Team
|
||||
/**
|
||||
Alphabetical order:
|
||||
batcox, Blue Prawn, Cocorobix, FlexH, Jimbo, manproc, Mildred, neub, RyLe,
|
||||
vicente, whisky, willou, Xfennec, Yoltie.
|
||||
**/
|
||||
|
||||
// Todo
|
||||
/**
|
||||
No particular order:
|
||||
- rendering core rewrite
|
||||
- self-running demo
|
||||
- (idea from RyLe) 'rayphp/' scripts integration into the binary (and why
|
||||
not, a "PACK style" support).
|
||||
- more network stack optimisations (UDP reads, mainly)
|
||||
- better organisation of comp.sh and ocomp.sh files (separate options
|
||||
and build process)
|
||||
|
||||
See also my todo: http://wiki.raydium.org/wiki/XfenneC
|
||||
|
||||
Please, if you start working on a feature, say it on the Wiki.
|
||||
**/
|
||||
|
||||
// Links
|
||||
/**
|
||||
http://raydium.org (Raydium home)
|
||||
svn://raydium.org/raydium/trunk (SVN trunk)
|
||||
http://raydium.org/svn.php (SVN "live" changelog)
|
||||
http://memak.raydium.org (MeMak forum: "a game using Raydium", french)
|
||||
http://www.cqfd-corp.org (CQFD homesite)
|
||||
mailto:xfennec -AT- cqfd-corp.org
|
||||
**/
|
||||
|
||||
// Greets
|
||||
/**
|
||||
**RyLe**: original implementation of sound.c (OpenAL core sound API)
|
||||
|
||||
**BatcoX**: export of RayODE functions into RayPHP (reg_api.c)
|
||||
and additional PHP wrappers (wrappers.c)
|
||||
|
||||
**Mildred**: header and Makefile generator, dynamic version of
|
||||
Raydium (.so and .a) for Linux.
|
||||
**/
|
||||
|
||||
// The end !
|
58
raydium/headers/mouse.h
Normal file
58
raydium/headers/mouse.h
Normal file
@ -0,0 +1,58 @@
|
||||
#ifndef _MOUSE_H
|
||||
#define _MOUSE_H
|
||||
/*=
|
||||
Mouse
|
||||
1100
|
||||
**/
|
||||
|
||||
// Introduction
|
||||
/**
|
||||
Mouse API is almost explainded at the top of this guide, but here it
|
||||
is some other usefull functions (macros, in facts)
|
||||
**/
|
||||
|
||||
|
||||
#define raydium_mouse_hide() glutSetCursor(GLUT_CURSOR_NONE);
|
||||
/**
|
||||
Hides mouse cursor.
|
||||
**/
|
||||
|
||||
#define raydium_mouse_show() glutSetCursor(GLUT_CURSOR_LEFT_ARROW);
|
||||
/**
|
||||
Shows mouse cursor.
|
||||
**/
|
||||
|
||||
#define raydium_mouse_move(x,y) glutWarpPointer((x),(y))
|
||||
/**
|
||||
Moves cursor to (##x##,##y##) position (in pixel).
|
||||
Example if you want to move cursor at window's center:
|
||||
%%(c)raydium_mouse_move(raydium_window_tx/2, raydium_window_ty/2);%%
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_mouse_isvisible(void);
|
||||
/**
|
||||
Returns true or false (0 or 1), if the mouse is visible or not.
|
||||
See ##raydium_mouse_show()## and ##raydium_mouse_hide()## above.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_mouse_init (void);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_mouse_click_callback (int but, int state, int x, int y);
|
||||
/**
|
||||
Internal callback.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_mouse_move_callback (int x, int y);
|
||||
/**
|
||||
Internal callback.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_mouse_button_pressed (int button);
|
||||
/**
|
||||
returns ##button## state. (See first part of this document)
|
||||
**/
|
||||
|
||||
#endif
|
94
raydium/headers/myglut.h
Normal file
94
raydium/headers/myglut.h
Normal file
@ -0,0 +1,94 @@
|
||||
/*
|
||||
Raydium - CQFD Corp.
|
||||
http://raydium.org/
|
||||
License: GPL - GNU General Public License, see "gpl.txt" file.
|
||||
*/
|
||||
|
||||
// avoid "real GLUT"
|
||||
#ifndef GLUT_API_VERSION
|
||||
#ifndef MYGLUT
|
||||
#define MYGLUT
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
|
||||
#define GLUT_LEFT_BUTTON 0
|
||||
#define GLUT_MIDDLE_BUTTON 1
|
||||
#define GLUT_RIGHT_BUTTON 2
|
||||
|
||||
#define GLUT_DOWN 0
|
||||
#define GLUT_UP 1
|
||||
|
||||
#define GLUT_KEY_F1 1
|
||||
#define GLUT_KEY_F2 2
|
||||
#define GLUT_KEY_F3 3
|
||||
#define GLUT_KEY_F4 4
|
||||
#define GLUT_KEY_F5 5
|
||||
#define GLUT_KEY_F6 6
|
||||
#define GLUT_KEY_F7 7
|
||||
#define GLUT_KEY_F8 8
|
||||
#define GLUT_KEY_F9 9
|
||||
#define GLUT_KEY_F10 10
|
||||
#define GLUT_KEY_F11 11
|
||||
#define GLUT_KEY_F12 12
|
||||
#define GLUT_KEY_LEFT 100
|
||||
#define GLUT_KEY_UP 101
|
||||
#define GLUT_KEY_RIGHT 102
|
||||
#define GLUT_KEY_DOWN 103
|
||||
#define GLUT_KEY_PAGE_UP 104
|
||||
#define GLUT_KEY_PAGE_DOWN 105
|
||||
#define GLUT_KEY_HOME 106
|
||||
#define GLUT_KEY_END 107
|
||||
#define GLUT_KEY_INSERT 108
|
||||
|
||||
#define GLUT_WINDOW_WIDTH 102
|
||||
#define GLUT_WINDOW_HEIGHT 103
|
||||
#define GLUT_WINDOW_DEPTH_SIZE 106
|
||||
#define GLUT_WINDOW_CURSOR 122
|
||||
|
||||
#define GLUT_CURSOR_LEFT_ARROW 1
|
||||
#define GLUT_CURSOR_NONE 101
|
||||
|
||||
#define GLUT_RGB 0
|
||||
#define GLUT_DOUBLE 2
|
||||
#define GLUT_DEPTH 16
|
||||
|
||||
#define GLUT_GAME_MODE_POSSIBLE 1
|
||||
|
||||
// ------------------- variables
|
||||
|
||||
// callbacks:
|
||||
void (*glutReshapeFuncCB)(int width, int height);
|
||||
void (*glutKeyboardFuncCB)(unsigned char key, int x, int y);
|
||||
void (*glutSpecialUpFuncCB)(int key, int x, int y);
|
||||
void (*glutSpecialFuncCB)(int key, int x, int y);
|
||||
void (*glutMotionFuncCB)(int x, int y);
|
||||
void (*glutPassiveMotionFuncCB)(int x, int y);
|
||||
void (*glutMouseFuncCB)(int button, int state, int x, int y);
|
||||
void (*glutDisplayFuncCB)(void);
|
||||
void (*glutIdleFuncCB)(void);
|
||||
|
||||
// protos
|
||||
__rayapi void glutInit(int *argc, char **argv);
|
||||
__rayapi int glutGet(int enu);
|
||||
__rayapi void glutSetCursor(int cursor);
|
||||
__rayapi void glutWarpPointer(int x, int y);
|
||||
__rayapi void glutSwapBuffers(void);
|
||||
__rayapi void glutIgnoreKeyRepeat(int ignore);
|
||||
__rayapi void glutReshapeFunc(void *func);
|
||||
__rayapi void glutKeyboardFunc(void *func);
|
||||
__rayapi void glutSpecialUpFunc(void *func);
|
||||
__rayapi void glutSpecialFunc(void *func);
|
||||
__rayapi void glutMotionFunc(void *func);
|
||||
__rayapi void glutPassiveMotionFunc(void *func);
|
||||
__rayapi void glutMouseFunc(void *func);
|
||||
__rayapi void glutDisplayFunc(void *func);
|
||||
__rayapi void glutIdleFunc(void *func);
|
||||
__rayapi int glutExtensionSupported(const char *name);
|
||||
__rayapi void glutMainLoop(void);
|
||||
__rayapi void glutWireSphere(GLdouble radius, GLint slices, GLint stacks);
|
||||
__rayapi void myglutCreateWindow(GLuint tx, GLuint ty, signed char rendering, char *name);
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
514
raydium/headers/network.h
Normal file
514
raydium/headers/network.h
Normal file
@ -0,0 +1,514 @@
|
||||
#ifndef _NETWORK_H
|
||||
#define _NETWORK_H
|
||||
/*=
|
||||
Network
|
||||
2800
|
||||
**/
|
||||
|
||||
// Bases of Raydium's networking API
|
||||
/**
|
||||
Raydium supports networking via UDP/IP, providing high level functions
|
||||
for multiplayer game development.
|
||||
Raydium servers are limited to 256 clients for now.
|
||||
|
||||
You will find in network.c a set of "low level" functions and vars dedicated to
|
||||
networked games: players names, event callbacks, UDP sockets,
|
||||
broadcasts, ...
|
||||
See a few chapters below for higher level functions.
|
||||
|
||||
All this is ready to use. As it's not done in the introduction of this
|
||||
guide, We will explain here some variables defined in common.h.
|
||||
|
||||
%%(c)
|
||||
#define RAYDIUM_NETWORK_PORT 29104
|
||||
#define RAYDIUM_NETWORK_PACKET_SIZE 230
|
||||
#define RAYDIUM_NETWORK_TIMEOUT 5
|
||||
#define RAYDIUM_NETWORK_PACKET_OFFSET 4
|
||||
#define RAYDIUM_NETWORK_MAX_CLIENTS 8
|
||||
#define RAYDIUM_NETWORK_MODE_NONE 0
|
||||
#define RAYDIUM_NETWORK_MODE_CLIENT 1
|
||||
#define RAYDIUM_NETWORK_MODE_SERVER 2
|
||||
%%
|
||||
|
||||
Here, we can find network port declaration (Raydium will use only one
|
||||
port, allowing easy port forwarding management, if needed), default timeout
|
||||
(unit: second), and the three mode possible for a Raydium application.
|
||||
|
||||
But there is also two other very important defines: packet size
|
||||
(unit: byte) and max number of clients.. This is important because
|
||||
Raydium uses UDP sockets, and UDP sockets required fixed
|
||||
length packets, and as you need to set packet size as small as possible
|
||||
(for obvious speed reasons), you must calculate you maximum
|
||||
information packet size (players position, for example), multiply
|
||||
it by ##RAYDIUM_NETWORK_MAX_CLIENTS##,and add ##RAYDIUM_NETWORK_PACKET_OFFSET##
|
||||
wich represent the required header of the packet.
|
||||
|
||||
It's more easy than it seems, look:
|
||||
//
|
||||
My game will support 8 players.
|
||||
I will send players state with 3 floats (x,y,z).
|
||||
My packet size must be: 8*3*sizeof(float)+RAYDIUM_NETWORK_PACKET_OFFSET = 100 bytes.
|
||||
//
|
||||
Please, do not change packet offset size, since Raydium will use it
|
||||
for packet header.
|
||||
|
||||
%%(c)
|
||||
#define RAYDIUM_NETWORK_DATA_OK 1
|
||||
#define RAYDIUM_NETWORK_DATA_NONE 0
|
||||
#define RAYDIUM_NETWORK_DATA_ERROR -1
|
||||
%%
|
||||
|
||||
This three defines are used as network functions result:
|
||||
|
||||
%%(c)
|
||||
if(raydium_network_read_flushed(&id,&type,buff)==RAYDIUM_NETWORK_DATA_OK)
|
||||
{
|
||||
...
|
||||
%%
|
||||
|
||||
%%(c) #define RAYDIUM_NETWORK_PACKET_BASE 20 %%
|
||||
|
||||
In most network functions, you will find a "type" argument, used to
|
||||
determine packet goal. This type is 8 bits long (256 possible values),
|
||||
but Raydium is already using some of them. So you can use
|
||||
##RAYDIUM_NETWORK_PACKET_BASE## as a base for your own types:
|
||||
|
||||
%%(c)
|
||||
#define NORMAL_DATA RAYDIUM_NETWORK_PACKET_BASE
|
||||
#define BALL_TAKEN (NORMAL_DATA+1)
|
||||
#define SCORE_INFO (NORMAL_DATA+2)
|
||||
#define HORN (NORMAL_DATA+3)
|
||||
...
|
||||
%%
|
||||
|
||||
===Variables:===
|
||||
|
||||
Your own player id (0<= id < RAYDIUM_NETWORK_MAX_CLIENTS),
|
||||
read only: ##int raydium_network_uid;##
|
||||
Special value "-1" means that you're not connected (see below).
|
||||
|
||||
Current network mode (none, client, server),
|
||||
read only: ##signed char raydium_network_mode;##
|
||||
|
||||
Boolean used to determine client state (connected or not), read only:
|
||||
##signed char raydium_network_client[RAYDIUM_NETWORK_MAX_CLIENTS];##
|
||||
|
||||
example:
|
||||
%%(c)
|
||||
if(raydium_network_client[4])
|
||||
draw_player(4);
|
||||
%%
|
||||
|
||||
Can be used by a server to send data to his clients. Read only:
|
||||
##struct sockaddr raydium_network_client_addr[RAYDIUM_NETWORK_MAX_CLIENTS];##
|
||||
|
||||
Players names, read only:
|
||||
##char raydium_network_name[RAYDIUM_NETWORK_MAX_CLIENTS][RAYDIUM_MAX_NAME_LEN];##
|
||||
|
||||
##OnConnect## and ##OnDisconnect## events (server only):
|
||||
##void * raydium_network_on_connect;
|
||||
void * raydium_network_on_disconnect;##
|
||||
|
||||
You can place your owns callbacks (##void(int)##) on these events, as in
|
||||
this example:
|
||||
|
||||
%%(c)
|
||||
void new_client(int client)
|
||||
{
|
||||
raydium_log("New player: %s", raydium_network_nameclient);
|
||||
}
|
||||
|
||||
...
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
...
|
||||
raydium_network_on_connect=new_client;
|
||||
...
|
||||
%%
|
||||
**/
|
||||
|
||||
// Reliablility versus Speed
|
||||
/**
|
||||
As explained above, Raydium is using UDP network packets, and as
|
||||
you may know, UDP is not a reliable protocol, aiming speed before all.
|
||||
This system is interesting for sending non-sensible data, as player positions,
|
||||
for example.
|
||||
But Raydium can handle more important data, using some of methods of TCP
|
||||
protocol, as Timeouts, ACK, resending, ...
|
||||
This TCP style packets are available thru "Netcalls".
|
||||
**/
|
||||
|
||||
// High level API: "Netcalls" and "Propags"
|
||||
/**
|
||||
Netcalls provides you a good way to handle network exchanges using
|
||||
callbacks functions, like a simple RPC system.
|
||||
The idea is simple, built over the notion of "type". See suitable functions for
|
||||
more information about this system.
|
||||
|
||||
Another available mechanism is called Propags, and allows you to "share"
|
||||
variables over the network (scores, game state, ...) in a very few steps.
|
||||
You only need to "create" a type, and link a variable to it (any C type or
|
||||
structure is allowed). After each modification of this (local copy of the)
|
||||
variable, just call ##raydium_network_propag_refresh*## and that's it. If
|
||||
any other client (or the server) is applying a modification to this "type",
|
||||
your local copy is automatically updated.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_network_propag_find (int type);
|
||||
/**
|
||||
Lookups a "propag" by his ##type##. Returns -1 is no propag is found.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_network_propag_recv (int type, char *buff);
|
||||
/**
|
||||
Internal callback for "propag" receiving.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_network_propag_refresh_id (int i);
|
||||
/**
|
||||
Will refresh a propag by his ##id##.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_network_propag_refresh (int type);
|
||||
/**
|
||||
Will refresh a propag by his ##type##.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_network_propag_refresh_all (void);
|
||||
/**
|
||||
Will refresh all propags
|
||||
**/
|
||||
|
||||
__rayapi int raydium_network_propag_add (int type, void *data, int size);
|
||||
/**
|
||||
This function will "register" a new propag. You need to provide the address
|
||||
of your variable/structure (##data##), ans its ##size##. A dedicated ##type##
|
||||
is also required (see at the top of this chapter).
|
||||
**/
|
||||
|
||||
__rayapi void raydium_network_queue_element_init (raydium_network_Tcp * e);
|
||||
/**
|
||||
Internal use. (TCP style packets)
|
||||
**/
|
||||
|
||||
__rayapi unsigned short raydium_network_queue_tcpid_gen (void);
|
||||
/**
|
||||
Internal use. (TCP style packets)
|
||||
**/
|
||||
|
||||
__rayapi void raydium_network_queue_tcpid_known_add (int tcpid, int player);
|
||||
/**
|
||||
Internal use. (TCP style packets)
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_network_queue_tcpid_known (unsigned short tcpid, unsigned short player);
|
||||
/**
|
||||
Internal use. (TCP style packets)
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_network_queue_is_tcpid (int type);
|
||||
/**
|
||||
Internal use. (TCP style packets)
|
||||
**/
|
||||
|
||||
__rayapi void raydium_network_queue_element_add (char *packet, struct sockaddr *to);
|
||||
/**
|
||||
Internal use. (TCP style packets)
|
||||
**/
|
||||
|
||||
__rayapi unsigned long *raydium_network_internal_find_delay_addr (int player);
|
||||
/**
|
||||
Internal use. (TCP style packets)
|
||||
**/
|
||||
|
||||
__rayapi void raydium_network_queue_check_time (void);
|
||||
/**
|
||||
Internal use. (TCP style packets)
|
||||
**/
|
||||
|
||||
__rayapi void raydium_network_queue_ack_send (unsigned short tcpid, struct sockaddr *to);
|
||||
/**
|
||||
Internal use. (TCP style packets)
|
||||
**/
|
||||
|
||||
__rayapi void raydium_network_queue_ack_recv (int type, char *buff);
|
||||
/**
|
||||
Internal use. (TCP style packets)
|
||||
**/
|
||||
|
||||
__rayapi void raydium_network_player_name (char *str);
|
||||
/**
|
||||
This function will returns the current player name.
|
||||
Raydium will ask the OS for "current logged user", but player name may
|
||||
be provided thru ##--name## command line argument.
|
||||
**/
|
||||
|
||||
// internal hack, no doc provided
|
||||
__rayapi signed char raydium_network_set_socket_block_internal(int socket, int block);
|
||||
|
||||
__rayapi signed char raydium_network_set_socket_block (int block);
|
||||
/**
|
||||
This function will sets ##block## (true or false) status to the network stack.
|
||||
A blocking socket will wait indefinitely an incoming packet. A non blocking one
|
||||
will return "no data" instead.
|
||||
You've almost no reason to call this function by yourself.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_network_socket_close(int fd);
|
||||
/**
|
||||
Portable socket closing function. See "man 2 close" or closesocket (win32)
|
||||
docs.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_network_socket_is_readable(int fd);
|
||||
/**
|
||||
Will return true (1) if there is some data ready on ##fd## socket,
|
||||
false (0) otherwise.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_network_netcall_add (void *ptr, int type, signed char tcp);
|
||||
/**
|
||||
This function will register a new Network Callback ("netcall").
|
||||
With Raydium, you can read the main data stream with
|
||||
##raydium_network_read_flushed()##, and configure netcalls on random
|
||||
events (using packet type).
|
||||
|
||||
Netcalls signature is: ##void(int type, char *buff)##
|
||||
|
||||
As you may configure the same callback function for multiples packet types,
|
||||
this type is passed to your function, with the temporary ##buff## buffer.
|
||||
You can extract from field from packet if needed.
|
||||
|
||||
If you sets the ##tcp## flag to true (1), your packet will use "TCP style"
|
||||
network protocol (see a the top of this chapter).
|
||||
**/
|
||||
|
||||
__rayapi void raydium_network_netcall_exec (int type, char *buff);
|
||||
/**
|
||||
Internal callback for "netcall" receiving.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_network_timeout_check (void);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_network_init_sub(void);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_network_init (void);
|
||||
/**
|
||||
Nothing interesting unless you're creating a console server (using the
|
||||
##RAYDIUM_NETWORK_ONLY## directive), since in this case you must do all
|
||||
inits by yourself...
|
||||
example :
|
||||
%%(c)
|
||||
#define RAYDIUM_NETWORK_ONLY
|
||||
#include "raydium/index.c"
|
||||
|
||||
...
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
setbuf(stdout,NULL);
|
||||
signal(SIGINT,quit);
|
||||
raydium_php_init(); // only if you need PHP support
|
||||
raydium_network_init();
|
||||
raydium_network_server_create();
|
||||
...
|
||||
%%
|
||||
**/
|
||||
|
||||
__rayapi void raydium_network_write (struct sockaddr *to, int from, signed char type, char *buff);
|
||||
/**
|
||||
Obviously, this function will send data.
|
||||
If you're a client, you don't need to determine to field, as the only
|
||||
destination is the server, so you can use ##NULL##, for example. If you're
|
||||
a server, you can use ##raydium_network_client_addr[]## array.
|
||||
|
||||
As a client, ##from## argument is generally your own uid (##raydium_network_uid##),
|
||||
but you can use any other player number if needed.
|
||||
As a server, ##from## field is useless, since you are the only machine able
|
||||
to send data to clients.
|
||||
|
||||
As you may expect, ##type## field is used to determine packet's type.
|
||||
You can use any (8 bits) value greater or equal to ##RAYDIUM_NETWORK_PACKET_BASE##.
|
||||
|
||||
Finally, ##buff## is a pointer to data's buffer. This buffer
|
||||
must be ##RAYDIUM_NETWORK_PACKET_SIZE## long, and can be cleared
|
||||
or re-used after this call.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_network_broadcast (signed char type, char *buff);
|
||||
/**
|
||||
Sends data over network.
|
||||
Obviously, from network point of vue, only a server can broadcast
|
||||
(to his clients).
|
||||
|
||||
When a client needs to broadcast (from the game point of vue) some
|
||||
informations (his own position, for example), he must send this information
|
||||
to server, and the server will broadcast it.
|
||||
|
||||
This function uses the same arguments as previous one, except ##to## and
|
||||
##from##, not needed here.
|
||||
**/
|
||||
|
||||
|
||||
__rayapi signed char raydium_network_read (int *id, signed char *type, char *buff);
|
||||
/**
|
||||
Reads next packet from network (FIFO) stack.
|
||||
This function uses the same arguments as previous ones, and returns
|
||||
data availability: ##RAYDIUM_NETWORK_DATA_OK##, ##RAYDIUM_NETWORK_DATA_NONE##
|
||||
or ##RAYDIUM_NETWORK_DATA_ERROR##.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_network_read_flushed (int *id, signed char *type, char *buff);
|
||||
/**
|
||||
Reads last packet from network stack.
|
||||
All previous packets will be ignored, only the newest packet will
|
||||
be read (if any).
|
||||
|
||||
As you may miss some important informations, you can use netcalls
|
||||
(see above) if you want to capture packets with a particular
|
||||
type, even with flushed reading.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_network_read_faked(void);
|
||||
/**
|
||||
Reads from network, but do not care of received data. This is useful for
|
||||
listen to internal packets (server "beacon" broadcasts, for example).
|
||||
Reading is done thru ##raydium_network_read_flushed##.
|
||||
Mostly for internal use.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_network_server_broadcast(char *name, char *app_or_mod, int version);
|
||||
/**
|
||||
This function will start to broadcast a server to the LAN.
|
||||
You must provide a party ##name##, the application or mod name (##app_or_mod##)
|
||||
and a "protocol" version of you choice.
|
||||
The server is going to broadcast a "beacon" packet to the LAN
|
||||
every ##RAYDIUM_NETWORK_BEACON_DELAY##.
|
||||
Any client in "discovery mode" with the same ##app_or_mod## and ##version##
|
||||
will see this beacon.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_network_server_broadcast_info(char *info);
|
||||
/**
|
||||
Update "information" field of this server (current track or map, for example).
|
||||
Size cannot exceed ##RAYDIUM_NETWORK_BEACON_INFO_MAX_LEN##.
|
||||
**/
|
||||
|
||||
|
||||
__rayapi void raydium_network_server_broadcast_check(void);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_network_server_create (void);
|
||||
/**
|
||||
Will transform you application into a server, accepting new clients
|
||||
instantaneously.
|
||||
See also the ##RAYDIUM_NETWORK_ONLY## directive if you want to create console
|
||||
servers.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_network_client_connect_to (char *server);
|
||||
/**
|
||||
This function will try to connect your application to ##server## (hostname or
|
||||
ip address).
|
||||
WARNING: For now, this call could be endless ! (server failure while connecting).
|
||||
This function will succed returning 1 or 0 otherwise.
|
||||
You are connected instantaneously, and you must start sending data
|
||||
before server timeout (defined by ##RAYDIUM_NETWORK_TIMEOUT##).
|
||||
You player number can be found with ##raydium_network_uid## variable,
|
||||
as said before.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_network_client_discover(char *game,int version);
|
||||
/**
|
||||
This function will set client in ##RAYDIUM_NETWORK_MODE_DISCOVER## mode.
|
||||
While using this mode, a client will search every LAN server with the
|
||||
same ##game## (or mod name) and ##version## as itself.
|
||||
Then, you can access to this server list using [undocumented yet].
|
||||
**/
|
||||
|
||||
__rayapi int raydium_network_discover_numservers(void);
|
||||
/**
|
||||
While the client is in ##RAYDIUM_NETWORK_MODE_DISCOVER## mode, you
|
||||
can fetch all "detected" servers in the LAN.
|
||||
This function will return :
|
||||
- -1 : "not in discovery mode". See ##raydium_network_client_discover()##.
|
||||
- 0 : no server detected (yet ... try during next frame)
|
||||
- more : total number of compatible servers (same game/application
|
||||
and protocol version)
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_network_discover_getserver(int num, char *name, char *ip, char *info, int *player_count, int *player_max);
|
||||
/**
|
||||
Use this function with the help of ##raydium_network_discover_numservers()##,
|
||||
with something like :
|
||||
%%(c)
|
||||
int i;
|
||||
char name[RAYDIUM_MAX_NAME_LEN];
|
||||
char ip[RAYDIUM_MAX_NAME_LEN];
|
||||
char info[RAYDIUM_MAX_NAME_LEN];
|
||||
int player_count;
|
||||
int player_max;
|
||||
...
|
||||
for(i=0;i<raydium_network_discover_numservers();i++)
|
||||
{
|
||||
raydium_network_discover_getserver(i,name,ip,info,&player_count,&player_max);
|
||||
raydium_log("server %02i: %s (%s)",i,name,ip);
|
||||
}
|
||||
|
||||
No memory allocation is done for ##name## and ##ip##. It's your job.
|
||||
|
||||
This function will return :
|
||||
- -1 : "not in discovery mode". See ##raydium_network_client_discover()##.
|
||||
- 0 : invalid ##num##.
|
||||
- 1 : OK.
|
||||
%%
|
||||
**/
|
||||
|
||||
__rayapi void raydium_network_client_disconnect(void);
|
||||
/**
|
||||
This function will disconnect client from server, if connected.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_server_accept_new (struct sockaddr *from, char *name);
|
||||
/**
|
||||
Internal server callback for new clients.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_network_close (void);
|
||||
/**
|
||||
Obvious. Raydium will do it for you, anyway.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_network_internal_server_delays_dump (void);
|
||||
/**
|
||||
Dumps "TCP Style" timeouts for all clients to console.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_network_internal_dump (void);
|
||||
/**
|
||||
Dumps various stats about network stack to console.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_network_internet_test(void);
|
||||
/**
|
||||
This function will test if direct internet connection is available,
|
||||
using Raydium webiste. This function supports proxies.
|
||||
**/
|
||||
|
||||
#ifdef linux
|
||||
__rayapi signed char raydium_network_linux_find_broadcast_interfaces(void);
|
||||
/**
|
||||
Internal use. Linux only.
|
||||
**/
|
||||
#endif
|
||||
|
||||
#endif
|
47
raydium/headers/normal.h
Normal file
47
raydium/headers/normal.h
Normal file
@ -0,0 +1,47 @@
|
||||
#ifndef _NORMAL_H
|
||||
#define _NORMAL_H
|
||||
|
||||
/*=
|
||||
Normals
|
||||
1600
|
||||
**/
|
||||
|
||||
// Introduction
|
||||
/**
|
||||
This file provides some usefull functions for normal generation and smoothing.
|
||||
You can find some more informations about normals at the top of this guide.
|
||||
**/
|
||||
|
||||
|
||||
__rayapi void raydium_normal_generate_lastest_triangle (int default_visu);
|
||||
/**
|
||||
Generate normal for the last created triangle (see ##raydium_vertex_index##)
|
||||
if ##default_visu## is true ( != 0 ), this function will restore "visu"
|
||||
normals too.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_normal_restore_all (void);
|
||||
/**
|
||||
This function restore visu normals with standard ones (##raydium_vertex_normal_*##)
|
||||
**/
|
||||
|
||||
__rayapi void raydium_normal_regenerate_all (void);
|
||||
/**
|
||||
This function will regenerate standard and visu normals for the whole
|
||||
scene (ground, objects, ...).
|
||||
**/
|
||||
|
||||
__rayapi void raydium_normal_smooth_all (void);
|
||||
/**
|
||||
This function will smooth the whole scene, using adjacent vertices.
|
||||
Note this function can take a lot of time.
|
||||
**/
|
||||
|
||||
void raydium_normal_smooth_from_to(GLuint from, GLuint to);
|
||||
/**
|
||||
Same as above, but only from ##from## vertex to ##to## vertex (excluded).
|
||||
In other words: will smooth [from;to[
|
||||
**/
|
||||
|
||||
|
||||
#endif
|
204
raydium/headers/object.h
Normal file
204
raydium/headers/object.h
Normal file
@ -0,0 +1,204 @@
|
||||
#ifndef _OBJECT_H
|
||||
#define _OBJECT_H
|
||||
/*=
|
||||
Objects
|
||||
2300
|
||||
**/
|
||||
|
||||
// Introduction
|
||||
/**
|
||||
With the following functions, you can easily draw and manage
|
||||
mesh objects (.tri file).
|
||||
**/
|
||||
|
||||
__rayapi GLint raydium_object_find (char *name);
|
||||
/**
|
||||
Lookups an object by its ##name##. This function will return -1 if the
|
||||
object's not found, and will not try to load the .tri file.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_object_isvalid(int obj);
|
||||
/**
|
||||
Internal use, but you can call this function if you want to verify if an
|
||||
object id is valid (in bounds).
|
||||
**/
|
||||
|
||||
__rayapi GLint raydium_object_find_load (char *name);
|
||||
/**
|
||||
Same as above (##raydium_object_load##), but will try to load object.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_object_reset (GLuint o);
|
||||
/**
|
||||
Internal use. Do not call.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_object_load (char *filename);
|
||||
/**
|
||||
Load ##filename## as a .tri file, and returns corresponding id, or
|
||||
-1 in case of error.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_object_draw (GLuint o);
|
||||
/**
|
||||
Draws ##o## (index) object, using current matrixes.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_object_draw_name (char *name);
|
||||
/**
|
||||
Same as above, but you only have to provide object's ##name## (".tri file").
|
||||
If this object was not already loaded, this function will do it for you.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_object_deform (GLuint obj, GLfloat ampl);
|
||||
/**
|
||||
Early devel state. Useless as is.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_object_deform_name (char *name, GLfloat ampl);
|
||||
/**
|
||||
Early devel state. Useless as is.
|
||||
**/
|
||||
|
||||
__rayapi GLfloat raydium_object_find_dist_max (GLuint obj);
|
||||
/**
|
||||
This function will return will return the distance form (0,0,0)
|
||||
to the farest point of ##obj## object.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_object_find_axes_max (GLuint obj, GLfloat * tx, GLfloat * ty, GLfloat * tz);
|
||||
/**
|
||||
This function returns the (maximum) size of the bounding box
|
||||
of ##obj## (relative to (0,0,0)).
|
||||
**/
|
||||
|
||||
__rayapi void raydium_object_find_minmax(GLuint obj, GLfloat *min, GLfloat *max);
|
||||
/**
|
||||
Returns min and max values for ##obj##. No memory allocation is done, you must
|
||||
provide two GLfloat[3] array.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_object_find_center_factors(GLuint obj, GLfloat *tx, GLfloat *ty, GLfloat *tz);
|
||||
/**
|
||||
Returns "centering" factors for ##obj##. A centered object will return (0,0,0).
|
||||
**/
|
||||
|
||||
__rayapi void raydium_object_callback(void);
|
||||
/**
|
||||
Internal (frame callback).
|
||||
**/
|
||||
|
||||
|
||||
// Animations
|
||||
/**
|
||||
Raydium now supports mesh animation, thru MD2 (Quake 2) files. Raydium file
|
||||
format was extended to version 2. If you want to create an animated mesh
|
||||
for Raydium from a MD2 file, you may use Blender with "import-md2-0.14.py"
|
||||
script ( by Bob Holcomb, http://67.22.114.230:8082/programming/blender/index.html )
|
||||
and export it back to a tri file using provided "triEXP-MD2-*.py" script.
|
||||
All other tasks (loading, transformations, ...) are done the same way as
|
||||
regular static mesh.
|
||||
|
||||
For Raydium, an animation is a set of "anims", and each "anim" is a set
|
||||
of "frames". Each "anim" gets its own name (see header of a version 2 file
|
||||
for more informations), and since an animated object may be use for many
|
||||
players, Raydium provides an "instances" based system: setting things like
|
||||
anim and frame for an object is done only for one instance of this object.
|
||||
Instances are always available, no need to create or declare them.
|
||||
That's all you need to use animation simple API.
|
||||
**/
|
||||
|
||||
__rayapi GLint raydium_object_anim_find(int object, char *name);
|
||||
/**
|
||||
Lookups an animation by its ##name##. This function will return -1 if the
|
||||
animation's not found. Mostly for internal use.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_object_anim_generate_internal(int object, int instance);
|
||||
/**
|
||||
Internal. Transformed mesh generation.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_object_anim_frame(int object, int instance, GLfloat frame);
|
||||
/**
|
||||
Sets current ##frame## for one ##instance## of ##object##. ##frame## is
|
||||
automatically bounded and looped.
|
||||
Warning, change anim **before** anim's frame.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_object_anim_frame_name(char *object, int instance, GLfloat frame);
|
||||
/**
|
||||
Same as above, but using ##object##'s name.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_object_anim(int object, int instance, int anim);
|
||||
/**
|
||||
Sets current ##anim## for one ##instance## of ##object##.
|
||||
Again, change anim **before** anim's frame.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_object_anim_name(char *object, int instance, char *anim);
|
||||
/**
|
||||
Same as above, but using ##object##'s name and ##anim##'s name.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_object_anim_instance(int object, int instance);
|
||||
/**
|
||||
With this function, you must set what instance will be drawn when
|
||||
##raydium_object_draw()## will be called with ##object## argument.
|
||||
|
||||
Default is set to instance 0.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_object_anim_instance_name(char *object, int instance);
|
||||
/**
|
||||
Same as above, but using ##object##'s name.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_object_anim_automatic(int object, int anim, GLfloat factor);
|
||||
/**
|
||||
With this function, you can set an automatic frame increment for a specific
|
||||
##anim## of an ##object##. This increment is based on frame time and ##factor##.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_object_anim_automatic_name(char *object, char *anim, GLfloat factor);
|
||||
/**
|
||||
Same as above, but using ##object##'s name and ##anim##'s name.
|
||||
**/
|
||||
|
||||
// "Punctually" anims
|
||||
/**
|
||||
When using animations, you're switching for an "anim" to another, and an
|
||||
"anim" will loop forever. "Punctually" support will allow you to set a
|
||||
default "anim" for an object and to do switch punctually to another "anim",
|
||||
and automatically return back to default value when this "anim" is finished,
|
||||
usefull for animations like jumps, kick, ...
|
||||
**/
|
||||
|
||||
__rayapi void raydium_object_anim_default(int object, int anim);
|
||||
/**
|
||||
This function will set default ##anim## for ##object##.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_object_anim_punctually(int object, int anim, int instance);
|
||||
/**
|
||||
This function will trigger a punctually ##anim## for ##object##'s ##instance##.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_object_anim_punctually_name(char *object, char *anim, int instance);
|
||||
/**
|
||||
Same as above, but with object's name.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_object_anim_ispunctually(int object, int instance);
|
||||
/**
|
||||
Will return true (1) if ##object## is currently running a punctually animation,
|
||||
or false (0) otherwise.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_object_anim_ispunctually_name(char *object, int instance);
|
||||
/**
|
||||
Same as above, but with object's name.
|
||||
**/
|
||||
|
||||
#endif
|
1560
raydium/headers/ode.h
Normal file
1560
raydium/headers/ode.h
Normal file
File diff suppressed because it is too large
Load Diff
182
raydium/headers/ode_net.h
Normal file
182
raydium/headers/ode_net.h
Normal file
@ -0,0 +1,182 @@
|
||||
#ifndef _ODE_NET_H
|
||||
#define _ODE_NET_H
|
||||
|
||||
/*=
|
||||
RayODE network layer
|
||||
4000
|
||||
**/
|
||||
|
||||
// Introduction
|
||||
/**
|
||||
Physics engines are extremely powerful tools, but it turns to nightmares when
|
||||
the application must be networked. RayODE API provides its own network layer,
|
||||
using Raydium lower level network API. And the great thing is that you've
|
||||
almost anything to do !
|
||||
Just choose the best "send" function and let Raydium do the rest.
|
||||
|
||||
RayODE Net will use udp streams, netcall (RPC), smart timeouts, predictions,
|
||||
dead reckoning, and many others voodoo things. Just trust.
|
||||
|
||||
A few things about internals:
|
||||
- NID: Network ID. Every networked element have a NID.
|
||||
- Distant elements are localy created using static elements, owned by
|
||||
an object called "##DISTANT##".
|
||||
- ##raydium_ode_network_maxfreq## defines the paquet sending frequency. By
|
||||
default, this value is ##RAYDIUM_ODE_NETWORK_MAXFREQ##, but you can use
|
||||
##--ode-rate## command line switch.
|
||||
- No rotation prediction is done.
|
||||
- See ##config.h## if you want to disable prediction (##ODE_PREDICTION##) or
|
||||
to debug RayODE Net (##DEBUG_ODENET##, **very** verbose !).
|
||||
- Explosions are also automatically managed by RayODE Net.
|
||||
- **Do NOT use** Raydium lower level network API when using RayODE Net. Use
|
||||
netcalls, propags and so on.
|
||||
|
||||
Nothing is said here about how to create a RayODE Net server. There's only
|
||||
a few more things to do if you already have a standard server, but since it's
|
||||
unsupported for now, you must have a look to existing RayODE Net servers.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_ode_network_MaxElementsPerPacket (void);
|
||||
/**
|
||||
This function will return how many elements may be sent with
|
||||
current packet size (see ##common.h##).
|
||||
**/
|
||||
|
||||
__rayapi int raydium_network_nid_element_find (int nid);
|
||||
/**
|
||||
Internal. Find wich element have ##nid##.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_ode_network_newdel_event (int type, char *buff);
|
||||
/**
|
||||
Internal. NEWDEL netcall event.
|
||||
NEWDEL is fired when a new element is created or deleted somewhere in the
|
||||
network.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_ode_network_nidwho_event (int type, char *buff);
|
||||
/**
|
||||
Internal. NIDWHO netcall event.
|
||||
NIDWHO is sent when someone received some "update" informations about a
|
||||
nid, but didn't received previous NEWDEL informations for this nid.
|
||||
The nid owner will send a reply.
|
||||
|
||||
Most reasons for this are:
|
||||
- We are a new client and we dont known anything about the whole scene.
|
||||
- The NEWDEL packet was lost ("TCP style" packets may be lost too ...)
|
||||
|
||||
NIDWHO answer will be used by every peer to refresh its own copy of the
|
||||
element informations (geometry type, mesh, size and tag).
|
||||
**/
|
||||
|
||||
__rayapi void raydium_ode_network_explosion_event (int type, char *buff);
|
||||
/**
|
||||
Internal explosion netcall event.(##RAYDIUM_ODE_NETWORK_EXPLOSION_EXPL## and
|
||||
##RAYDIUM_ODE_NETWORK_EXPLOSION_BLOW##).
|
||||
**/
|
||||
|
||||
__rayapi void raydium_ode_network_init (void);
|
||||
/**
|
||||
Internal. Will initialize all RayODE Net layer and register netcalls.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_ode_network_TimeToSend (void);
|
||||
/**
|
||||
Almost internal. Will return 1 (true) if it's time to send a new packet, using
|
||||
##raydium_ode_network_maxfreq## value.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_ode_network_element_send (short nelems, int *e);
|
||||
/**
|
||||
Will send all elements of ##e## array to network. You must provide array lenght
|
||||
using ##nelems##.
|
||||
To "time to send ?" test is done, you'll probably have to do it yourself.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_ode_network_element_send_all (void);
|
||||
/**
|
||||
Will try to send all elements to network. Warning, packet size may be to
|
||||
small to send all elements !..
|
||||
**/
|
||||
|
||||
__rayapi void raydium_ode_network_element_send_random (int nelems);
|
||||
/**
|
||||
Will send randomly chosen elements to network. You must provide how many
|
||||
elements you want with ##nelems##, but RAYDIUM_ODE_NETWORK_OPTIMAL is
|
||||
available.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_ode_network_element_send_iterative (int nelems);
|
||||
/**
|
||||
Will send elements to network, iteratively chose. You must provide how many
|
||||
elements you want with ##nelems##, but RAYDIUM_ODE_NETWORK_OPTIMAL is
|
||||
available.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_ode_network_nidwho (int nid);
|
||||
/**
|
||||
Internal. Will ask for informations for ##nid## (see above).
|
||||
NID sending frequency is now limited, since a lot of overhead was generated
|
||||
when new clients were joining a "big" network.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_ode_network_apply (raydium_ode_network_Event * ev);
|
||||
/**
|
||||
Internal. This callback is fired when new data is received. A lot of things
|
||||
are done here (timeouts, dead reckoning, ...)
|
||||
**/
|
||||
|
||||
__rayapi void raydium_ode_network_read (void);
|
||||
/**
|
||||
Internal. Reads new packets, if any.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_ode_network_element_new (int e);
|
||||
/**
|
||||
Internal. Send a new element to network.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_ode_network_element_delete (int e);
|
||||
/**
|
||||
Internal. Send "delete event" to network, since we're deleting one of "our" elements.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_ode_network_explosion_send (raydium_ode_network_Explosion * exp);
|
||||
/**
|
||||
Internal. Send a new explosion event.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_ode_network_element_isdistant (int elem);
|
||||
/**
|
||||
Will return true (1) if element ##elem## is "distant", or false (0) if it's
|
||||
one of "our" elements.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_ode_network_element_isdistant_name (char *elem);
|
||||
/**
|
||||
Same as above, but using element's name.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_ode_network_element_distantowner(int elem);
|
||||
/**
|
||||
Returns UID (peer "user" ID) for the distant element owner. See ##network.c##
|
||||
documentation for more informations about UID.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_ode_network_element_distantowner_name(char *elem);
|
||||
/**
|
||||
Same as above, but using element's name.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_ode_network_element_trajectory_correct (int elem);
|
||||
/**
|
||||
Internal. Applies dead reckoning values to element.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_ode_network_elment_next_local(void);
|
||||
/**
|
||||
Call this function when you don't want that the next created element is sent
|
||||
to network ("local only" element).
|
||||
**/
|
||||
|
||||
#endif
|
228
raydium/headers/osd.h
Normal file
228
raydium/headers/osd.h
Normal file
@ -0,0 +1,228 @@
|
||||
#ifndef _OSD_H
|
||||
#define _OSD_H
|
||||
/*=
|
||||
OSD (On Screen Display)
|
||||
2900
|
||||
**/
|
||||
|
||||
// Introduction
|
||||
/**
|
||||
Raydium provides some high level function for "On Screen Display",
|
||||
as string drawing (2D and 3D), application's logo, mouse cursor, and other
|
||||
various 2D displaying tools.
|
||||
|
||||
In most cases, these functions must be called after any other object
|
||||
drawing function, to avoid overlapping problems.
|
||||
|
||||
Most functions will use a percentage system, and origin is at lower-left corner.
|
||||
**/
|
||||
|
||||
|
||||
__rayapi void raydium_osd_color_change (GLfloat r, GLfloat g, GLfloat b);
|
||||
/**
|
||||
This function will change the font color for the next ##raydium_osd_printf*##
|
||||
calls.
|
||||
As usual: 0 <= (##r##,##g## and ##b##) <= 1.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_osd_alpha_change (GLfloat a);
|
||||
/**
|
||||
Same as above, but will change font transparency.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_osd_color_rgba (GLfloat r, GLfloat g, GLfloat b, GLfloat a);
|
||||
/**
|
||||
This is a mix of ##raydium_osd_color_change## and ##raydium_osd_alpha_change##.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_osd_color_ega (char hexa);
|
||||
/**
|
||||
This function will change font color with the corresponding
|
||||
##hexa##decimal code (as a char: '0' to 'F') in the standard EGA palette.
|
||||
|
||||
Here is this palette:
|
||||
""
|
||||
<div class="table" align="center">
|
||||
<table class="tableListing" summary=" " cellspacing="0" cellpadding="3" border="1">
|
||||
<tr class="wiki"><td class="wiki"> <b>Hexa</b> </td><td class="wiki"> <b>Color</b> </td></tr>
|
||||
<tr class="wiki"><td class="wiki"> 0 </td><td class="wiki"> Black </td></tr>
|
||||
<tr class="wiki"><td class="wiki"> 1 </td><td class="wiki"> Blue </td></tr>
|
||||
<tr class="wiki"><td class="wiki"> 2 </td><td class="wiki"> Green </td></tr>
|
||||
<tr class="wiki"><td class="wiki"> 3 </td><td class="wiki"> Cyan </td></tr>
|
||||
<tr class="wiki"><td class="wiki"> 4 </td><td class="wiki"> Red </td></tr>
|
||||
<tr class="wiki"><td class="wiki"> 5 </td><td class="wiki"> Purple </td></tr>
|
||||
<tr class="wiki"><td class="wiki"> 6 </td><td class="wiki"> Brown </td></tr>
|
||||
<tr class="wiki"><td class="wiki"> 7 </td><td class="wiki"> White </td></tr>
|
||||
<tr class="wiki"><td class="wiki"> 8 </td><td class="wiki"> Grey </td></tr>
|
||||
<tr class="wiki"><td class="wiki"> 9 </td><td class="wiki"> Light Blue </td></tr>
|
||||
<tr class="wiki"><td class="wiki"> A </td><td class="wiki"> Light Green </td></tr>
|
||||
<tr class="wiki"><td class="wiki"> B </td><td class="wiki"> Light Cyan </td></tr>
|
||||
<tr class="wiki"><td class="wiki"> C </td><td class="wiki"> Light Red </td></tr>
|
||||
<tr class="wiki"><td class="wiki"> D </td><td class="wiki"> Light Purple </td></tr>
|
||||
<tr class="wiki"><td class="wiki"> E </td><td class="wiki"> Light Yellow </td></tr>
|
||||
<tr class="wiki"><td class="wiki"> F </td><td class="wiki"> Light White </td></tr>
|
||||
</table>
|
||||
</div>
|
||||
""
|
||||
**/
|
||||
|
||||
__rayapi void raydium_osd_start (void);
|
||||
/**
|
||||
Mostly for internal uses. (will configure screen for OSD operations)
|
||||
**/
|
||||
|
||||
__rayapi void raydium_osd_stop (void);
|
||||
/**
|
||||
Mostly for internal uses. (see above)
|
||||
**/
|
||||
|
||||
__rayapi void raydium_osd_draw (int tex, GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2);
|
||||
/**
|
||||
Will draw ##tex## texture using (##x1##,##y1##) and (##x2##,##y2##) points.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_osd_draw_name (char *tex, GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2);
|
||||
/**
|
||||
Same as above, but using texture filename.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_osd_printf (GLfloat x, GLfloat y, GLfloat size, GLfloat spacer, char *texture, char *format, ...);
|
||||
/**
|
||||
This function is an OpenGL equivalent to the standard "printf" C function.
|
||||
|
||||
- (##x##,##y##) is the position of the text's beginning, as a screen
|
||||
percentage, with origin at lower left.
|
||||
|
||||
- ##size## is the font size, using an arbitrary unit. This size is always
|
||||
proportionnal to frame size (font size will grow up with screen size,
|
||||
in other words).
|
||||
|
||||
- ##spacer## is the factor of spacing between 2 consecutive letters. With
|
||||
standard fonts, 0.5 is a correct value (relatively condensed text).
|
||||
|
||||
- ##texture## is obviously the texture filename to use (font*.tga are
|
||||
often provided with Raydium distribution, and by R3S).
|
||||
|
||||
- ##format## is the standard printf format string, followed by
|
||||
corresponding arguments: ##"^9Player ^Fname is: %10s", player_name##
|
||||
This format can use '^' char to change color text, followed by a color,
|
||||
indicated by a hexadecimal letter (EGA palette). See ##raydium_osd_color_ega##
|
||||
function, above.
|
||||
|
||||
Here you are a simple example:
|
||||
|
||||
%%(c)
|
||||
strcpy(version,"^Ctest 0.1^F");
|
||||
raydium_osd_printf(2,98,16,0.5,"font2.tga","- %3i FPS - tech demo %s for Raydium %s, CQFD Corp.",
|
||||
raydium_render_fps,version,raydium_version);
|
||||
%%
|
||||
**/
|
||||
|
||||
__rayapi void raydium_osd_printf_3D (GLfloat x, GLfloat y, GLfloat z, GLfloat size, GLfloat spacer, char *texture, char *format, ...);
|
||||
/**
|
||||
Same as above, but you can place your text in your application 3D space,
|
||||
using ##x##, ##y## and ##z## values.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_osd_logo (char *texture);
|
||||
/**
|
||||
Will draw a logo for the current frame with texture filename.
|
||||
For now, you've no control over rotation speed of the logo.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_osd_cursor_set (char *texture, GLfloat xsize, GLfloat ysize);
|
||||
/**
|
||||
This function will set mouse cursor with texture filename and
|
||||
with (##xsize##,##ysize##) size (percent of screen size).
|
||||
You should use a RGB**A** texture for better results.
|
||||
example:
|
||||
%%(c)
|
||||
raydium_osd_cursor_set("BOXcursor.tga",4,4);
|
||||
%%
|
||||
|
||||
You can set ##texture## to NULL or empty string to cancel OSD cursor texture.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_osd_cursor_draw (void);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_osd_internal_vertex (GLfloat x, GLfloat y, GLfloat top);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_osd_network_stat_draw (GLfloat px, GLfloat py, GLfloat size);
|
||||
/**
|
||||
Will draw network stats (if available) in a box.
|
||||
%%(c) raydium_osd_network_stat_draw(5,30,20); %%
|
||||
**/
|
||||
|
||||
__rayapi void raydium_osd_mask (GLfloat * color4);
|
||||
/**
|
||||
Will draw a uniform mask using ##color4## (RGBA color) for this frame.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_osd_mask_texture(int texture,GLfloat alpha);
|
||||
/**
|
||||
Will draw a textured mask, with ##alpha## opacity (1 is full opacity).
|
||||
**/
|
||||
|
||||
__rayapi void raydium_osd_mask_texture_name(char *texture,GLfloat alpha);
|
||||
/**
|
||||
Same as above, but resolving texture by name.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_osd_mask_texture_clip(int texture,GLfloat alpha, GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2);
|
||||
/**
|
||||
Same as ##raydium_osd_mask_texture##, but (x1,y1),(x2,y2) will be used as
|
||||
texture coords, in a [0,100] range.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_osd_mask_texture_clip_name(char *texture,GLfloat alpha, GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2);
|
||||
/**
|
||||
Same as above, but resolving texture by name.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_osd_fade_callback (void);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_osd_fade_init (void);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_osd_fade_from (GLfloat * from4, GLfloat * to4, GLfloat time_len, void *OnFadeEnd);
|
||||
/**
|
||||
This function will configure a fading mask from ##from4## color to ##to4##.
|
||||
This fade will last ##time_len## seconds, and will call ##OnFadeEnd## callback
|
||||
when finished.
|
||||
This callback signature must be ##void callback(void)##.
|
||||
|
||||
A standard fade-to-black-and-restore example:
|
||||
%%(c)
|
||||
// back to normal rendering
|
||||
void restorefade(void)
|
||||
{
|
||||
GLfloat from[4]={0,0,0,2};
|
||||
GLfloat to[4]={0,0,0,0};
|
||||
raydium_osd_fade_from(from,to,1,NULL);
|
||||
// do things (like moving camera to another place, for example).
|
||||
}
|
||||
|
||||
...
|
||||
|
||||
// If space key : fade to black
|
||||
if(raydium_key_last==1032)
|
||||
{
|
||||
GLfloat from[4]={0,0,0,0};
|
||||
GLfloat to[4]={0,0,0,1};
|
||||
raydium_osd_fade_from(from,to,0.3,restorefade);
|
||||
}
|
||||
%%
|
||||
**/
|
||||
|
||||
#endif
|
113
raydium/headers/parser.h
Normal file
113
raydium/headers/parser.h
Normal file
@ -0,0 +1,113 @@
|
||||
#ifndef _PARSER_H
|
||||
#define _PARSER_H
|
||||
|
||||
/*=
|
||||
Text file parsing
|
||||
3700
|
||||
**/
|
||||
|
||||
// Introduction
|
||||
/**
|
||||
Raydium provides a set of functions dedicated to text files parsing. These
|
||||
files must follow a simple syntax:
|
||||
%%(c)
|
||||
// strings
|
||||
variable_s="string value";
|
||||
|
||||
// float (or integer, i.e.)
|
||||
variable_f=10.5;
|
||||
|
||||
// float array
|
||||
variable_a={1,2,10.5,};
|
||||
|
||||
// raw data
|
||||
variable_r=[
|
||||
xxxxxxxx
|
||||
# oo #
|
||||
# #
|
||||
# oo #
|
||||
xxxxxxxx
|
||||
];
|
||||
%%
|
||||
Semi-colon are purely esthetic.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_parser_trim (char *org);
|
||||
/**
|
||||
Strip whitespace (or other characters) from the beginning and end of a string.
|
||||
So far, ' ', '\n' and ';' are deleted.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_parser_isdata (char *str);
|
||||
/**
|
||||
Returns true (1) if ##str## contains data, false (0) otherwise (comments and
|
||||
blank lines).
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_parser_cut (char *str, char *part1, char *part2, char separator);
|
||||
/**
|
||||
This function will cut ##str## in two parts (##part1## and ##part2##) on
|
||||
##separator##. No memory allocation will be done by this functions.
|
||||
First occurence of ##separator## is used (left cut).
|
||||
Return true (##i##+1) if ##str## was cut, where ##i## is the separator position.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_parser_replace (char *str, char what, char with);
|
||||
/**
|
||||
Will replace all occurence of ##what## with ##with##.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_parser_read (char *var, char *val_s, GLfloat *val_f, int *size, FILE *fp);
|
||||
/**
|
||||
Reads a new data line in ##fp##.
|
||||
##var## will contain variable name. You'll find associated value in ##val_s##
|
||||
if it's a string, or ##val_f## if it's a float (or a float array). In this last
|
||||
case, ##size## will return the number of elements if the array.
|
||||
%%(c)
|
||||
FILE *fp;
|
||||
int ret;
|
||||
char var[RAYDIUM_MAX_NAME_LEN];
|
||||
char val_s[RAYDIUM_MAX_NAME_LEN];
|
||||
GLfloat val_f[MY_ARRAY_SIZE];
|
||||
int size;
|
||||
|
||||
fp=raydium_file_fopen("foobar.txt","rt");
|
||||
|
||||
while( (ret=raydium_parser_read(var,val_s,val_f,&size,fp))!=RAYDIUM_PARSER_TYPE_EOF)
|
||||
{
|
||||
if(!strcasecmp(var,"foobar_variable"))
|
||||
{
|
||||
if(ret!=RAYDIUM_PARSER_TYPE_FLOAT || size!=2)
|
||||
{
|
||||
raydium_log("error: foobar_variable is not float array");
|
||||
continue;
|
||||
}
|
||||
memcpy(...);
|
||||
}
|
||||
|
||||
...
|
||||
|
||||
}
|
||||
%%
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_parser_db_get(char *key, char *value, char *def);
|
||||
/**
|
||||
This function will copy the value of ##key## from Raydium's database to
|
||||
##value##. If ##key## is not found, ##def## is used as a default value.
|
||||
|
||||
If you do not want to use a default value, give ##NULL## to ##def##,
|
||||
and the function will return 0 when ##key## was not found.
|
||||
|
||||
No memory allocation is done for you.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_parser_db_set(char *key, char *value);
|
||||
/**
|
||||
Sets ##key## in the Raydium's database to ##value##.
|
||||
This function will return 0 if failed.
|
||||
**/
|
||||
|
||||
|
||||
#endif
|
||||
|
190
raydium/headers/particle2.h
Normal file
190
raydium/headers/particle2.h
Normal file
@ -0,0 +1,190 @@
|
||||
#ifndef _PARTICLE__H
|
||||
#define _PARTICLE__H
|
||||
#include "../particle2.h"
|
||||
|
||||
/*=
|
||||
Particle engine
|
||||
1400
|
||||
**/
|
||||
|
||||
// Introduction
|
||||
/**
|
||||
This is the second version of Raydium's particle engine. This engine is build
|
||||
on top of a dedicated file format (.prt and .sprt files), describing most
|
||||
(up to all, in facts) properties of generators.
|
||||
It probably better to start by an example (fountain.prt) :
|
||||
%%(c)
|
||||
// Simple blue fountain (change 'vector' if needed)
|
||||
ttl_generator=5;
|
||||
ttl_particles=1.5;
|
||||
ttl_particles_random=0;
|
||||
|
||||
particles_per_second=200;
|
||||
|
||||
texture="flare_nb.tga";
|
||||
|
||||
size=0.1;
|
||||
size_inc_per_sec=0.1;
|
||||
|
||||
gravity={0,0,-5};
|
||||
vector={0,0,4};
|
||||
vector_random={0.2,0.2,0.2};
|
||||
|
||||
// RGBA
|
||||
color_start={0.6,0.6,1,0.5};
|
||||
color_start_random={0,0,0.2,0};
|
||||
color_end={1,1,1,0.1};
|
||||
|
||||
// end of file.
|
||||
%%
|
||||
|
||||
.prt files are readed using parsing functions (see appropriate chapter, if
|
||||
needed), and the list of all available properties can be found in particle2.c
|
||||
source file. A full toturial is also available on Raydium's Wiki.
|
||||
|
||||
Once the particle file is written, you only need to load the file using the
|
||||
suitable function (see below). Some anchor are available to link generators to
|
||||
physic entities, if needed, as callbacks for a few events (one, for now).
|
||||
|
||||
.sprt files are used to create a "snapshot" of particles, used for example by
|
||||
3D captures, and are not meant to be edited by hand.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_particle_name_auto (char *prefix, char *dest);
|
||||
/**
|
||||
Will generate a unique string using ##prefix##. The string is created using
|
||||
space provided by ##dest##.
|
||||
You can use this function when building a new generator.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_particle_init (void);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_particle_generator_isvalid (int g);
|
||||
/**
|
||||
Internal use, but you can call this function if you want to verify if a
|
||||
generator's id is valid (in bounds, and loaded).
|
||||
**/
|
||||
|
||||
__rayapi int raydium_particle_generator_find (char *name);
|
||||
/**
|
||||
Lookups a generator using is name. Returns -1 if ##name## is not found.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_particle_find_free (void);
|
||||
/**
|
||||
Finds a free **particle** slot.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_particle_generator_delete (int gen);
|
||||
/**
|
||||
Deletes a generator.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_particle_generator_delete_name (char *gen);
|
||||
/**
|
||||
Same as above, but using generator's name.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_particle_generator_enable (int gen, signed char enabled);
|
||||
/**
|
||||
Activate a disabled generator (see below).
|
||||
**/
|
||||
|
||||
__rayapi void raydium_particle_generator_enable_name (char *gen, signed char enable);
|
||||
/**
|
||||
Disable a generator (TTL is still decremented).
|
||||
**/
|
||||
|
||||
__rayapi void raydium_particle_preload (char *filename);
|
||||
/**
|
||||
Loads .prt file and associated textures into suitable caches.
|
||||
Call this function if you want to avoid (small) jerks caused by "live"
|
||||
loading a generator.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_particle_generator_load_internal (int generator, FILE * fp, char *filename);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_particle_generator_load (char *filename, char *name);
|
||||
/**
|
||||
Loads generator from ##filename## as ##name##. This ##name## will be used for
|
||||
future references to this generator, as the returned interger id.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_particle_generator_update (int g, GLfloat step);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_particle_update (int part, GLfloat step);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_particle_callback (void);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_particle_state_dump(char *filename);
|
||||
/**
|
||||
Dumped current particles to ##filename## (.sprt [static particles]).
|
||||
**/
|
||||
|
||||
__rayapi int raydium_particle_state_restore(char *filename);
|
||||
/**
|
||||
Append .sprt ##filename## to current scene.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_particle_draw (raydium_particle_Particle * p, GLfloat ux, GLfloat uy, GLfloat uz, GLfloat rx, GLfloat ry, GLfloat rz);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_particle_draw_all (void);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_particle_generator_move (int gen, GLfloat * pos);
|
||||
/**
|
||||
Moves ##gen## generator to ##pos## position (3 * GLfloat array).
|
||||
**/
|
||||
|
||||
__rayapi void raydium_particle_generator_move_name (char *gen, GLfloat * pos);
|
||||
/**
|
||||
Same as above, but using generator's name.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_particle_generator_move_name_3f (char *gen, GLfloat x, GLfloat y, GLfloat z);
|
||||
/**
|
||||
Same as above, using 3 different GLfloat values.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_particle_generator_particles_OnDelete (int gen, void *OnDelete);
|
||||
/**
|
||||
Sets a callback for ##gen##, fired when any particle of this generator is
|
||||
deleted, providing a easy way to create "cascading" generators.
|
||||
The callback must respect the following prototype:
|
||||
%%(c) void cb(raydium_particle_Particle *) %%
|
||||
Do not free the provided particle.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_particle_generator_particles_OnDelete_name (char *gen, void *OnDelete);
|
||||
/**
|
||||
Same as above, but using generator's name.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_particle_scale_all(GLfloat scale);
|
||||
/**
|
||||
Will scale all particles with ##scale## factor. Use with caution.
|
||||
Default is obviously 1.
|
||||
**/
|
||||
|
||||
|
||||
#endif
|
26
raydium/headers/path.h
Normal file
26
raydium/headers/path.h
Normal file
@ -0,0 +1,26 @@
|
||||
#ifndef _PATH__H
|
||||
#define _PATH__H
|
||||
#include "../path.h"
|
||||
|
||||
/*=
|
||||
File path
|
||||
2110
|
||||
**/
|
||||
|
||||
// Introduction
|
||||
/**
|
||||
No doc yet.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_path_find_free(void);
|
||||
__rayapi signed char raydium_path_ext(char *dir, char *ext);
|
||||
__rayapi signed char raydium_path_add(char *dir);
|
||||
__rayapi signed char raydium_path_write(char *dir);
|
||||
__rayapi signed char raydium_path_string_from(char *str);
|
||||
__rayapi int raydium_path_string_to(char *out);
|
||||
__rayapi void raydium_path_resolv(char *in, char *out, char mode);
|
||||
__rayapi void raydium_path_dump(void);
|
||||
__rayapi void raydium_path_reset(void);
|
||||
__rayapi void raydium_path_init(void);
|
||||
|
||||
#endif
|
37
raydium/headers/php.h
Normal file
37
raydium/headers/php.h
Normal file
@ -0,0 +1,37 @@
|
||||
//!NOBINDINGS
|
||||
#ifndef _PHP_H
|
||||
#define _PHP_H
|
||||
|
||||
/*=
|
||||
PHP scripting engine
|
||||
5000
|
||||
**/
|
||||
|
||||
// Introduction
|
||||
/**
|
||||
This is the internal part of the RayPHP API, where Raydium
|
||||
deals with Zend engine.
|
||||
|
||||
All this is for internal use, so no documentation is provided.
|
||||
**/
|
||||
|
||||
#include "../php_wrappers.c"
|
||||
// use this macro when registering your functions
|
||||
#define C2PHP ZEND_FN
|
||||
|
||||
|
||||
// Dirty globals... (needed for WIN32 PHP support)
|
||||
#ifdef ZTS
|
||||
extern zend_compiler_globals *compiler_globals;
|
||||
extern zend_executor_globals *executor_globals;
|
||||
extern php_core_globals *core_globals;
|
||||
extern sapi_globals_struct *sapi_globals;
|
||||
extern void ***tsrm_ls;
|
||||
#endif
|
||||
__rayapi void raydium_php_error (int type, const char *msg, ...);
|
||||
__rayapi int raydium_php_uwrite (const char *str, uint str_length TSRMLS_DC);
|
||||
__rayapi void raydium_php_init_request (char *filename);
|
||||
__rayapi int raydium_php_exec (char *name);
|
||||
__rayapi void raydium_php_close (void);
|
||||
__rayapi void raydium_php_init (void);
|
||||
#endif
|
29
raydium/headers/profile.h
Normal file
29
raydium/headers/profile.h
Normal file
@ -0,0 +1,29 @@
|
||||
#ifndef _PROFILE_H
|
||||
#define _PROFILE_H
|
||||
#ifdef DEBUG_PROFILE
|
||||
|
||||
/*=
|
||||
Profiling (sort of ...)
|
||||
3500
|
||||
**/
|
||||
|
||||
// Introduction
|
||||
/**
|
||||
You will find here a few functions for a **very simple** profiling.
|
||||
For anything else than a quick time measure, use real profiling tools.
|
||||
Note: Use only one "profiler" at a time.
|
||||
**/
|
||||
|
||||
__rayapi unsigned long raydium_profile_timer;
|
||||
__rayapi void raydium_profile_start(void);
|
||||
/**
|
||||
Starts measure.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_profile_end(char *tag);
|
||||
/**
|
||||
Stops measure and displays result using ##tag## string.
|
||||
**/
|
||||
|
||||
#endif
|
||||
#endif
|
52
raydium/headers/random.h
Normal file
52
raydium/headers/random.h
Normal file
@ -0,0 +1,52 @@
|
||||
#ifndef _RANDOM_H
|
||||
#define _RANDOM_H
|
||||
/*=
|
||||
Random
|
||||
400
|
||||
**/
|
||||
|
||||
// Introduction
|
||||
/**
|
||||
These functions deals with random numbers generation.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_random_randomize (void);
|
||||
/**
|
||||
This function initialize the random number generator
|
||||
with current time for seed.
|
||||
**Note: ** You are not supposed to use this function.
|
||||
**/
|
||||
|
||||
__rayapi GLfloat raydium_random_pos_1 (void);
|
||||
/**
|
||||
"positive, to one": 0 <= res <= 1
|
||||
**/
|
||||
|
||||
__rayapi GLfloat raydium_random_neg_pos_1 (void);
|
||||
/**
|
||||
"negative and positive, one as absolute limit": -1 <= res <= 1
|
||||
**/
|
||||
|
||||
__rayapi GLfloat raydium_random_0_x (GLfloat i);
|
||||
/**
|
||||
"zero to x": 0 <= res <= x
|
||||
**/
|
||||
|
||||
__rayapi GLfloat raydium_random_f (GLfloat min, GLfloat max);
|
||||
/**
|
||||
min <= res <= max (float)
|
||||
**/
|
||||
|
||||
__rayapi int raydium_random_i (int min, int max);
|
||||
/**
|
||||
min <= res <= max (integer)
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_random_proba (GLfloat proba);
|
||||
/**
|
||||
Returns true or false (0 or 1) depending of "proba" factor.
|
||||
##proba## must be: 0 <= proba <=1
|
||||
ex: 50% = 0.5
|
||||
**/
|
||||
|
||||
#endif
|
292
raydium/headers/raydoc.php
Normal file
292
raydium/headers/raydoc.php
Normal file
@ -0,0 +1,292 @@
|
||||
#!/usr/bin/php
|
||||
<?
|
||||
/*
|
||||
Raydium - CQFD Corp.
|
||||
http://raydium.org/
|
||||
License: GPL - GNU General Public License, see "gpl.txt" file.
|
||||
*/
|
||||
|
||||
// This script generates a Wiki(ni) style documentation from comments of
|
||||
// all header files of Raydium (raydium/header/*.h)
|
||||
|
||||
$page="http://wiki.raydium.org/wiki/RaydiumApiReference";
|
||||
|
||||
$intro="
|
||||
======Raydium API Reference======
|
||||
|
||||
=====CQFD Corp.=====
|
||||
|
||||
This document is the most up-to-date version. **This is a work in progress**:
|
||||
there's again some errors and wrong informations. Try, wait, or contribute ;)
|
||||
|
||||
\"\"<a href=$page#chapters>Index of chapters</a>\"\"
|
||||
\"\"<a href=$page#index>Index of all Raydium functions</a>\"\"
|
||||
|
||||
----
|
||||
This document is autogenerated, any change will be lost,
|
||||
use RaydiumApiReferenceComments for any need.
|
||||
{DATE}, for Raydium **{VERSION}**
|
||||
----
|
||||
";
|
||||
|
||||
|
||||
|
||||
function getTagLine($tag,$lines,$from=0)
|
||||
{
|
||||
for($i=$from;$i<count($lines);$i++)
|
||||
{
|
||||
$l=$lines[$i];
|
||||
if(substr(trim($l),0,strlen($tag))==$tag)
|
||||
return $i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
function getVersion()
|
||||
{
|
||||
$file="../common.h";
|
||||
$f=file($file);
|
||||
$maj=getTagLine("#define RAYDIUM_MAJOR",$f);
|
||||
$min=getTagLine("#define RAYDIUM_MINOR",$f);
|
||||
|
||||
$maj=str_replace("\t"," ",trim($f[$maj]));
|
||||
$min=str_replace("\t"," ",trim($f[$min]));
|
||||
|
||||
$maj=explode(" ",$maj);
|
||||
$min=explode(" ",$min);
|
||||
$maj=$maj[count($maj)-1];
|
||||
$min=$min[count($min)-1];
|
||||
|
||||
return sprintf("%d.%03d",$maj,$min);
|
||||
}
|
||||
|
||||
function getMain($filename,$offset)
|
||||
{
|
||||
$f=file($filename);
|
||||
$l=getTagLine("/*=",$f);
|
||||
if($l==-1)
|
||||
return -1;
|
||||
$res=trim($f[$l+$offset]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
function getPriority($filename)
|
||||
{
|
||||
$res=trim(getMain($filename,2));
|
||||
if(is_numeric($res))
|
||||
return $res;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
function getTitle($filename)
|
||||
{
|
||||
return trim(getMain($filename,1));
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getHeaders($directory)
|
||||
{
|
||||
$res=array();
|
||||
if (is_dir($directory))
|
||||
{
|
||||
if ($dh = opendir($directory))
|
||||
{
|
||||
while (($file = readdir($dh)) !== false)
|
||||
{
|
||||
if(substr($file,-2)==".h")
|
||||
{
|
||||
$res[]=$file;
|
||||
}
|
||||
}
|
||||
closedir($dh);
|
||||
}
|
||||
}
|
||||
else echo "'$directory' is not a directory";
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
$chapters=array();
|
||||
function h1($str,$addchap=true)
|
||||
{
|
||||
global $chapters;
|
||||
static $i=1;
|
||||
if($addchap)
|
||||
{
|
||||
echo '""'."<a name=chap$i></a>".'""';
|
||||
$chapters[$i]=$str;
|
||||
$i++;
|
||||
}
|
||||
echo "\n=====$str:=====\n";
|
||||
}
|
||||
|
||||
function h2($str)
|
||||
{
|
||||
echo "====$str:====\n";
|
||||
}
|
||||
|
||||
function body($str)
|
||||
{
|
||||
echo $str."\n\n";
|
||||
}
|
||||
|
||||
function intro($str)
|
||||
{
|
||||
$str=str_replace("{DATE}","Generated: ".date("Y-m-d H:i:s"),$str);
|
||||
$str=str_replace("{VERSION}",getVersion(),$str);
|
||||
echo $str;
|
||||
}
|
||||
|
||||
$index=array();
|
||||
function addToIndex($f)
|
||||
{
|
||||
static $i=0;
|
||||
global $index;
|
||||
|
||||
$p=strpos($f,"raydium_");
|
||||
if($p!==false)
|
||||
$f=substr($f,$p);
|
||||
else
|
||||
$f="unsupported - $f";
|
||||
|
||||
$index[$i]=$f."|$i";
|
||||
return $i++;
|
||||
}
|
||||
|
||||
// Main
|
||||
|
||||
$id="";
|
||||
$files=getHeaders(".");
|
||||
//var_dump($files);
|
||||
if($files==-1)
|
||||
die("No header found");
|
||||
|
||||
unset($sorted);
|
||||
for($i=0;$i<count($files);$i++)
|
||||
{
|
||||
$file=$files[$i];
|
||||
$p=getPriority($file);
|
||||
if($p==-1)
|
||||
$p=999000+$i;
|
||||
|
||||
while(isset($sorted[$p]))
|
||||
$p++;
|
||||
$sorted[$p]=$file;
|
||||
}
|
||||
ksort($sorted);
|
||||
$sorted=array_values($sorted);
|
||||
//var_dump($sorted);
|
||||
|
||||
// Files are sorted, now
|
||||
|
||||
intro($intro);
|
||||
|
||||
for($i=0;$i<count($sorted);$i++)
|
||||
{
|
||||
$file=$sorted[$i];
|
||||
$title=getTitle($file);
|
||||
|
||||
if($title==-1)
|
||||
{
|
||||
h1(($i+1)." no documentation for $file");
|
||||
continue;
|
||||
}
|
||||
|
||||
h1(($i+1)." $title");
|
||||
|
||||
$f=file($file);
|
||||
$last=0;
|
||||
$n=0;
|
||||
while(($l=getTagLine("/**",$f,$last))!=-1)
|
||||
{
|
||||
$title=trim($f[$l-1]);
|
||||
if($title=="")
|
||||
$title="// unknown item";
|
||||
|
||||
// types:
|
||||
// 1 - Comment (//)
|
||||
// 2 - Macro (#)
|
||||
// 3 - Code (...)
|
||||
$type=3;
|
||||
if($title[0]=="/")
|
||||
{
|
||||
$type=1;
|
||||
$title=trim(substr($title,2));
|
||||
}
|
||||
|
||||
if($title[0]=="#")
|
||||
{
|
||||
$type=2;
|
||||
$pos=strpos($title,")");
|
||||
if($pos)
|
||||
{
|
||||
$title=substr($title,0,$pos+1);
|
||||
}
|
||||
$title=trim(str_replace("#define ","",$title))." (macro)";
|
||||
|
||||
}
|
||||
|
||||
if($type==3)
|
||||
{
|
||||
if(substr($title,0,7)=="extern ")
|
||||
$title=trim(substr($title,7));
|
||||
if(substr($title,0,9)=="__rayapi ")
|
||||
$title=trim(substr($title,9));
|
||||
if($title[strlen($title)-1]==";")
|
||||
$title=substr($title,0,-1);
|
||||
$title=trim(str_replace("**","* *",$title));
|
||||
}
|
||||
|
||||
if($type==2 || $type==3)
|
||||
$id=addToIndex($title);
|
||||
|
||||
h2('""'."<a name=$id></a>".'""'.($i+1).".".($n+1)." $title");
|
||||
|
||||
$last=$l+1;
|
||||
$end=getTagLine("**/",$f,$last);
|
||||
if($end==-1)
|
||||
die("expected '**/' (started line $l)");
|
||||
|
||||
unset($body);
|
||||
/* for($j=$l+1;$j<$end;$j++)
|
||||
{
|
||||
$lj=trim($f[$j]);
|
||||
if($lj=="")
|
||||
$lj="\n\n";
|
||||
else
|
||||
$lj.=" ";
|
||||
$body[]=$lj;
|
||||
}
|
||||
$str=implode("",$body);*/
|
||||
for($j=$l+1;$j<$end;$j++)
|
||||
{
|
||||
$lj=trim($f[$j]);
|
||||
$body[]=$lj;
|
||||
}
|
||||
$str=@implode("\n",$body);
|
||||
body($str);
|
||||
|
||||
$last=$end+1;
|
||||
$n++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
h1('""<a name=chapters></a>""Chapters',false);
|
||||
foreach($chapters as $key => $val)
|
||||
{
|
||||
echo('====""'."<a href=$page#chap$key>$val</a>".'""====')."\n";
|
||||
}
|
||||
|
||||
sort($index);
|
||||
h1('""<a name=index></a>""Index');
|
||||
for($i=0;$i<count($index);$i++)
|
||||
{
|
||||
$j=explode("|",$index[$i]);
|
||||
$k=$j[0];
|
||||
$l=$j[1];
|
||||
echo '""'."<a href=$page#$l><tt>$k</tt></a>".'""'."\n";
|
||||
}
|
||||
|
64
raydium/headers/rayphp.h
Normal file
64
raydium/headers/rayphp.h
Normal file
@ -0,0 +1,64 @@
|
||||
//!NOBINDINGS
|
||||
#ifndef _RAYPHP_H
|
||||
#define _RAYPHP_H
|
||||
|
||||
/*=
|
||||
RayPHP (internals)
|
||||
3600
|
||||
**/
|
||||
|
||||
// Introduction
|
||||
/**
|
||||
Raydium also use RayPHP (Raydium/PHP interface) for its own needs.
|
||||
For PHP part of these functions, see "rayphp/" directory.
|
||||
So far, RayPHP is dedicated to R3S (Raydium Server Side Scripts) access.
|
||||
All this is mostly usefull for internal uses, since Raydium provides ##fopen##
|
||||
wrappers, thru ##raydium_file_fopen##.
|
||||
|
||||
R3S is able to work with HTTP and FTP, and supports proxy using ##raydium.db##
|
||||
configuration database. Example : %%Generic-Proxy;http://proxy:3128/%%
|
||||
The trailing ##/## (slash) must be present.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_php_rayphp_path_change(char *path);
|
||||
/**
|
||||
By default, Raydium search for a "rayphp/" subdirectory in the application
|
||||
directory. It's possible to change this using a --rayphp command line
|
||||
switch, or using this function. You must call the function as soon as possible,
|
||||
before any use of RayPHP.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_rayphp_repository_file_get (char *path);
|
||||
/**
|
||||
Will contact R3S servers for downloading ##path## file.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_rayphp_repository_file_put (char *path, int depends);
|
||||
/**
|
||||
Will contact R3S servers for uploading ##path## file. Set ##depends## to
|
||||
true (1) if you also want to upload dependencies, false (0) otherwise.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_rayphp_repository_file_list(char *filter);
|
||||
/**
|
||||
Will contact R3S servers to get file list, using ##filter## (shell-like
|
||||
syntax). Default ##filter## is ##*##.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_rayphp_http_test(void);
|
||||
/**
|
||||
Test if Internet connection is available using Raydium website.
|
||||
(0 means 'not available', 1 means 'OK')
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_rayphp_repository_defaults(char *def);
|
||||
/**
|
||||
Gives the default repositories for this applications
|
||||
|
||||
This function will create two files, ##repositories.list## and
|
||||
##repositories.upload## in game user home directory, if these files
|
||||
don't alreay exist, and will fill the files with ##def##.
|
||||
This argument is an URL, or a list of URLs (use \n separator). See R3S doc.
|
||||
**/
|
||||
|
||||
#endif
|
21
raydium/headers/reg_api.h
Normal file
21
raydium/headers/reg_api.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef _REGAPI_H
|
||||
#define _REGAPI_H
|
||||
|
||||
/*=
|
||||
RegAPI
|
||||
4100
|
||||
**/
|
||||
|
||||
// Introduction
|
||||
/**
|
||||
RegAPI is an internal system that exports some Raydium's API functions to
|
||||
scripting engine, creating bindings.
|
||||
See RayPHP chapter for more informations anout scripting.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_register_api(void);
|
||||
/**
|
||||
Internal. Will register Raydium API.
|
||||
**/
|
||||
|
||||
#endif
|
73
raydium/headers/register.h
Normal file
73
raydium/headers/register.h
Normal file
@ -0,0 +1,73 @@
|
||||
#ifndef _REGISTER_H
|
||||
#define _REGISTER_H
|
||||
|
||||
/*=
|
||||
Data registration
|
||||
3400
|
||||
**/
|
||||
|
||||
// Introduction
|
||||
/**
|
||||
Raydium supports scripting, for example using PHP in the current implementation.
|
||||
All ##raydium_register_*## functions are provided as a "bridge" between
|
||||
your applications and PHP scripts, allowing you to "export" native variables
|
||||
and functions to PHP scripts.
|
||||
For more informations, see PHP chapters.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_register_find_name (char *name);
|
||||
/**
|
||||
Lookups a **variable** by ##name##. Search is not possible (yet) for
|
||||
registered functions.
|
||||
Mostly used internally.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_register_name_isvalid (char *name);
|
||||
/**
|
||||
Tests ##name##, and returns his viability as a boolean.
|
||||
Accepted intervals for variables and functions: [a-z], [A-Z] and '_'
|
||||
Numerics are not allowed.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_register_variable (void *addr, int type, char *name);
|
||||
/**
|
||||
Will register a new variable. You must provide variable's address (##addr##),
|
||||
##type## and ##name##.
|
||||
Current available types are: ##RAYDIUM_REGISTER_INT##, ##RAYDIUM_REGISTER_FLOAT##,
|
||||
and ##RAYDIUM_REGISTER_STR##.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_register_variable_const_f(float val, char *name);
|
||||
/**
|
||||
Will register a new ##float## constant.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_register_variable_const_i(int val, char *name);
|
||||
/**
|
||||
Will register a new ##int## constant.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_register_variable_unregister_last (void);
|
||||
/**
|
||||
Variable are registered on a stack. As you may want to create "temporary"
|
||||
variables (usefull for building script's arguments, for example), this function
|
||||
allows you to unregister last registered variable. Multiple calls are possible.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_register_modifiy (char *var, char *args);
|
||||
/**
|
||||
Deprecated.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_register_function (void *addr, char *name);
|
||||
/**
|
||||
Will register a function. You only need to provide an address (##addr##)
|
||||
and a name.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_register_dump (void);
|
||||
/**
|
||||
Will dump to console all registered variables and functions.
|
||||
**/
|
||||
|
||||
#endif
|
108
raydium/headers/render.h
Normal file
108
raydium/headers/render.h
Normal file
@ -0,0 +1,108 @@
|
||||
#ifndef _RENDER_H
|
||||
#define _RENDER_H
|
||||
/*=
|
||||
Rendering
|
||||
1300
|
||||
**/
|
||||
|
||||
// Introduction
|
||||
/*=
|
||||
render.c contains Raydium rendering core, so only "public" and
|
||||
interesting function will be documented.
|
||||
|
||||
It' obvious for me that many parts of this code have to be
|
||||
rewritten (tips: slow, buggy, old, ... :)
|
||||
**/
|
||||
|
||||
__rayapi void raydium_render_lightmap_color(GLfloat *color);
|
||||
/**
|
||||
You may force a new lightmap rendering color "filter" anytime with this
|
||||
function, allowing advanced lighting effects.
|
||||
HUGE WARNING: You must turn off display lists if you change this value after
|
||||
first object's render.
|
||||
See ##raydium_rendering_displaylists_disable()## if needed.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_render_lightmap_color_4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a);
|
||||
/**
|
||||
Same as above, using 4 values.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_rendering_prepare_texture_unit (GLenum tu, GLuint tex);
|
||||
/**
|
||||
This function will "prepare" hardawre texture unit ##tu## to render ##tex## texture.
|
||||
There almost no reason to call this function by yourself.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_rendering_internal_prepare_texture_render (GLuint tex);
|
||||
/**
|
||||
Same as above, but for texture unit #0 only.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_rendering_internal_restore_render_state (void);
|
||||
/**
|
||||
Internal. Deprecated.
|
||||
**/
|
||||
|
||||
// DO NOT DOCUMENT THIS ... THING !
|
||||
__rayapi char infov (GLfloat x, GLfloat y);
|
||||
|
||||
__rayapi void raydium_rendering_from_to_simple(GLuint from, GLuint to);
|
||||
/**
|
||||
Same as ##raydium_rendering_from_to()##, but only with vertices (no
|
||||
UV, no normals, no textures, no colors, ...).
|
||||
Mostly used for internal shadow maps creation.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_rendering_from_to (GLuint from, GLuint to);
|
||||
/**
|
||||
Renders vertices from ##from## to ##to##.
|
||||
Using object management functions is a better idea.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_rendering (void);
|
||||
/**
|
||||
Renders all vertices (probably useless, now).
|
||||
**/
|
||||
|
||||
__rayapi void raydium_rendering_finish (void);
|
||||
/**
|
||||
You must call this function at the end of each frame. This will flush all
|
||||
commands to hardware, fire a lot off callbacks, and prepare next frame.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_rendering_wireframe (void);
|
||||
/**
|
||||
Switch to wireframe rendering.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_rendering_normal (void);
|
||||
/**
|
||||
Switch back to standard rendering.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_rendering_rgb_force (GLfloat r, GLfloat g, GLfloat b);
|
||||
/**
|
||||
Force all RGB colored vertices to take ##(r,g,b)## color. One example of this
|
||||
use is for making "team colored" cars : Do not apply textures to some faces
|
||||
while modelling, and force to team color each time you render a car.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_rendering_rgb_normal (void);
|
||||
/**
|
||||
Disable "rgb force" state. See above.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_rendering_displaylists_disable(void);
|
||||
/**
|
||||
Disable display lists usage.
|
||||
Some old video cards and broken drivers may get better performances WITHOUT
|
||||
display lists (on large objects, mainly).
|
||||
**/
|
||||
|
||||
__rayapi void raydium_rendering_displaylists_enable(void);
|
||||
/**
|
||||
Enable display lists usage. default state.
|
||||
**/
|
||||
|
||||
#endif
|
159
raydium/headers/shader.h
Normal file
159
raydium/headers/shader.h
Normal file
@ -0,0 +1,159 @@
|
||||
#ifndef _SHADER__H
|
||||
#define _SHADER__H
|
||||
#include "../shader.h"
|
||||
|
||||
/*=
|
||||
Shaders
|
||||
4500
|
||||
**/
|
||||
|
||||
// Introduction
|
||||
/**
|
||||
Raydium provides a support for OpenGL Shading Language (GLSL).
|
||||
This documentation talks only about Raydium Shader API, and not about
|
||||
the Shading Language itself. With Raydium, shaders works by two: you must
|
||||
provide a vertex shader and a fragment shader each time. This is a very
|
||||
usual way to do.
|
||||
|
||||
You must know that **only one** shader can be active at a time.
|
||||
Once a shader is loaded, Raydium API allows you to attach this shader to
|
||||
a texture, so you don't have to deal manually with activation/deactivation.
|
||||
|
||||
You can also change all "uniform" variables from shaders
|
||||
using ##raydium_shader_var_...()## functions.
|
||||
Into this set, all functions that does **not** contain the **_name**
|
||||
suffix **are only able to deal with current shader !**.
|
||||
|
||||
You can use the global variable ##raydium_shader_support## to detect if
|
||||
current hardware supports GLSL or not (1=OK 0=no shader support).
|
||||
**/
|
||||
|
||||
|
||||
__rayapi void raydium_shader_init(void);
|
||||
/**
|
||||
Internal use. Init all shader subsystem.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_shader_isvalid(int shader);
|
||||
/**
|
||||
Internal use. Returns true (1) if ##shader## slot is in bounds and filled.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_shader_find(char *name);
|
||||
/**
|
||||
Returns shader's ID using its ##name##.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_shader_infolog(GLhandleARB shader);
|
||||
/**
|
||||
Internal use.
|
||||
Reports full driver error message when shader compilation or linking fails.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_shader_load(char *name, char *file_vert, char *file_frag);
|
||||
/**
|
||||
Loads the vertex shader ##file_vert## and the fragment shader ##file_frag##.
|
||||
The shader is stored with the provided ##name##. This function returns the
|
||||
shader ID or -1 in case of failure.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_shader_variable(int shader, char *name);
|
||||
/**
|
||||
Returns an ID for the variable "##name## of the provided ##shader##.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_shader_var_i(int var_id, int value);
|
||||
/**
|
||||
This function will change the ##value## of the variable ##var_id## of
|
||||
the current shader.
|
||||
Value is an integer.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_shader_var_i_name(char *shader, char *variable, int value);
|
||||
/**
|
||||
Same as above, but using shader's name and variable's name. This function is
|
||||
able to change the ##variable##'s ##value## even is the ##shader## is not
|
||||
the current one.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_shader_var_f(int var_id, float value);
|
||||
/**
|
||||
This function will change the ##value## of the variable ##var_id## of
|
||||
the current shader.
|
||||
Value is a float.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_shader_var_f_name(char *shader, char *variable, float value);
|
||||
/**
|
||||
Same as above, but using shader's name and variable's name. This function is
|
||||
able to change the ##variable##'s ##value## even is the ##shader## is not
|
||||
the current one.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_shader_var_2f(int var_id, float value1, float value2);
|
||||
/**
|
||||
This function will change the ##value## of the variable ##var_id## of
|
||||
the current shader.
|
||||
Value is an "array" of 2 floats (vec2).
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_shader_var_2f_name(char *shader, char *variable, float value1, float value2);
|
||||
/**
|
||||
Same as above, but using shader's name and variable's name. This function is
|
||||
able to change the ##variable##'s ##value## even is the ##shader## is not
|
||||
the current one.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_shader_var_3f(int var_id, float value1, float value2, float value3);
|
||||
/**
|
||||
This function will change the ##value## of the variable ##var_id## of
|
||||
the current shader.
|
||||
Value is an "array" of 3 floats (vec3).
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_shader_var_3f_name(char *shader, char *variable, float value1, float value2, float value3);
|
||||
/**
|
||||
Same as above, but using shader's name and variable's name. This function is
|
||||
able to change the ##variable##'s ##value## even is the ##shader## is not
|
||||
the current one.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_shader_var_4f(int var_id, float value1, float value2, float value3, float value4);
|
||||
/**
|
||||
This function will change the ##value## of the variable ##var_id## of
|
||||
the current shader.
|
||||
Value is an "array" of 4 floats (vec4).
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_shader_var_4f_name(char *shader, char *variable, float value1, float value2, float value3, float value4);
|
||||
/**
|
||||
Same as above, but using shader's name and variable's name. This function is
|
||||
able to change the ##variable##'s ##value## even is the ##shader## is not
|
||||
the current one.
|
||||
**/
|
||||
|
||||
|
||||
__rayapi signed char raydium_shader_current(int shader);
|
||||
/**
|
||||
This function will change the current active shader with ##shader##.
|
||||
To disable a shader and get back to regular OpenGL fixed function pipeline,
|
||||
set ##shader## value to ##-1##.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_shader_current_name(char *shader);
|
||||
/**
|
||||
Same as above, but using shader's name.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_shader_attach_texture(int shader, int texture);
|
||||
/**
|
||||
During rendering, each time the ##texture## will be used by any object,
|
||||
the ##shader## will be activated.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_shader_attach_texture_name(char *shader, char *texture);
|
||||
/**
|
||||
Same as above, but using shader's name and texture's name.
|
||||
**/
|
||||
|
||||
#endif
|
16
raydium/headers/shadow.h
Normal file
16
raydium/headers/shadow.h
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef _SHADOW__H
|
||||
#define _SHADOW__H
|
||||
#include "../shadow.h"
|
||||
|
||||
__rayapi void raydium_shadow_init(void);
|
||||
__rayapi void raydium_shadow_enable(void);
|
||||
__rayapi void raydium_shadow_disable(void);
|
||||
__rayapi signed char raydium_shadow_isenabled(void);
|
||||
__rayapi void raydium_shadow_light_main(GLuint l);
|
||||
__rayapi void raydium_shadow_ground_change(int object);
|
||||
__rayapi void raydium_shadow_map_generate(void);
|
||||
__rayapi void raydium_shadow_map_render(void);
|
||||
__rayapi void raydium_shadow_object_draw(GLuint o);
|
||||
|
||||
|
||||
#endif
|
17
raydium/headers/signal.h
Normal file
17
raydium/headers/signal.h
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef _HEADERS_SIGNAL_H
|
||||
#define _HEADERS_SIGNAL_H
|
||||
/*=
|
||||
Signals
|
||||
2500
|
||||
**/
|
||||
|
||||
// Quickview
|
||||
/**
|
||||
There almost nothing to said about signals management, except that Raydium
|
||||
will try to catch SIGINT signal (sended by CTRL+C sequence, for example).
|
||||
There's nothing else for now, but we plan a user callback for this signal.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_signal_handler (int sig);
|
||||
__rayapi void raydium_signal_install_trap (void);
|
||||
#endif
|
80
raydium/headers/sky.h
Normal file
80
raydium/headers/sky.h
Normal file
@ -0,0 +1,80 @@
|
||||
#ifndef _SKY_H
|
||||
#define _SKY_H
|
||||
|
||||
/*=
|
||||
Sky and environement boxes
|
||||
1900
|
||||
**/
|
||||
|
||||
// Introduction
|
||||
/**
|
||||
Skyboxes are mostly automated.
|
||||
|
||||
For now, Raydium will use ##BOXfront.tga##, ##BOXback.tga##, ##BOXleft.tga##,
|
||||
##BOXright.tga##, ##BOXbottom.tga## and ##BOXtop.tga## and will draw a
|
||||
skybox only if fog is disabled (this is not for technical reasons,
|
||||
but only for realism, just think about it ;)... but you can force
|
||||
skybox with fog using ##raydium_sky_force## if you really want).
|
||||
**/
|
||||
|
||||
|
||||
__rayapi void raydium_sky_box_cache (void);
|
||||
/**
|
||||
As skybox texture are sometimes large files, you can pre-load skybox
|
||||
with this function. If you don't do it, Raydium will load textures
|
||||
during the first frame of your application.
|
||||
Calling this function will automatically define sky as a HDR emitter.
|
||||
See HDR chapter for more information.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_sky_box_render (GLfloat x, GLfloat y, GLfloat z);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_sky_sphere_render(GLfloat x, GLfloat y, GLfloat z, int detail);
|
||||
/**
|
||||
Internal use.
|
||||
Calculates and draw the sphere. Also rotate it according the angles or orbit.
|
||||
**/
|
||||
|
||||
//Atmosphere
|
||||
/**
|
||||
Atmosphere are series of effects that intend to make the sky and the atmosphere
|
||||
of the game more realistic. As this is quite-beta state, only a orbital sky
|
||||
effect is available right now.
|
||||
To activate/deactivate this series of effects, you should use:
|
||||
##raydium_sky_atmosphere_enable## and ##raydium_sky_atmosphere_disable##
|
||||
respectively.
|
||||
If you need to check if the atmosphere is activated or not, use
|
||||
##raydium_sky_atmosphere_check##. The rest of the functions are internal
|
||||
and should not used by normal programs.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_sky_atmosphere_enable(void);
|
||||
/**
|
||||
turn on the use of atmosphere effects.
|
||||
This one and _disable function a program should use, the other
|
||||
##raydium_sky_atmosphere_## are internal ones.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_sky_atmosphere_disable(void);
|
||||
/**
|
||||
turn off the use of atmosphere effects.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_sky_atmosphere_render(GLfloat x, GLfloat y, GLfloat z,int detail);
|
||||
/**
|
||||
Internal use. This internal function draws the atmosphere effects. Right
|
||||
now only draws a rotating sphere with a gradient of color (from black to white).
|
||||
In a future, it will draw multiples layers of sky (with and without textures),
|
||||
stars, satellites... Maybe rain and snow could be included here also.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_sky_atmosphere_check(void);
|
||||
/**
|
||||
This functions only check if the atmosphere features are been used.
|
||||
Returns 1 if they are used, else 0.
|
||||
**/
|
||||
|
||||
#endif
|
292
raydium/headers/sound.h
Normal file
292
raydium/headers/sound.h
Normal file
@ -0,0 +1,292 @@
|
||||
#ifndef _SOUND_H
|
||||
#define _SOUND_H
|
||||
/*=
|
||||
Sound and music
|
||||
2600
|
||||
**/
|
||||
|
||||
// Introduction
|
||||
/**
|
||||
The Raydium sound API is pretty easy to use and there's only need to use a
|
||||
few functions to make your program ouput sounds or music.
|
||||
|
||||
On top of this, there are a bunch of functions to modify the sound behavior.
|
||||
|
||||
Raydium uses OpenAL and OggVorbis for its sounds and musics, for a basic
|
||||
use of our sound API you only need to know one thing: OpenAL uses buffers
|
||||
for its sounds and you need to be able to address the sounds separately.
|
||||
For this we use ALuint in our code. Each buffer is associated to a source,
|
||||
we have an array of all available sources and then, you only need to have
|
||||
a simple int that acts as an index in this array. See below for more
|
||||
informations.
|
||||
|
||||
Music is readed thru libogg, streamed from disk. If you want to play an
|
||||
OGG audio track, the only thing you've to do is to call the suitable function.
|
||||
You can use ##raydium_sound_music_eof_callback## if needed. This event is
|
||||
fired when sound track ends, allowing you to switch to another file.
|
||||
Prototype for this callback is ##int callback(char *new_track)##, allowing
|
||||
you to do something like ##strcpy(new_track,"foobar.ogg"); return 1;##.
|
||||
Return 0 if you do not want to switch to another audio file (this will stops
|
||||
music playback).
|
||||
Another callback is available, ##raydium_sound_music_changed_callback##, fired
|
||||
just after a music track switch, allowing you to get new informations from the
|
||||
new stream, such as artist, album and title. See ##raydium_sound_load_music()##
|
||||
for more informations about this.
|
||||
|
||||
This document is not an alternative to OpenAL papers, and only provides
|
||||
informations about Raydium's interface to OpenAL.
|
||||
See specifications here: http://www.openal.org/documentation.html
|
||||
**/
|
||||
|
||||
__rayapi void raydium_sound_verify (char *caller);
|
||||
/**
|
||||
This functions checks if any error occured during last OpenAL operation.
|
||||
You don't have to call this function by yourself, since every function of
|
||||
this API will do it.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_sound_Array3IsValid(ALfloat *a);
|
||||
/**
|
||||
Since OpenAL is very sensitive to malformed values, this function is used
|
||||
internally to check consistency of provided ALfloat arrays.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_sound_InitSource (int src);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_sound_LoadWav (const char *fname);
|
||||
/**
|
||||
This function tries to load the ##fname## wav file into a buffer, if
|
||||
successful, it returns the source id, else 0.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_sound_SourceVerify (int src);
|
||||
/**
|
||||
Internal id checks.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_sound_SetSourceLoop (int src, signed char loop);
|
||||
/**
|
||||
Modifies the ##loop## property of the ##src## source (loops if loop is non-zero,
|
||||
default value for a source is "true").
|
||||
Returns 0 if ok, -1 if error.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_sound_GetSourcePitch (int src, ALfloat * p);
|
||||
/**
|
||||
Returns current pitch for ##src## source.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_sound_SetSourcePitch (int src, ALfloat p);
|
||||
/**
|
||||
Sets pitch for ##src## source.
|
||||
Current OpenAL spec is not clear about pitch's limits. Raydium will
|
||||
clamp values to to ]0,2] interval.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_sound_GetSourceGain (int src, ALfloat * g);
|
||||
/**
|
||||
Returns current gain ("volume") for ##src## source.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_sound_SetSourceGain (int src, ALfloat g);
|
||||
/**
|
||||
Sets gain ("volume") for ##src## source.
|
||||
Current OpenAL spec is not clear about pitch's limits. Raydium do not allows
|
||||
negative values, but no upper limit is set.
|
||||
Warning: some OpenAL implementations will provide strange gain curves. More
|
||||
work is needed on this issue.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_sound_SetSourcePos (int src, ALfloat Pos[]);
|
||||
/**
|
||||
Sets 3D position of ##src## source.
|
||||
##Pos## is a 3 * ALfloat array.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_sound_SetSourcePosCamera(int src);
|
||||
/**
|
||||
Sets 3D position of ##src## source on the current camera position.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_sound_GetSourcePos (int src, ALfloat * Pos[]);
|
||||
/**
|
||||
Returns current 3D position of ##src## source.
|
||||
##Pos## is a 3 * ALfloat array.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_sound_SetSourceDir (int src, ALfloat Dir[]);
|
||||
/**
|
||||
Sets 3D direction of ##src## source.
|
||||
##Dir## is a 3 * ALfloat array.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_sound_GetSourceDir (int src, ALfloat * Dir[]);
|
||||
/**
|
||||
Returns current 3D direction of ##src## source.
|
||||
##Dir## is a 3 * ALfloat array.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_sound_SetSourceVel (int src, ALfloat Vel[]);
|
||||
/**
|
||||
Sets 3D velocity of ##src## source.
|
||||
##Vel## is a 3 * ALfloat array.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_sound_GetSourceVel (int src, ALfloat * Vel[]);
|
||||
/**
|
||||
Returns current 3D velocity of ##src## source.
|
||||
##Vel## is a 3 * ALfloat array.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_sound_SetListenerPos (ALfloat Pos[]);
|
||||
/**
|
||||
Sets 3D position of listener.
|
||||
This is done automatically by Raydium, each frame, using camera informations
|
||||
##Pos## is a 3 * ALfloat array.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_sound_GetListenerPos (ALfloat * Pos[]);
|
||||
/**
|
||||
Returns current 3D position of listener.
|
||||
##Pos## is a 3 * ALfloat array.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_sound_SetListenerOr (ALfloat Or[]);
|
||||
/**
|
||||
Sets 3D orientation of listener.
|
||||
This is done automatically by Raydium, each frame, using camera informations
|
||||
##Or## is a 3 * ALfloat array.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_sound_GetListenerOr (ALfloat * Or[]);
|
||||
/**
|
||||
Returns current 3D orientation of listener.
|
||||
##Or## is a 3 * ALfloat array.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_sound_SetListenerVel (ALfloat Vel[]);
|
||||
/**
|
||||
Sets 3D velocity of Listener.
|
||||
##Vel## is a 3 * ALfloat array.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_sound_GetListenerVel (ALfloat * Vel[]);
|
||||
/**
|
||||
Returns current 3D velocity of Listener.
|
||||
##Vel## is a 3 * ALfloat array.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_sound_init (void);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_sound_SourcePlay (int src);
|
||||
/**
|
||||
Plays the ##src## source.
|
||||
If ##src## was already in "play" state, the buffer is rewinded.
|
||||
Returns 0 if ok, -1 if error.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_sound_SourceStop (int src);
|
||||
/**
|
||||
Stops the ##src## source.
|
||||
Returns 0 if ok, -1 if error.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_sound_SourcePause (int src);
|
||||
/**
|
||||
Will pause the ##src## source.
|
||||
Returns 0 if ok, -1 if error.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_sound_SourceUnpause (int src);
|
||||
/**
|
||||
##src## will restart playback after being paused.
|
||||
Returns 0 if ok, -1 if error.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_sound_IsPlaying(int src);
|
||||
/**
|
||||
Returns true (1) if ##src## is playing, false (0) if stopped or invalid.
|
||||
**/
|
||||
|
||||
|
||||
__rayapi void raydium_sound_close (void);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi int BufferData (ALuint buffer, OggVorbis_File * file, vorbis_info * ogginfo);
|
||||
__rayapi void raydium_sound_internal_cleanstreambuffs (void);
|
||||
__rayapi int StartMusic (ALuint musicsource, ALuint * buffers, OggVorbis_File * file, vorbis_info * ogginfo);
|
||||
__rayapi int raydium_sound_load_music (char *fname);
|
||||
/**
|
||||
Opens fname **OGG** music file and prepairs Raydium for playing it.
|
||||
The music will be automatically played after a call to this function.
|
||||
This function will use R3S (data repositories) if needed.
|
||||
To switch to another audio track, simply call again this function.
|
||||
Send ##NULL## or an empty string to cancel music playback.
|
||||
Returns 0 if ok, -1 if error
|
||||
|
||||
See also ##raydium_sound_music_eof_callback## at the top of this chapter.
|
||||
|
||||
You can get OGG informations from ##raydium_sound_music_info##, using
|
||||
its members:
|
||||
%%(c)
|
||||
char artist[RAYDIUM_MAX_NAME_LEN];
|
||||
char title [RAYDIUM_MAX_NAME_LEN];
|
||||
char album [RAYDIUM_MAX_NAME_LEN];
|
||||
%%
|
||||
**/
|
||||
|
||||
__rayapi void raydium_sound_music_info_init(void);
|
||||
/**
|
||||
Internal use. Will reset infos.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_sound_music_info_refresh(void);
|
||||
/**
|
||||
Internal use. Will flush infos from disk to ##raydium_sound_music_info##.
|
||||
**/
|
||||
|
||||
|
||||
__rayapi void raydium_sound_music_callback (void);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_sound_callback (void);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_sound_source_fade(int src, ALfloat len);
|
||||
/**
|
||||
This function will fade down source ##src## over ##len## seconds.
|
||||
Since gain is not linear, you may have to play a bit with ##len## to
|
||||
find the correct value for you.
|
||||
Use source 0 for music source.
|
||||
**/
|
||||
|
||||
// Sound API Example
|
||||
/**
|
||||
%%(c)
|
||||
int sound;
|
||||
sound=raydium_sound_LoadWav("explo.wav");
|
||||
raydium_sound_SetSourceLoop(sound,0);
|
||||
[...]
|
||||
if(explosion) raydium_sound_SourcePlay(sound);
|
||||
%%
|
||||
**/
|
||||
|
||||
__rayapi void raydium_sound_source_fade_to(int src, ALfloat len, char *to);
|
||||
/**
|
||||
Same as above, but plays ##to## file at the end of the fade.
|
||||
Warning: Works only for "music" source (##src## = 0).
|
||||
**/
|
||||
|
||||
#endif
|
99
raydium/headers/texture.h
Normal file
99
raydium/headers/texture.h
Normal file
@ -0,0 +1,99 @@
|
||||
#ifndef _TEXTURE_H
|
||||
#define _TEXTURE_H
|
||||
/*=
|
||||
Textures
|
||||
1200
|
||||
**/
|
||||
|
||||
// Introduction
|
||||
/**
|
||||
For now, Raydium only handles TGA uncompressed texture.
|
||||
As explainded in the first part of this guide, Raydium provides three
|
||||
texture filters (none, bilinear, trilinear using MipMaps ).
|
||||
|
||||
Texture sizes must be a power of two, 8 (alpha mask), 24 (RGB) or 32 (RGBA) bits.
|
||||
|
||||
Raydium supports simple color materials, using a "rgb(r,g,b)" string
|
||||
as texture name, where r, g and b are 0 <= x <= 1 (floats).
|
||||
With 3 negative values, you will generate a "phantom texture". Phantom textures
|
||||
are only drawn into the z-buffer (and not color buffer).
|
||||
Texture clamping and advanced multitexturing effects are supported by Raydium,
|
||||
but not documented here for now. If you're interested, have a look at source
|
||||
code, or take a look at the Wiki. Tips: "BOX", "ENV", "HDR", ";", "|".
|
||||
|
||||
Effective environment mapping (one pass, two texture units) is available using
|
||||
a special filename separator for texture field in TRI files : #
|
||||
See this example:
|
||||
##0.232258 0.225387 -0.149804 0.012198 -0.274925 0.961388 0.731411 0.980236 fiesta_diffuse.tga#ENV_map.tga##
|
||||
Environment texture name must start with "ENV" to allow spherical mapping, wich
|
||||
is needed for such effect. See also ##RAYDIUM_RENDER_REFLECTION_FACT## in
|
||||
file ##common.h## if you want reflection to be more or less visible.
|
||||
**/
|
||||
|
||||
|
||||
__rayapi signed char raydium_texture_size_is_correct (GLuint size);
|
||||
/**
|
||||
Returns true if ##size## is a correct texture size, depending of
|
||||
hardware capacities and "power of 2" constraint.
|
||||
**/
|
||||
|
||||
__rayapi GLuint raydium_texture_load_internal(char *filename, char *as, signed char faked, int faked_tx, int faked_ty, int faked_bpp, int or_live_id_fake);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi GLuint raydium_texture_load (char *filename);
|
||||
/**
|
||||
Loads "filename" texture into hardware memory. Function results
|
||||
texture index, but in most cases, you can identify later a texture
|
||||
by his name, without providing his index, so you can probably ignore
|
||||
this value.
|
||||
|
||||
0 is returned if texture loading have failed.
|
||||
**/
|
||||
|
||||
__rayapi GLuint raydium_texture_load_erase (char *filename, GLuint to_replace);
|
||||
/**
|
||||
Same as above, but ##to_replace## texture (index) is erased with ##filename##.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_texture_current_set (GLuint current);
|
||||
/**
|
||||
Switch active texture to "current" index. Mostly used for runtime object
|
||||
creation:
|
||||
"set current texture, add vertices, set another texture,
|
||||
add vertices, ... and save all to an objet"
|
||||
(see below for vertices management).
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_texture_current_set_name (char *name);
|
||||
/**
|
||||
Same as above, but using texture name. This function will load ##name##
|
||||
if not alread done.
|
||||
**/
|
||||
|
||||
__rayapi GLuint raydium_texture_find_by_name (char *name);
|
||||
/**
|
||||
Returns index for texture "name", and load it if not already done.
|
||||
**/
|
||||
|
||||
__rayapi GLuint raydium_texture_exists(char *name);
|
||||
/**
|
||||
Same as above, but don't load texture if ##name## isn't already loaded and
|
||||
then returns -1. Returns texture id otherwise.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_texture_filter_change (GLuint filter);
|
||||
/**
|
||||
|
||||
Change texture filter. The new filter will apply on all "next" textures,
|
||||
but will not change already loaded ones (this was the case in old Raydium
|
||||
releases), since it may generate strange bugs with dynamic (aka "faked")
|
||||
textures, and it was very slow.
|
||||
|
||||
%%(c)
|
||||
// will switch to bilinear filter for next textures
|
||||
raydium_texture_filter_change(RAYDIUM_TEXTURE_FILTER_BILINEAR)%%
|
||||
**/
|
||||
|
||||
#endif
|
146
raydium/headers/timecall.h
Normal file
146
raydium/headers/timecall.h
Normal file
@ -0,0 +1,146 @@
|
||||
#ifndef _TIMECALL_H
|
||||
#define _TIMECALL_H
|
||||
/*=
|
||||
Timecalls
|
||||
2700
|
||||
**/
|
||||
|
||||
// Concept
|
||||
/**
|
||||
As you may already know, in a real time application (as a game), you need
|
||||
to control in-game time evolution.
|
||||
For example, you cannot increment a car position by 1 at each frame since
|
||||
it will generate an irregular scrolling (a frame is never rendered within
|
||||
the same time as the previous or the next one).
|
||||
|
||||
Raydium supports timecalls, wich are a great solution for this problem.
|
||||
Usage is very simple: write a simple function, and ask Raydium to call it
|
||||
at the desired rate.
|
||||
**/
|
||||
|
||||
// Constraints
|
||||
/**
|
||||
There is an important risk with timecalls: infinite loops.
|
||||
If a callback is long, it may take more CPU time than he would, as in this
|
||||
very simple example:
|
||||
|
||||
foo() is a function, taking 200 ms for his own execution. If you ask for
|
||||
a 6 Hz execution, Raydium will execute foo() six times on the first frame,
|
||||
taking 1200 ms. On the next frame, Raydium will need to execute foo() 7
|
||||
times (the asked 6 times, and one more for the 200 ms lost during the last
|
||||
frame), taking 1400 ms, so 8 times will be needed for the next frame, then 9, ...
|
||||
|
||||
So you need to create callbacks as short as possible, since long callbacks
|
||||
may cause a game freeze on slower machines than yours. (1 FPS syndrom)
|
||||
**/
|
||||
|
||||
// Hardware devices and methods
|
||||
/**
|
||||
Raydium must use a very accurate system timer, and will try many methods:
|
||||
##/dev/rtc## , ##gettimeofday()## (Linux only) and
|
||||
##QueryPerformanceCounter## for win32.
|
||||
|
||||
##gettimeofday()## will use a CPU counter and is extremely accurate.
|
||||
It's far the best method. (0.001 ms accuracy is possible)
|
||||
|
||||
##/dev/rtc## is quite good, and Raydium will try to configure RTC at
|
||||
##RAYDIUM_TIMECALL_FREQ_PREFERED## rate (8192 Hz by default), but may
|
||||
require a "##/proc/sys/dev/rtc/max-user-freq##" modification:
|
||||
##echo 8192 > /proc/sys/dev/rtc/max-user-freq##
|
||||
|
||||
You may want to look at common.c for interesting defines about timecalls.
|
||||
**/
|
||||
|
||||
#ifdef WIN32
|
||||
#define __GETTIMEOFDAY_USEC 1000
|
||||
#else
|
||||
#define __GETTIMEOFDAY_USEC 1000000
|
||||
#endif
|
||||
__rayapi void raydium_timecall_raydium (GLfloat step);
|
||||
/**
|
||||
Internal Raydium callback.
|
||||
**/
|
||||
|
||||
#ifdef WIN32
|
||||
__rayapi float raydium_timecall_internal_w32_detect_modulo(int div);
|
||||
/**
|
||||
Internal, WIN32 only: Returns timer resolution for ##div## divisor.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_timecall_internal_w32_divmodulo_find(void);
|
||||
/**
|
||||
Internal, WIN32 only: Detects the best timer divisor for the current CPU.
|
||||
**/
|
||||
|
||||
#endif
|
||||
__rayapi unsigned long raydium_timecall_devrtc_clock (void);
|
||||
/**
|
||||
Internal, Linux only: Reads and return RTC clock.
|
||||
**/
|
||||
|
||||
__rayapi unsigned long raydium_timecall_clock (void);
|
||||
/**
|
||||
Returns current "time".
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_timecall_devrtc_rate_change (unsigned long new_rate);
|
||||
/**
|
||||
Internal, Linux only: Modifies RTC clock rate.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_timecall_devrtc_close (void);
|
||||
/**
|
||||
Internal, Linux only: Will close RTC clock.
|
||||
**/
|
||||
|
||||
__rayapi unsigned long raydium_timecall_devrtc_init (void);
|
||||
/**
|
||||
Internal, Linux only: Will open RTC clock.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_timecall_detect_frequency (void);
|
||||
/**
|
||||
Internal: This function will find the best timer available for current
|
||||
platform, and adjust properties to your hardware (rate, divisor, ...).
|
||||
**/
|
||||
|
||||
__rayapi void raydium_timecall_init (void);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
|
||||
__rayapi int raydium_timecall_add (void *funct, GLint hz);
|
||||
/**
|
||||
There is two sort of timecalls with Raydium:
|
||||
|
||||
1. Standard ones:
|
||||
%%(c)
|
||||
raydium_timecall_add(function,800);
|
||||
%%
|
||||
##void function(void)## will be called 800 times per second.
|
||||
|
||||
2. Elastic timed ones:
|
||||
%%(c)
|
||||
raydium_timecall_add(function,-80);
|
||||
%%
|
||||
##void function(float step)## will be called for each frame, with a
|
||||
"##step## factor" as argument. In the above example, a 160 Hz game will call
|
||||
function with step = 0.5, but step = 2.0 for a 40 Hz game.
|
||||
|
||||
A standard timecall will use ##void(void)## function and a positive ##hertz##
|
||||
argument, as an elasitc one will use ##void(float)## and negative ##hertz## argument.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_timecall_freq_change (int callback, GLint hz);
|
||||
/**
|
||||
This function changes the ##callback## frequency. See above for possibles
|
||||
values of ##hz## (negative and positive values).
|
||||
**/
|
||||
|
||||
__rayapi void raydium_timecall_callback (void);
|
||||
/**
|
||||
Internal use (frame fired callback).
|
||||
**/
|
||||
|
||||
#endif
|
137
raydium/headers/trigo.h
Normal file
137
raydium/headers/trigo.h
Normal file
@ -0,0 +1,137 @@
|
||||
#ifndef _TRIGO_H
|
||||
#define _TRIGO_H
|
||||
|
||||
/*=
|
||||
Maths
|
||||
200
|
||||
*/
|
||||
|
||||
// Little introduction to trigo.c
|
||||
/**
|
||||
This section is mostly designed for internal uses, but provides some
|
||||
usefull maths functions, mostly for trigonometrical uses.
|
||||
**/
|
||||
|
||||
__rayapi GLfloat raydium_trigo_cos (GLfloat i);
|
||||
/**
|
||||
Obvious (degrees)
|
||||
**/
|
||||
|
||||
__rayapi GLfloat raydium_trigo_sin (GLfloat i);
|
||||
/**
|
||||
Obvious (degrees)
|
||||
**/
|
||||
|
||||
__rayapi GLfloat raydium_trigo_cos_inv (GLfloat i);
|
||||
/**
|
||||
Obvious (degrees)
|
||||
**/
|
||||
|
||||
__rayapi GLfloat raydium_trigo_sin_inv (GLfloat i);
|
||||
/**
|
||||
Obvious (degrees)
|
||||
**/
|
||||
|
||||
#define raydium_trigo_abs(a) ( (a) < (0) ? (-a) : (a) )
|
||||
/**
|
||||
Obvious
|
||||
**/
|
||||
|
||||
#define raydium_trigo_min(a,b) ( (a) < (b) ? (a) : (b) )
|
||||
/**
|
||||
Obvious
|
||||
**/
|
||||
|
||||
#define raydium_trigo_max(a,b) ( (a) > (b) ? (a) : (b) )
|
||||
/**
|
||||
Obvious
|
||||
**/
|
||||
|
||||
#define raydium_trigo_isfloat(a) ( (!isnan(a) && !isinf(a)) ? 1 : 0)
|
||||
/**
|
||||
Test two cases : "Not a Number" and "Infinite"
|
||||
**/
|
||||
|
||||
#define raydium_trigo_round(a) ((int)((a)>0?((a)+0.5):((a)-0.5)))
|
||||
/**
|
||||
Will obviously "round" ##a## instead of the default C floor behaviour
|
||||
**/
|
||||
|
||||
__rayapi void raydium_trigo_rotate (GLfloat * p, GLfloat rx, GLfloat ry, GLfloat rz, GLfloat * res);
|
||||
/**
|
||||
Rotate p (GLfloat * 3) by (rx,ry,rx) angles (degrees).
|
||||
Result is stored in res (GLfloat * 3)
|
||||
**/
|
||||
|
||||
__rayapi void raydium_trigo_pos_to_matrix (GLfloat * pos, GLfloat * m);
|
||||
/**
|
||||
Generates a ODE style matrix (16 Glfloat) from pos (GLfloat * 3)
|
||||
**/
|
||||
|
||||
__rayapi void raydium_trigo_pos_get_modelview (GLfloat * res);
|
||||
/**
|
||||
Stores the current OpenGL MODELVIEW matrix in res (16 GLfloat)
|
||||
**/
|
||||
|
||||
__rayapi int raydium_trigo_pow2_next(int value);
|
||||
/**
|
||||
Returns next power of two of ##value##. Ugly.
|
||||
**/
|
||||
|
||||
//Matrix functions
|
||||
/**
|
||||
Here there are a few functions also designed for internal uses that aims
|
||||
only at matrices. Really the main objective of these functions is give support
|
||||
for the inverse function.
|
||||
The data type matrix4x4 is really an 16 double array.
|
||||
**/
|
||||
|
||||
|
||||
__rayapi double raydium_matrix_determinant(matrix4x4 matrix);
|
||||
/**
|
||||
Returns the ##determinant## of the given matrix.
|
||||
**/
|
||||
|
||||
__rayapi matrix4x4 raydium_matrix_adjoint(matrix4x4 matrix);
|
||||
/**
|
||||
Returns the ##adjoint matrix## of the given matrix.
|
||||
**/
|
||||
|
||||
__rayapi matrix4x4 raydium_matrix_multiply(matrix4x4 matrix1, matrix4x4 matrix2);
|
||||
/**
|
||||
Returns the resulting matrix of the multiplication of 2 matrices.
|
||||
Remeber that the multiplication of matrices doesn't have the conmutative
|
||||
property, so is not equal ##matrix1 X matrix2## than ##matrix2 x matrix1##.
|
||||
**/
|
||||
|
||||
__rayapi matrix4x4 raydium_matrix_inverse(matrix4x4 matrix);
|
||||
/**
|
||||
Returns the inverse matrix of a given matrix.
|
||||
**/
|
||||
|
||||
__rayapi double raydium_matrix_internal_determinant(matrix4x4 matrix, int dimension);
|
||||
/**
|
||||
internal, don't use.
|
||||
**/
|
||||
|
||||
__rayapi matrix4x4 raydium_matrix_internal_adjoint(matrix4x4 matrix, int dimension);
|
||||
/**
|
||||
internal, don't use.
|
||||
**/
|
||||
__rayapi matrix4x4 raydium_matrix_internal_multiply(matrix4x4 matrix_one, matrix4x4 matrix_two, int dimension);
|
||||
/**
|
||||
internal, don't use.
|
||||
**/
|
||||
__rayapi matrix4x4 raydium_matrix_internal_inverse(matrix4x4 adjoint_matrix,double det,int dimension);
|
||||
/**
|
||||
internal, don't use.
|
||||
**/
|
||||
|
||||
__rayapi int _raydium_trigo_MatrixInverse(const float *m,float *out);
|
||||
/*
|
||||
Our matrix_inverse seems broken.
|
||||
This code works, thanks to Alexander Zaprjagaev (frustum@public.tsu.ru)
|
||||
This code is not native
|
||||
*/
|
||||
|
||||
#endif
|
32
raydium/headers/vertex.h
Normal file
32
raydium/headers/vertex.h
Normal file
@ -0,0 +1,32 @@
|
||||
#ifndef _VERTEX_H
|
||||
#define _VERTEX_H
|
||||
|
||||
/*=
|
||||
vertices
|
||||
1700
|
||||
**/
|
||||
|
||||
// Introduction
|
||||
/**
|
||||
You can create objets at runtime, if needed, using the following functions.
|
||||
Each of theses functions adds only one vertex so, obviously, you need to
|
||||
call three time the same function to add one triangle.
|
||||
**/
|
||||
|
||||
|
||||
__rayapi void raydium_vertex_add (GLfloat x, GLfloat y, GLfloat z);
|
||||
/**
|
||||
Adds a vertex at (##x,y,z##).
|
||||
**/
|
||||
|
||||
__rayapi void raydium_vertex_uv_add (GLfloat x, GLfloat y, GLfloat z, GLfloat u, GLfloat v);
|
||||
/**
|
||||
Same as above, but providing texture mapping informations with ##u## and ##v##.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_vertex_uv_normals_add (GLfloat x, GLfloat y, GLfloat z, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat u, GLfloat v);
|
||||
/**
|
||||
Same as above, giving vertex's normal with (##nx,ny,nz##).
|
||||
**/
|
||||
|
||||
#endif
|
111
raydium/headers/video.h
Normal file
111
raydium/headers/video.h
Normal file
@ -0,0 +1,111 @@
|
||||
#ifndef _VIDEO_H
|
||||
#define _VIDEO_H
|
||||
|
||||
#include "../video.h"
|
||||
|
||||
/*=
|
||||
Video playback
|
||||
4100
|
||||
**/
|
||||
|
||||
// Introduction
|
||||
/**
|
||||
Raydium supports simple video playback, thru a special video codec (JPGS),
|
||||
useful for menus enhancements, "speaking" thumbnails, ...
|
||||
This codec only supports video, use sound API if needed.
|
||||
You will find an small utility, ##mk_jpgs## in Raydium source tree, didacted to
|
||||
movie creation.
|
||||
**/
|
||||
|
||||
// How to create a movie ?
|
||||
/**
|
||||
First, compile ##mk_jpgs##: example: ##gcc mk_jpgs.c -o mk_jpgs## or any other
|
||||
standard build command.
|
||||
Then, generate JPEG pictures (using a temporary directory, if possible):
|
||||
##mplayer movie.avi -vo jpeg:quality=50 -vf scale=256:256##, where you may
|
||||
change quality factor and output size. Use "hardware friendly" sizes (64,
|
||||
128,256,...) !
|
||||
You can now build JPGS file:
|
||||
##./mk_jpgs 25 256 256 video.jpgs## (fps, size x, size y, output file)
|
||||
**/
|
||||
|
||||
__rayapi void raydium_video_init(void);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_video_isvalid(int i);
|
||||
/**
|
||||
Internal use, but you can call this function if you want to verify if a
|
||||
video id is valid (in bounds and open).
|
||||
**/
|
||||
|
||||
__rayapi int raydium_video_find_free(void);
|
||||
/**
|
||||
Internal use.
|
||||
Finds a free video slot.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_video_find(char *name);
|
||||
/**
|
||||
Resolvs video ##name##, returning video id.
|
||||
Returns -1 when video is not found.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_video_jpeg_decompress(FILE *fp,unsigned char *to);
|
||||
/**
|
||||
Internal.
|
||||
**/
|
||||
|
||||
__rayapi int raydium_video_open(char *filename, char *as);
|
||||
/**
|
||||
This function will open and prepare video ##filename##, and will attach
|
||||
this video to a "live texture" (see Live API chapter, if needed).
|
||||
**/
|
||||
|
||||
__rayapi void raydium_video_callback_video(int id);
|
||||
/**
|
||||
Internal use.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_video_callback(void);
|
||||
/**
|
||||
Internal use. Frame callback.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_video_delete(int id);
|
||||
/**
|
||||
Will delete video ##id##. Warning: this function will not delete
|
||||
associated Live texture, so you may open a new video with the same
|
||||
texture name, but video size must be the same a the previous one.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_video_delete_name(char *name);
|
||||
/**
|
||||
Same as above, using video name.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_video_loop(int id, signed char loop);
|
||||
/**
|
||||
Sets loop attribute for the video ##id##. By defaults, video loops. Call
|
||||
this function with loop=0 to disable this behavior.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_video_loop_name(char *name, signed char loop);
|
||||
/**
|
||||
Same as above, using video name.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_video_isplaying(int id);
|
||||
/**
|
||||
Returns **1** is video ##id## is playing, **0** if this video is stopped,
|
||||
and **-1** if function failed.
|
||||
**/
|
||||
|
||||
__rayapi signed char raydium_video_isplaying_name(char *name);
|
||||
/**
|
||||
Same as above, using video name.
|
||||
**/
|
||||
|
||||
|
||||
#endif
|
20
raydium/headers/web.h
Normal file
20
raydium/headers/web.h
Normal file
@ -0,0 +1,20 @@
|
||||
#ifndef _WEB_H
|
||||
#define _WEB_H
|
||||
|
||||
#include "../web.h"
|
||||
|
||||
/*=
|
||||
HTTP Web Tools
|
||||
4200
|
||||
**/
|
||||
|
||||
__rayapi void raydium_web_answer(char *message, int fd);
|
||||
__rayapi void raydium_web_request(int fd);
|
||||
__rayapi void raydium_web_start(char *title);
|
||||
__rayapi void raydium_web_callback(void);
|
||||
__rayapi void raydium_web_init(void);
|
||||
__rayapi void raydium_web_extension_add(char *ext, char *mime, void *handler);
|
||||
__rayapi signed char raydium_web_client_get(char *filename);
|
||||
|
||||
|
||||
#endif
|
52
raydium/headers/window.h
Normal file
52
raydium/headers/window.h
Normal file
@ -0,0 +1,52 @@
|
||||
#ifndef _WINDOW_H
|
||||
#define _WINDOW_H
|
||||
/*=
|
||||
Window management
|
||||
600
|
||||
**/
|
||||
|
||||
// Introduction
|
||||
/**
|
||||
Some important functions, used for window creation and managment.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_window_close (void);
|
||||
/**
|
||||
This function is called by Raydium, do not use.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_window_create (GLuint tx, GLuint ty, signed char rendering, char *name);
|
||||
/**
|
||||
You must call this function once in your program, with following arguments:
|
||||
|
||||
1. ##tx##, ##ty##: window size, in pixel
|
||||
2. ##rendering##: window mode: ##RAYDIUM_RENDERING_*## (NONE, WINDOW, FULLSCREEN)
|
||||
3. ##name##: window's name
|
||||
|
||||
Raydium is using GLUT for window management, and GLUT fullscreen is not
|
||||
the same between various implementations, and can fail,
|
||||
so use a standard window size (640x480, 800x600, ...) for fullscreen mode.
|
||||
|
||||
Note that user can force fullscreen using ##--fullscreen## on the command line.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_window_resize_callback (GLsizei Width, GLsizei Height);
|
||||
/**
|
||||
This function is automaticaly called during a window resize,
|
||||
and resize OpenGL rendering space.
|
||||
|
||||
There is almost no reason to call this function by yourself.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_window_view_update (void);
|
||||
/**
|
||||
If you've changed 3D window size (clipping: raydium_projection_*),
|
||||
apply to hardware with this fonction.
|
||||
**/
|
||||
|
||||
__rayapi void raydium_window_view_perspective(GLfloat fov, GLfloat fnear, GLfloat ffar);
|
||||
/**
|
||||
All-in-one function: sets all "perspective" variables, and updates.
|
||||
**/
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user