[Add] Documented opengl file, explained coordinate system in use.
This commit is contained in:
parent
090d9535c4
commit
6758fd9393
27
src/opengl.c
27
src/opengl.c
@ -1,3 +1,30 @@
|
|||||||
|
/**
|
||||||
|
* @file opengl.c
|
||||||
|
*
|
||||||
|
* @brief This file handles most of the more generic opengl functions.
|
||||||
|
*
|
||||||
|
* The main way to work with opengl in lephisto is to create glTextures and then
|
||||||
|
* use the blit functions to draw them on the screen. This system will handle
|
||||||
|
* relative and absolute positions.
|
||||||
|
*
|
||||||
|
* There are two coordinate systems: relative and absolute.
|
||||||
|
*
|
||||||
|
* Relative:
|
||||||
|
* -- Everything is drawn relative to the player, if it doesn't fit on the
|
||||||
|
* screen it is clipped.
|
||||||
|
* -- Origin (0., 0.) would be ontop of the player.
|
||||||
|
*
|
||||||
|
* Absolute:
|
||||||
|
* -- Everything is drawn in "screen coordinates".
|
||||||
|
* -- (0., 0.) is bottom left.
|
||||||
|
* -- (SCREEN_W, SCREEN_H) is top right.
|
||||||
|
*
|
||||||
|
* Note that the game actually uses a third type of coordinate for when using
|
||||||
|
* raw commands. In this third type, the (0., 0.) is actually in middle of the
|
||||||
|
* screen. (-SCREEN_W/2., -SCREEN_H/2.) is bottom left and
|
||||||
|
* (-SCREEN_W/2., -SCREEN_H/2.) is top right.
|
||||||
|
*/
|
||||||
|
|
||||||
#include <SDL/SDL.h>
|
#include <SDL/SDL.h>
|
||||||
#include <SDL/SDL_image.h>
|
#include <SDL/SDL_image.h>
|
||||||
#include "SDL_version.h"
|
#include "SDL_version.h"
|
||||||
|
20
src/opengl.h
20
src/opengl.h
@ -7,15 +7,15 @@
|
|||||||
|
|
||||||
/* Recommended for compatibility bullshit. */
|
/* Recommended for compatibility bullshit. */
|
||||||
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
||||||
# define RMASK 0xff000000
|
# define RMASK 0xff000000 /**< Red bit mask. */
|
||||||
# define GMASK 0x00ff0000
|
# define GMASK 0x00ff0000 /**< Green bit mask. */
|
||||||
# define BMASK 0x0000ff00
|
# define BMASK 0x0000ff00 /**< Blue bit mask. */
|
||||||
# define AMASK 0x000000ff
|
# define AMASK 0x000000ff /**< Alpha bit mask. */
|
||||||
#else
|
#else
|
||||||
# define RMASK 0x000000ff
|
# define RMASK 0x000000ff /**< Red bit mask. */
|
||||||
# define GMASK 0x0000ff00
|
# define GMASK 0x0000ff00 /**< Green bit mask. */
|
||||||
# define BMASK 0x00ff0000
|
# define BMASK 0x00ff0000 /**< Blue bit mask. */
|
||||||
# define AMASK 0xff000000
|
# define AMASK 0xff000000 /**< Alpha bit mask. */
|
||||||
#endif
|
#endif
|
||||||
#define RGBAMASK RMASK,GMASK,BMASK,AMASK
|
#define RGBAMASK RMASK,GMASK,BMASK,AMASK
|
||||||
|
|
||||||
@ -33,8 +33,6 @@
|
|||||||
#define gl_has(f) (gl_screen.flags & (f)) /**< Check for the flag. */
|
#define gl_has(f) (gl_screen.flags & (f)) /**< Check for the flag. */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @struct glInfo
|
|
||||||
*
|
|
||||||
* @brief Store data about the current opengl environment.
|
* @brief Store data about the current opengl environment.
|
||||||
*/
|
*/
|
||||||
typedef struct glInfo_ {
|
typedef struct glInfo_ {
|
||||||
@ -138,7 +136,7 @@ void gl_getSpriteFromDir(int* x, int* y, const glTexture* t, const double dir);
|
|||||||
void gl_screenshot(const char* filename);
|
void gl_screenshot(const char* filename);
|
||||||
int SDL_savePNG(SDL_Surface* surface, const char* file);
|
int SDL_savePNG(SDL_Surface* surface, const char* file);
|
||||||
/*#if DEBUG == 1 */
|
/*#if DEBUG == 1 */
|
||||||
void gl_checkErr(void);
|
void gl_checkErr(void); /**< Hack to ignore errors when debugging. */
|
||||||
/*#else */
|
/*#else */
|
||||||
/*#define gl_checkErr() */
|
/*#define gl_checkErr() */
|
||||||
/*#endif */
|
/*#endif */
|
||||||
|
Loading…
Reference in New Issue
Block a user