-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathframebuffer.h
49 lines (41 loc) · 1.7 KB
/
framebuffer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#ifndef FRAMEBUFFER_H
#define FRAMEBUFFER_H
#include <SDL.h>
#include <SDL2_gfxPrimitives.h>
#include <SDL2_framerate.h>
#include <SDL_image.h>
#include <SDL2_rotozoom.h>
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
#define FONT_WIDTH 16
#define FONT_HEIGHT 16
#define FONT_KERNING 10
typedef struct frameBuffer {
int width;
int height;
SDL_Window *screen;
SDL_Renderer *renderer;
SDL_Texture *texture;
FPSmanager fps_mgr;
} frameBuffer;
/* Frame buffer */
frameBuffer *createFrameBuffer(int width, int height, int fullscreen);
void presentFrameBuffer(frameBuffer *fb);
/* Drawing primitives */
void setPixelWithAlpha(frameBuffer *fb, int x, int y, int r, int g, int b, int alpha);
void fillBackground(frameBuffer *fb, int r, int g, int b);
void drawHline(frameBuffer *fb, int x1, int x2, int y, int r, int g, int b, int alpha);
void drawEllipse(frameBuffer *fb, int xc, int yc, int radx, int rady, int r, int g, int b, int alpha);
void drawBox(frameBuffer *fb, int x1, int y1, int x2, int y2, int r, int g, int b, int alpha);
void drawTriangle(frameBuffer *fb, int x1, int y1, int x2, int y2, int x3, int y3, int r, int g, int b, int alpha);
void drawLine(frameBuffer *fb, int x1, int y1, int x2, int y2, int r, int g, int b, int alpha);
/* Bitmap font */
void bfLoadFont(char **c);
void bfWriteChar(frameBuffer *fb, int xp, int yp, int c, int r, int g, int b, int alpha);
void bfWriteString(frameBuffer *fb, int xp, int yp, const char *s, int len, int r, int g, int b, int alpha);
/* Sprites */
void spriteBlit(frameBuffer *fb, void *sprite, int x, int y, int angle, int aa);
void *spriteLoad(lua_State *L, const char *filename);
void initSpriteEngine(lua_State *L);
#endif /* FRAMEBUFFER_H */