#pragma once #include #include #include #include "colour.h" #include "physics.h" // Recommended for compatibility bullshit. #if SDL_BYTEORDER == SDL_BIG_ENDIAN # define RMASK 0xff000000 # define GMASK 0x00ff0000 # define BMASK 0x0000ff00 # define AMASK 0x000000ff #else # define RMASK 0x000000ff # define GMASK 0x0000ff00 # define BMASK 0x00ff0000 # define AMASK 0xff000000 #endif #define RGBMASK RMASK,GMASK,BMASK,AMASK // Info about opengl screen. #define OPENGL_FULLSCREEN (1<<0) #define OPENGL_DOUBLEBUF (1<<1) #define OPENGL_AA_POINT (1<<2) #define OPENGL_AA_LINE (1<<3) #define OPENGL_AA_POLYGON (1<<4) #define OPENGL_FRAG_SHADER (1<<5) #define OPENGL_VERT_SHADER (1<<6) #define gl_has(f) (gl_screen.flags & (f)) // Check for the flag. typedef struct glInfo_ { int w, h; // Window dimensions. int depth; // Depth in bpp. int r, g, b, a; // Framebuffer values in bits. int flags; // Store different properties. int tex_max; // Max texture size. } glInfo; extern glInfo gl_screen; // Local structure set with gl_init etc. #define SCREEN_W gl_screen.w #define SCREEN_H gl_screen.h #define COLOUR(x) glColor4d((x).r, (x).g, (x).b, (x).a) #define ACOLOUR(x,a) glColor4d((x).r, (x).g, (x).b, a) // Spritesheet info. typedef struct glTexture_ { double w, h; // Real size of the image (excluding POT buffer. double rw, rh; // Size of POT surface. double sx, sy; // Number of sprites on x and y axes. double sw, sh; // Size of each sprite. GLuint texture; // The opengl texture itself. uint8_t* trans; // Maps the transparency. } glTexture; // gl_texute loading/freeing. glTexture* gl_loadImage(SDL_Surface* surface); // Frees the surface. glTexture* gl_newImage(const char* path); glTexture* gl_newSprite(const char* path, const int sx, const int sy); void gl_freeTexture(glTexture* texture); // Rendering. // Blits a sprite. void gl_blitSprite(const glTexture* sprite, const double bx, const double by, const int sx, const int sy, const glColour* c); // Blit the entire image. void gl_blitStatic(const glTexture* texture, const double bx, const double by, const glColour* c); // Bind the camera to a vector. void gl_bindCamera(const Vec2* pos); // Circle drawing. void gl_drawCircle(const double x, const double y, const double r); void gl_drawCircleInRect(const double x, const double y, const double r, const double rc, const double ry, const double rw, const double rh); // Initialize/cleanup. int gl_init(void); void gl_exit(void); // Misc. int gl_isTrans(const glTexture* t, const int x, const int y); void gl_getSpriteFromDir(int* x, int* y, const glTexture* t, const double dir); void gl_screenshot(const char* filename); //#if DEBUG == 1 void gl_checkErr(void); //#else //#define gl_checkErr() //#endif