WID comments
[Lilanci.git] / gr.h
blob469566025322fea52b8ac874acda4640a52d2b85
1 #pragma once
2 #include <SDL/SDL.h>
3 #include <SDL_opengl.h>
5 #define SCREEN_WIDTH 20.0
6 #define SCREEN_HEIGHT 15.0
9 int RegenerateSprites();
10 //called internally when there is a need for sprites after InvalidateSprites or externally
11 //returns 0 on success
13 void InvalidateSprites();
14 //call it if you want to queue reload of sprites, for example after screen resize
16 int DrawSprites();
17 //draw queued spites
18 //returns 0 on success
20 int ClrScr();
21 //Clear Screen -- may does nothing, check code
22 //returns 0 on success
24 int GrInit();
25 //please call this procedure before anything else from this module
26 //returns 0 on success
28 int GrKill();
29 //please call this when you wanna to kill graphics
30 //also on exit, because not all platforms frees all resources when process ends
34 typedef struct{
35 double width; //width of a sprite (in game units)
36 double height; //height of a sprite (in game units)
37 double twidth; //height of the texture in pixels
38 double theight; //width of the texture in pixels
39 int z; //z
40 char *fname; //file name of original SVG
41 int rotation; //rotation ( *PI/2.0)
42 unsigned int SID; //surface ID
43 }Sprite;
45 // Because of lazy implementations of OpenGL on some hw, we are using textures with dimensions of power of two
46 // if you run out of texture memory, try to lower resolution or config.texture_lod
47 Sprite* LoadSpriteSVG(char *fname, double width, double height);
48 //returns 0 when failed
50 void DestroySprite(Sprite *sprite);
51 Sprite* CopySprite(Sprite *sprite);
53 void RotateClockwise(Sprite *sprite); //rotate clockwise by PI/2.0
54 //currently unimplemented
56 void QueueDrawSprite(Sprite *sprite, double x, double y, int z);
57 //queue target sprite to be drawn at [x,y] at level z 0-deepest
59 void QueueDrawSpriteColorize(Sprite *sprite, double x, double y, int z, SDL_Color c);
60 //queue target sprite to be drawn at [x,y] at level z 0-deepest
61 void QueueDrawSpriteColorizeStretch(Sprite *sprite, double x, double y, double xx, double yy, int z, SDL_Color c);
62 //queue target sprite to be drawn at [x,y] at level z 0-deepest
65 int G2SX(double x);
66 int G2SY(double y);
67 double S2GX(int x);
68 double S2GY(int y);