#pragma once #include #include #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. typedef struct { int w, h; // Window dimensions. int depth; // Depth in bpp. int fullscreen; // 1 = fullscreen, 0 = windowed. int r, g, b, a; // Framebuffer values in bits. int doublebuf; // Double buffer. } gl_info; extern gl_info gl_screen; // Local structure set with gl_init etc. // Colors. typedef struct { double r, g, b, a; } glColor; #define COLOR(x) glColor4d((x).r, (x).g, (x).b, (x).a) // Default colors. extern glColor cGrey; // Spritesheet info. typedef struct { 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. } gl_texture; // Font info. typedef struct { int h; // Height. int* w; GLuint* textures; GLuint list_base; } gl_font; extern gl_font gl_defFont; // Default font. // gl_font loading/freeing. // If font is NULL it uses the internal default font, same with gl_print void gl_fontInit(gl_font* font, const char* fname, const unsigned int h); void gl_freeFont(gl_font* font); // gl_texute loading/freeing. gl_texture* gl_loadImage(SDL_Surface* surface); // Frees the surface. gl_texture* gl_newImage(const char* path); gl_texture* gl_newSprite(const char* path, const int sx, const int sy); void gl_freeTexture(gl_texture* texture); // Rendering. void gl_blitSprite(const gl_texture* sprite, const Vec2* pos, const int sx, const int sy, const glColor* c); void gl_blitStatic(const gl_texture* texture, const Vec2* pos, const glColor* c); void gl_bindCamera(const Vec2* pos); void gl_print(const gl_font* ft_font, const Vec2* pos, const glColor* c, const char* fmt, ...); int gl_printWidth(const gl_font* ft_font, const char* fmt, ...); // Initialize/cleanup. int gl_init(void); void gl_exit(void); // Misc. int gl_isTrans(const gl_texture* t, const int x, const int y); void gl_getSpriteFromDir(int* x, int* y, const gl_texture* t, const double dir);