125 lines
1.7 KiB
C
125 lines
1.7 KiB
C
|
|
#ifndef _opengl
|
||
|
|
|
||
|
|
#define _opengl
|
||
|
|
|
||
|
|
|
||
|
|
// Macros
|
||
|
|
|
||
|
|
#define HEIGHT 480
|
||
|
|
|
||
|
|
|
||
|
|
#define WIDTH 640
|
||
|
|
|
||
|
|
|
||
|
|
#define GL_GLEXT_PROTOTYPES
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
#include "stdlib.h"
|
||
|
|
|
||
|
|
extern char * __ClassNames[];
|
||
|
|
|
||
|
|
|
||
|
|
// Includes
|
||
|
|
|
||
|
|
#include <time.h>
|
||
|
|
|
||
|
|
#include <GL/glx.h>
|
||
|
|
|
||
|
|
#include <GL/gl.h>
|
||
|
|
|
||
|
|
#include <GL/glext.h>
|
||
|
|
|
||
|
|
#include <X11/keysym.h>
|
||
|
|
|
||
|
|
#include <X11/Xlib.h>
|
||
|
|
|
||
|
|
#include <stdlib.h>
|
||
|
|
|
||
|
|
#include <stdio.h>
|
||
|
|
|
||
|
|
#include "unsignedIntegerArray.h"
|
||
|
|
|
||
|
|
#include "floatArray.h"
|
||
|
|
|
||
|
|
#include "shader.h"
|
||
|
|
|
||
|
|
#include "mesh.h"
|
||
|
|
|
||
|
|
|
||
|
|
typedef struct opengl{
|
||
|
|
|
||
|
|
unsigned short __classIndex;
|
||
|
|
|
||
|
|
Display * mainDisplay;
|
||
|
|
|
||
|
|
Window mainWindow;
|
||
|
|
|
||
|
|
int MainScreen;
|
||
|
|
|
||
|
|
Window RootWindow;
|
||
|
|
|
||
|
|
int lastTime;
|
||
|
|
|
||
|
|
clock_t deltaTime;
|
||
|
|
|
||
|
|
struct timespec startTime;
|
||
|
|
|
||
|
|
int frameCount;
|
||
|
|
|
||
|
|
GLuint vertexbuffer;
|
||
|
|
|
||
|
|
GLuint indexBuffer;
|
||
|
|
|
||
|
|
struct shader * currentShader;
|
||
|
|
|
||
|
|
struct mesh * quads;
|
||
|
|
|
||
|
|
unsigned char image[HEIGHT][WIDTH];
|
||
|
|
|
||
|
|
|
||
|
|
} opengl;
|
||
|
|
|
||
|
|
void opengl_initialize( opengl * this );
|
||
|
|
|
||
|
|
void opengl_showVersion( opengl * this );
|
||
|
|
|
||
|
|
void opengl_setupTime( opengl * this );
|
||
|
|
|
||
|
|
void opengl_setupWindow( opengl * this );
|
||
|
|
|
||
|
|
void opengl_setupRenderLoop( opengl * this );
|
||
|
|
|
||
|
|
void opengl_createShaders( opengl * this );
|
||
|
|
|
||
|
|
void opengl_createQuad( opengl * this );
|
||
|
|
|
||
|
|
double opengl_clockToMilliseconds( opengl * this, clock_t ticks );
|
||
|
|
|
||
|
|
void opengl_render( opengl * this );
|
||
|
|
|
||
|
|
void opengl_displayFPS( opengl * this );
|
||
|
|
|
||
|
|
void opengl_vertex2f( opengl * this, float x, float y );
|
||
|
|
|
||
|
|
void opengl_color3f( opengl * this, float r, float g, float b );
|
||
|
|
|
||
|
|
void opengl_clear( opengl * this, GLbitfield mask );
|
||
|
|
|
||
|
|
void opengl_clearColor( opengl * this, float r, float g, float b, float a );
|
||
|
|
|
||
|
|
void opengl_begin( opengl * this, GLenum mode );
|
||
|
|
|
||
|
|
void opengl_end( opengl * this );
|
||
|
|
|
||
|
|
void opengl_flush( opengl * this );
|
||
|
|
|
||
|
|
static int DoubleBufferAttributes[] ;
|
||
|
|
|
||
|
|
opengl opengl_new( );
|
||
|
|
|
||
|
|
opengl * opengl_newPointer( );
|
||
|
|
|
||
|
|
#endif
|