Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

flame.cpp File Reference


Compounds

struct  _paramlist
struct  _texlist
class  coneseg
struct  config
class  cylinder
class  cylindercaps
class  empty
class  fbo_switch
class  flat
class  house
class  item
class  itemlist
class  model
class  pseudocylinder
class  scene
class  texlist
class  tshader

Defines

#define apptitle   "Flame"
#define VERSION   "0.1.0"
#define GLUT_MOUSE   10000
#define DIM3D   32
#define FBTYPE   GL_TEXTURE_2D
#define check_ext(x)   if (!x) fatalf(#x " required!");

Typedefs

typedef float float3 [3]
typedef unsigned int uint
typedef int tex3d [DIM3D][DIM3D][DIM3D]
typedef unsigned char ub4 [4]
typedef float f3 [3]
typedef float f2 [2]
typedef _paramlist paramlist
typedef tshadershader
typedef _texlist tex_list

Functions

uint gettickcount (void)
void generate3d (tex3d *tex3)
void normalize3 (float *vec)
void material_reset (texture *tex, shader vshader, shader fshader)
void material (texture *tex, shader vshader, shader fshader, ub4 color)
float size2 (float3 v)
void mouseCenter (void)
void mouseHandler (int x, int y)
void quit (void)
void kbd (int c, int is_down)
void mouseButtonHandler (int button, int is_down, int x, int y)
void skeyDownHandler (int c, int x, int y)
void skeyUpHandler (int c, int x, int y)
void keyDownHandler (unsigned char c, int x, int y)
void keyUpHandler (unsigned char c, int x, int y)
GLuint createScreenImage (int w, int h)
void initFBO (int w, int h)
void killFBO ()
void resizeCallback (int x, int y)
void set2D (void)
void tick (void)
void set3D ()
void fbo_use (int fbo, int clear_fbo)
int gl_ext (const char *what)
int init_fbo_func ()
void loadWorld ()
void fpsFrameEnd ()
void cross (float *r, float *v1, float *v2)
void drawHud (void)
void setLight ()
void drawWorld ()
void displayCallback (void)
void idleHandler (void)
void setCallbacks (void)
void windowInit (void)
void createWindow (int w, int h, int *argc, char **argv)
void loadConfig (const char *filename)
int main (int argc, char **argv)

Variables

int mousex
int mousey
int omousex = -1
int omousey = -1
int maxx
int maxy
int ms_last
float ms_curr
int wireframe
int help
double angle1
double angle2 = 0.5
float3 eye
float3 eye_d
float3 eye_u
float3 fogcolor = {0.25,0.25,0.8}
float sensitivity = 0.015
float kb_sensitivity = 20
float fov = 90
float radius = 40
float clipfront = 0.001
float clipback = 250
char * font_texture_name = strdup("font.tga")
char * scene_filename = strdup("scene.txt")
int use_fbo = 1
uint buffer2
tex3d t3data [2]
GLuint t3 [2]
ub4 white = {255,255,255,255}
ub4 black = {0,0,0,255}
GLuint fbo_tex
int gwin
float radiusdelta = 0
GLuint fbuf [2]
GLuint rbuf_depth [2]
GLuint fb_image [2]
GLenum fb_buf [2] = {GL_COLOR_ATTACHMENT0_EXT,GL_BACK_LEFT}
GLenum screen_buf = GL_BACK_LEFT
int last_tick = gettickcount()
texlisttl = new texlist()
char * ext
sceneworld
int last_ftick = gettickcount()
int last_frames = 0
int width = 800
int height = 600
int fullscreen = 0
config cfg []

Define Documentation

#define apptitle   "Flame"
 

#define check_ext      if (!x) fatalf(#x " required!");
 

#define DIM3D   32
 

#define FBTYPE   GL_TEXTURE_2D
 

#define GLUT_MOUSE   10000
 

#define VERSION   "0.1.0"
 


Typedef Documentation

typedef float f2[2]
 

typedef float f3[3]
 

typedef float float3[3]
 

typedef struct _paramlist paramlist
 

parameter list for shaders

typedef tshader* shader
 

pointer to shader class

typedef int tex3d[DIM3D][DIM3D][DIM3D]
 

typedef struct _texlist tex_list
 

texture list.

typedef unsigned char ub4[4]
 

typedef unsigned int uint
 


Function Documentation

GLuint createScreenImage int    w,
int    h
 

Create and return texture with same dimensions as screen

void createWindow int    w,
int    h,
int *    argc,
char **    argv
 

initialize OpenGL, create window ...

Parameters:
w window width
h window height
argc argc passed to GLUT
argv argv passed to GLUT

void cross float *    r,
float *    v1,
float *    v2
 

cross product of 2 vectors (3 component vectors)

Parameters:
r result of dot product (out)
v1 first vector (in)
v2 second vector (in)

void displayCallback void   
 

callback used when needed to update display

void drawHud void   
 

draw HUD (including fps information)

void drawWorld  
 

draw entire world (scene, lighting ... )

