Commit code circa 2006

This commit is contained in:
2026-05-18 12:33:52 -04:00
commit 8334c53fc2
6 changed files with 690 additions and 0 deletions

94
draw.h Executable file
View File

@@ -0,0 +1,94 @@
/* anything related to drawing is in here
* including texture loading and setting */
#ifndef __DRAW_H__
#define __DRAW_H__
#include "common.h"
extern PEmitter theEmitter[2];
int drawGLScene( GLvoid )
{
/* These are to calculate our fps */
static GLint T0 = 0;
GLint t = 0;
static GLint Frames = 0;
/* Clear The Screen And The Depth Buffer */
glPointSize(3.0f);
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glMatrixMode(GL_MODELVIEW);
glLoadIdentity( );
glTranslatef(0.0f, 1.0f, -20.0f);
DrawEmitter(&theEmitter[0]);
DrawEmitter(&theEmitter[1]);
/* Draw it to the screen */
SDL_GL_SwapBuffers( );
Frames++;
t = SDL_GetTicks();
if (t - T0 >= 1000) {
GLfloat seconds = (t - T0) / 1000.0;
GLfloat fps = Frames / seconds;
printf("%d frames in %g seconds = %g FPS (new time %g)\n", Frames, seconds, fps, (float)time(NULL));
T0 = t;
Frames = 0;
}
UpdateEmitter(&theEmitter[0], t - T0);
UpdateEmitter(&theEmitter[1], t - T0);
T0 = t;
return( TRUE );
}
/* function to reset our viewport after a window resize */
int resizeWindow( int width, int height )
{
GLfloat ratio;
/* Protect against a divide by zero */
if ( height == 0 ) height = 1;
ratio = ( GLfloat )width / ( GLfloat )height;
/* set the viewport, viewing volume, perspective, etc etc */
glViewport( 0, 0, ( GLint )width, ( GLint )height );
glMatrixMode( GL_PROJECTION );
glLoadIdentity( );
gluPerspective( 45.0f, ratio, 0.1f, 100.0f );
glMatrixMode( GL_MODELVIEW );
/* Reset The Modelview matrix */
glLoadIdentity( );
return( TRUE );
}
/* general OpenGL initialization function */
int initGL( GLvoid )
{
/* Setup shading, clearing, depth testing, and rendering hints */
glShadeModel( GL_SMOOTH );
glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
glClearDepth( 1.0f );
glEnable( GL_DEPTH_TEST );
glDepthFunc( GL_LEQUAL );
glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST );
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
return( TRUE );
}
#endif // __DRAW_H__