void fbo_use int    fbo,
int    clear_fbo
 

use framebuffer numbered 0 or 1. Set fbo_tex texture to the content of second framebuffer -1: copy FBO 0 to screen, show screen

void fpsFrameEnd  
 

conpute fps information at end of frame

void generate3d tex3d   tex3
 

generate 3d texture with noise

Parameters:
tex3 pointer to 3dtexture of dimensions DIM3D ^3

uint gettickcount void   
 

return number of miliseconds since start

int gl_ext const char *    what
 

true - extension is supported. false - not supported

Parameters:
what Extension to be queried for support

void idleHandler void   
 

idle callback (called when application is idle)

int init_fbo_func  
 

initialize functions needed for EXT_framebuffer_object. Return false if no FBO support in card/drivers

void initFBO int    w,
int    h
 

create two offscreen buffers

void kbd int    c,
int    is_down
 

keyboard press handler

void keyDownHandler unsigned char    c,
int    x,
int    y
 

key press handler

void keyUpHandler unsigned char    c,
int    x,
int    y
 

key release handler

void killFBO  
 

destroy FB objects

void loadConfig const char *    filename
 

load configuration from a file

void loadWorld  
 

load entire wirld, generate textures, etc ...

int main int    argc,
char **    argv
 

main function

void material texture   tex,
shader    vshader,
shader    fshader,
ub4    color
 

set material for OpenGL - color, texture, pixel and framgent shaders

void material_reset texture   tex,
shader    vshader,
shader    fshader
 

reset material - remove textures from texturing units in shaders

void mouseButtonHandler int    button,
int    is_down,
int    x,
int    y
 

mouse button press/release handler

void mouseCenter void   
 

center mouse - move mouse pointer in screen center

void mouseHandler int    x,
int    y
 

mouse move handler

void normalize3 float *    vec
 

normalize vector of 3 floats

Parameters:
vec vector to normalize

void quit void   
 

Quit routine

void resizeCallback int    x,
int    y
 

callback called when resizing window

void set2D void   
 

set 2d projection (0,0 - maxx,maxy), turn off Z-buffer and backface culling

void set3D  
 

set 3d projection

void setCallbacks void   
 

register all callbacks

void setLight  
 

set up lighting

float size2 float3    v
 

return size of the vector squared

void skeyDownHandler int    c,
int    x,
int    y
 

special key press handler

void skeyUpHandler int    c,
int    x,
int    y
 

special key release handler

void tick void   
 

timer function called each frame

void windowInit void   
 

set up small details based on platform


Variable Documentation

double angle1
 

double angle2 = 0.5
 

ub4 black = {0,0,0,255}
 

uint buffer2
 

config cfg[]
 

Initial value:

{
{"width",&width,'i',320,4096},
{"height",&height,'i',200,4096},
{"fullscreen",&fullscreen,'i',0,1},
{"font_x",&fontsizex,'f',8,64},
{"font_y",&fontsizey,'f',16,64},
{"sensitivity",&sensitivity,'f',0.001,1000},
{"kbsensitivity",&kb_sensitivity,'f',0.001,1000},
{"fov",&fov,'f',5,175},
{"font",&font_texture_name,'s',0,0},
{"scene",&scene_filename,'s',0,0},
{"usefbo",&use_fbo,'i',0,1},
}
configuration data definition

float clipback = 250
 

float clipfront = 0.001
 

char* ext
 

float3 eye
 

float3 eye_d
 

float3 eye_u
 

GLenum fb_buf[2] = {GL_COLOR_ATTACHMENT0_EXT,GL_BACK_LEFT}
 

GLuint fb_image[2]
 

2 textures holding offscreen framebuffer image

GLuint fbo_tex
 

texture pointing to the second framebuffer (other one than rendering target)

GLuint fbuf[2]
 

2 offscreen framebuffers

float3 fogcolor = {0.25,0.25,0.8}
 

char* font_texture_name = strdup("font.tga")
 

name of texture containing font

float fov = 90
 

int fullscreen = 0
 

attempt fullscreen?

int gwin
 

GLUT window handle

int height = 600
 

height of window

int help
 

float kb_sensitivity = 20
 

int last_frames = 0
 

int last_ftick = gettickcount()
 

int last_tick = gettickcount()
 

int maxx
 

int maxy
 

int mousex
 

int mousey
 

float ms_curr
 

int ms_last
 

int omousex = -1
 

int omousey = -1
 

float radius = 40
 

float radiusdelta = 0
 

GLuint rbuf_depth[2]
 

2 offscreen renderbuffers

char* scene_filename = strdup("scene.txt")
 

name of file containing scene definition

GLenum screen_buf = GL_BACK_LEFT
 

float sensitivity = 0.015
 

GLuint t3[2]
 

tex3d t3data[2]
 

texlist* tl = new texlist()
 

One texture list for entire program

int use_fbo = 1
 

if true, framebuffer extension will be used

ub4 white = {255,255,255,255}
 

int width = 800
 

width of window

int wireframe
 

scene* world