Header file to include when using the LCGE engine. More...
Go to the source code of this file.
Data Structures | |
struct | LCGE_cursor_pos |
Typedefs | |
typedef struct LCGE_rect | LCGE_rect |
A 2D rectangle. More... | |
typedef struct LCGE_image | LCGE_image |
A 2D image. More... | |
typedef struct LCGE_clock | LCGE_clock |
Basic FPS clock. More... | |
typedef struct LCGE_cursor_pos | LCGE_cursor_pos |
typedef struct LCGE_font | LCGE_font |
A true type font. More... | |
typedef struct LCGE_text | LCGE_text |
2D text. More... | |
typedef struct LCGE_line | LCGE_line |
Functions | |
LCGE_IMPORT int | lcge_init (const char *lcge_res_dir) |
Initializes LCGE. More... | |
LCGE_IMPORT int | lcge_create_context (unsigned int width, unsigned int height, const char *title, int resizable) |
Create a window and get back a handle. More... | |
LCGE_IMPORT int | lcge_window_is_open () |
Returns whether or not the window is still open. More... | |
LCGE_IMPORT void | lcge_exit () |
Exits lcge. More... | |
LCGE_IMPORT void | lcge_window_clear () |
Clears the window. More... | |
LCGE_IMPORT void | lcge_window_update () |
Updates the window and polls for events. More... | |
LCGE_IMPORT LCGE_rect * | lcge_rect_load (float x, float y, float width, float height) |
Loads rectangle data and returns a handle. More... | |
LCGE_IMPORT void | lcge_rect_delete (LCGE_rect *rect) |
Deletes a rectangle. More... | |
LCGE_IMPORT void | lcge_rect_draw (LCGE_rect *rect, float r, float g, float b) |
Draw a loaded rectangle to the screen. More... | |
LCGE_IMPORT void | lcge_rect_set (LCGE_rect *rect, float x, float y, float width, float height) |
Updates rectangle data for a loaded rectangle. More... | |
LCGE_IMPORT void | lcge_rect_rotate (LCGE_rect *rect, float angle) |
Rotates a loaded rectangle. More... | |
LCGE_IMPORT float | lcge_rect_get_x (LCGE_rect *rect) |
Gets the rectangle x value. More... | |
LCGE_IMPORT float | lcge_rect_get_y (LCGE_rect *rect) |
Gets the rectangle y value. More... | |
LCGE_IMPORT float | lcge_rect_get_width (LCGE_rect *rect) |
Gets the rectangle width. More... | |
LCGE_IMPORT float | lcge_rect_get_height (LCGE_rect *rect) |
Gets the rectangle height. More... | |
LCGE_IMPORT LCGE_image * | lcge_image_load (const char *filepath, float x, float y, float width, float height) |
Loads an image from a file. More... | |
LCGE_IMPORT void | lcge_image_delete (LCGE_image *image) |
Deletes an image. More... | |
LCGE_IMPORT void | lcge_image_rotate (LCGE_image *image, float angle) |
Rotates an image. More... | |
LCGE_IMPORT void | lcge_image_reflect (LCGE_image *image) |
Reflects an image horizontally 180 deg. More... | |
LCGE_IMPORT void | lcge_image_set (LCGE_image *image, float x, float y, float width, float height) |
Sets new data for a loaded image. More... | |
LCGE_IMPORT void | lcge_image_draw (LCGE_image *image) |
Draws a loaded image to the screen. More... | |
LCGE_IMPORT float | lcge_image_get_x (LCGE_image *image) |
Gets image x. More... | |
LCGE_IMPORT float | lcge_image_get_y (LCGE_image *image) |
Gets image y. More... | |
LCGE_IMPORT float | lcge_image_get_width (LCGE_image *image) |
Gets image width. More... | |
LCGE_IMPORT float | lcge_image_get_height (LCGE_image *image) |
Gets image height. More... | |
LCGE_IMPORT LCGE_clock * | lcge_clock_create (unsigned int fps) |
Creates a clock. More... | |
LCGE_IMPORT void | lcge_clock_delete (LCGE_clock *clock) |
Deletes a clock. More... | |
LCGE_IMPORT void | lcge_clock_tick (LCGE_clock *clock) |
tickst the clock. More... | |
LCGE_IMPORT int | lcge_get_key (int key) |
Gets the input status of a key. More... | |
LCGE_IMPORT int | lcge_get_mouse_button (int button) |
Gets input status of a mouse button. More... | |
LCGE_IMPORT LCGE_cursor_pos | lcge_get_cursor_position () |
LCGE_IMPORT LCGE_font * | lcge_font_load (const char *filepath, float height) |
Loads a font. More... | |
LCGE_IMPORT void | lcge_font_delete (LCGE_font *font) |
Deletes a font. More... | |
LCGE_IMPORT LCGE_text * | lcge_text_load (const char *text, float x, float y, LCGE_font *font) |
Loads a 2D text struct. More... | |
LCGE_IMPORT void | lcge_text_delete (LCGE_text *text) |
Deletes a text struct. More... | |
LCGE_IMPORT void | lcge_text_draw (LCGE_text *text, float r, float g, float b) |
Draws 2D text. More... | |
LCGE_IMPORT void | lcge_text_set (LCGE_text *text, const char *n_text, float x, float y) |
Set new data for text. More... | |
LCGE_IMPORT float | lcge_text_get_x (LCGE_text *text) |
Gets x value of text. More... | |
LCGE_IMPORT float | lcge_text_get_y (LCGE_text *text) |
Gets y value of text. More... | |
LCGE_IMPORT float | lcge_text_get_width (LCGE_text *text) |
Gets the width of the text. More... | |
LCGE_IMPORT float | lcge_text_get_height (LCGE_text *text) |
Gets the height of the text. More... | |
LCGE_IMPORT LCGE_line * | lcge_line_load (float x0, float y0, float x1, float y1) |
LCGE_IMPORT void | lcge_line_delete (LCGE_line *line) |
LCGE_IMPORT void | lcge_line_draw (LCGE_line *line, float r, float g, float b) |
LCGE_IMPORT void | lcge_line_set (LCGE_line *line, float x0, float y0, float x1, float y1) |
Header file to include when using the LCGE engine.
LCGE is a 2D game engine written in C that uses the OpenGL graphics API.
#define LCGE_IMPORT |
#define LCGE_WINDOW_OPEN 1 |
#define LCGE_WINDOW_CLOSED 0 |
#define LCGE_INIT_ERR -1 |
#define LCGE_INIT_OK 0 |
#define LCGE_RESIZEABLE 1 |
#define LCGE_NON_RESIZEABLE 0 |
#define LCGE_CONTEXT_ERR -1 |
#define LCGE_CONTEXT_OK 1 |
#define LCGE_KEY_SPACE 32 |
#define LCGE_KEY_APOSTROPHE 39 /* ' */ |
#define LCGE_KEY_COMMA 44 /* , */ |
#define LCGE_KEY_MINUS 45 /* - */ |
#define LCGE_KEY_PERIOD 46 /* . */ |
#define LCGE_KEY_SLASH 47 /* / */ |
#define LCGE_KEY_0 48 |
#define LCGE_KEY_1 49 |
#define LCGE_KEY_2 50 |
#define LCGE_KEY_3 51 |
#define LCGE_KEY_4 52 |
#define LCGE_KEY_5 53 |
#define LCGE_KEY_6 54 |
#define LCGE_KEY_7 55 |
#define LCGE_KEY_8 56 |
#define LCGE_KEY_9 57 |
#define LCGE_KEY_SEMICOLON 59 /* ; */ |
#define LCGE_KEY_EQUAL 61 /* = */ |
#define LCGE_KEY_A 65 |
#define LCGE_KEY_B 66 |
#define LCGE_KEY_C 67 |
#define LCGE_KEY_D 68 |
#define LCGE_KEY_E 69 |
#define LCGE_KEY_F 70 |
#define LCGE_KEY_G 71 |
#define LCGE_KEY_H 72 |
#define LCGE_KEY_I 73 |
#define LCGE_KEY_J 74 |
#define LCGE_KEY_K 75 |
#define LCGE_KEY_L 76 |
#define LCGE_KEY_M 77 |
#define LCGE_KEY_N 78 |
#define LCGE_KEY_O 79 |
#define LCGE_KEY_P 80 |
#define LCGE_KEY_Q 81 |
#define LCGE_KEY_R 82 |
#define LCGE_KEY_S 83 |
#define LCGE_KEY_T 84 |
#define LCGE_KEY_U 85 |
#define LCGE_KEY_V 86 |
#define LCGE_KEY_W 87 |
#define LCGE_KEY_X 88 |
#define LCGE_KEY_Y 89 |
#define LCGE_KEY_Z 90 |
#define LCGE_KEY_LEFT_BRACKET 91 /* [ */ |
#define LCGE_KEY_BACKSLASH 92 /* \ */ |
#define LCGE_KEY_RIGHT_BRACKET 93 /* ] */ |
#define LCGE_KEY_GRAVE_ACCENT 96 /* ` */ |
#define LCGE_KEY_WORLD_1 161 /* non-US #1 */ |
#define LCGE_KEY_WORLD_2 162 /* non-US #2 */ |
#define LCGE_KEY_ESCAPE 256 |
#define LCGE_KEY_ENTER 257 |
#define LCGE_KEY_TAB 258 |
#define LCGE_KEY_BACKSPACE 259 |
#define LCGE_KEY_INSERT 260 |
#define LCGE_KEY_DELETE 261 |
#define LCGE_KEY_RIGHT 262 |
#define LCGE_KEY_LEFT 263 |
#define LCGE_KEY_DOWN 264 |
#define LCGE_KEY_UP 265 |
#define LCGE_KEY_PAGE_UP 266 |
#define LCGE_KEY_PAGE_DOWN 267 |
#define LCGE_KEY_HOME 268 |
#define LCGE_KEY_END 269 |
#define LCGE_KEY_CAPS_LOCK 280 |
#define LCGE_KEY_SCROLL_LOCK 281 |
#define LCGE_KEY_NUM_LOCK 282 |
#define LCGE_KEY_PRINT_SCREEN 283 |
#define LCGE_KEY_PAUSE 284 |
#define LCGE_KEY_F1 290 |
#define LCGE_KEY_F2 291 |
#define LCGE_KEY_F3 292 |
#define LCGE_KEY_F4 293 |
#define LCGE_KEY_F5 294 |
#define LCGE_KEY_F6 295 |
#define LCGE_KEY_F7 296 |
#define LCGE_KEY_F8 297 |
#define LCGE_KEY_F9 298 |
#define LCGE_KEY_F10 299 |
#define LCGE_KEY_F11 300 |
#define LCGE_KEY_F12 301 |
#define LCGE_KEY_F13 302 |
#define LCGE_KEY_F14 303 |
#define LCGE_KEY_F15 304 |
#define LCGE_KEY_F16 305 |
#define LCGE_KEY_F17 306 |
#define LCGE_KEY_F18 307 |
#define LCGE_KEY_F19 308 |
#define LCGE_KEY_F20 309 |
#define LCGE_KEY_F21 310 |
#define LCGE_KEY_F22 311 |
#define LCGE_KEY_F23 312 |
#define LCGE_KEY_F24 313 |
#define LCGE_KEY_F25 314 |
#define LCGE_KEY_KP_0 320 |
#define LCGE_KEY_KP_1 321 |
#define LCGE_KEY_KP_2 322 |
#define LCGE_KEY_KP_3 323 |
#define LCGE_KEY_KP_4 324 |
#define LCGE_KEY_KP_5 325 |
#define LCGE_KEY_KP_6 326 |
#define LCGE_KEY_KP_7 327 |
#define LCGE_KEY_KP_8 328 |
#define LCGE_KEY_KP_9 329 |
#define LCGE_KEY_KP_DECIMAL 330 |
#define LCGE_KEY_KP_DIVIDE 331 |
#define LCGE_KEY_KP_MULTIPLY 332 |
#define LCGE_KEY_KP_SUBTRACT 333 |
#define LCGE_KEY_KP_ADD 334 |
#define LCGE_KEY_KP_ENTER 335 |
#define LCGE_KEY_KP_EQUAL 336 |
#define LCGE_KEY_LEFT_SHIFT 340 |
#define LCGE_KEY_LEFT_CONTROL 341 |
#define LCGE_KEY_LEFT_ALT 342 |
#define LCGE_KEY_LEFT_SUPER 343 |
#define LCGE_KEY_RIGHT_SHIFT 344 |
#define LCGE_KEY_RIGHT_CONTROL 345 |
#define LCGE_KEY_RIGHT_ALT 346 |
#define LCGE_KEY_RIGHT_SUPER 347 |
#define LCGE_KEY_MENU 348 |
#define LCGE_KEY_PRESSED 1 |
#define LCGE_KEY_RELEASED -1 |
#define LCGE_MOUSE_BUTTON_1 0 |
#define LCGE_MOUSE_BUTTON_2 1 |
#define LCGE_MOUSE_BUTTON_3 2 |
#define LCGE_MOUSE_BUTTON_4 3 |
#define LCGE_MOUSE_BUTTON_5 4 |
#define LCGE_MOUSE_BUTTON_6 5 |
#define LCGE_MOUSE_BUTTON_7 6 |
#define LCGE_MOUSE_BUTTON_8 7 |
#define LCGE_MOUSE_BUTTON_LAST LCGE_MOUSE_BUTTON_8 |
#define LCGE_MOUSE_BUTTON_LEFT LCGE_MOUSE_BUTTON_1 |
#define LCGE_MOUSE_BUTTON_RIGHT LCGE_MOUSE_BUTTON_2 |
#define LCGE_MOUSE_BUTTON_MIDDLE LCGE_MOUSE_BUTTON_3 |
#define LCGE_MOUSE_BUTTON_PRESSED 1 |
#define LCGE_MOUSE_BUTTON_RELEASED -1 |
A 2D rectangle.
typedef struct LCGE_image LCGE_image |
A 2D image.
typedef struct LCGE_clock LCGE_clock |
Basic FPS clock.
typedef struct LCGE_cursor_pos LCGE_cursor_pos |
A true type font.
2D text.
LCGE_IMPORT int lcge_init | ( | const char * | lcge_res_dir | ) |
Initializes LCGE.
This function will setup GLFW, as well as save the LCGE asset directory in memory, which will be used later to load shaders
LCGE_IMPORT int lcge_create_context | ( | unsigned int | width, |
unsigned int | height, | ||
const char * | title, | ||
int | resizable | ||
) |
Create a window and get back a handle.
Takes in width and height in pixels resizeable is either LCGE_RESIZEABLE or LCGE_NON_RESIZEABLE
LCGE_IMPORT int lcge_window_is_open | ( | ) |
Returns whether or not the window is still open.
Returns LCGE_WINDOW_CLOSED if the window should be closed if not, returns LCGE_WINDOW_OPEN
LCGE_IMPORT void lcge_exit | ( | ) |
Exits lcge.
Delets any leftover garbage from the engine. this DOES NOT delete user created memory. Delete those yourself.
LCGE_IMPORT void lcge_window_clear | ( | ) |
Clears the window.
This will clear the color buffer and set the screen to all black
LCGE_IMPORT void lcge_window_update | ( | ) |
Updates the window and polls for events.
LCGE_IMPORT LCGE_rect* lcge_rect_load | ( | float | x, |
float | y, | ||
float | width, | ||
float | height | ||
) |
Loads rectangle data and returns a handle.
Takes in x, y coordinates and width and height (0, 0) is considered to be at the top left of the window
Width and height are in pixels.
LCGE_IMPORT void lcge_rect_delete | ( | LCGE_rect * | rect | ) |
Deletes a rectangle.
LCGE_IMPORT void lcge_rect_draw | ( | LCGE_rect * | rect, |
float | r, | ||
float | g, | ||
float | b | ||
) |
Draw a loaded rectangle to the screen.
Takes r, g, b (0 to 255) color values as input.
LCGE_IMPORT void lcge_rect_set | ( | LCGE_rect * | rect, |
float | x, | ||
float | y, | ||
float | width, | ||
float | height | ||
) |
Updates rectangle data for a loaded rectangle.
This function allows you to set new x, y, width, and height values for your rectangle
LCGE_IMPORT void lcge_rect_rotate | ( | LCGE_rect * | rect, |
float | angle | ||
) |
Rotates a loaded rectangle.
Takes in an angle in degrees. Rotates counterclockwise.
LCGE_IMPORT float lcge_rect_get_x | ( | LCGE_rect * | rect | ) |
Gets the rectangle x value.
LCGE_IMPORT float lcge_rect_get_y | ( | LCGE_rect * | rect | ) |
Gets the rectangle y value.
LCGE_IMPORT float lcge_rect_get_width | ( | LCGE_rect * | rect | ) |
Gets the rectangle width.
LCGE_IMPORT float lcge_rect_get_height | ( | LCGE_rect * | rect | ) |
Gets the rectangle height.
LCGE_IMPORT LCGE_image* lcge_image_load | ( | const char * | filepath, |
float | x, | ||
float | y, | ||
float | width, | ||
float | height | ||
) |
Loads an image from a file.
Takes in a filepath, x/y coordinates, and a width and height to use when drawing
LCGE_IMPORT void lcge_image_delete | ( | LCGE_image * | image | ) |
Deletes an image.
LCGE_IMPORT void lcge_image_rotate | ( | LCGE_image * | image, |
float | angle | ||
) |
Rotates an image.
Takes in the angle in degrees.
LCGE_IMPORT void lcge_image_reflect | ( | LCGE_image * | image | ) |
Reflects an image horizontally 180 deg.
LCGE_IMPORT void lcge_image_set | ( | LCGE_image * | image, |
float | x, | ||
float | y, | ||
float | width, | ||
float | height | ||
) |
Sets new data for a loaded image.
Lets you set x, y, width, and height values
LCGE_IMPORT void lcge_image_draw | ( | LCGE_image * | image | ) |
Draws a loaded image to the screen.
LCGE_IMPORT float lcge_image_get_x | ( | LCGE_image * | image | ) |
Gets image x.
LCGE_IMPORT float lcge_image_get_y | ( | LCGE_image * | image | ) |
Gets image y.
LCGE_IMPORT float lcge_image_get_width | ( | LCGE_image * | image | ) |
Gets image width.
LCGE_IMPORT float lcge_image_get_height | ( | LCGE_image * | image | ) |
Gets image height.
LCGE_IMPORT LCGE_clock* lcge_clock_create | ( | unsigned int | fps | ) |
Creates a clock.
Takes in an fps. The clock will make sure that your window's fps is as close to the target fps as possible.
LCGE_IMPORT void lcge_clock_delete | ( | LCGE_clock * | clock | ) |
Deletes a clock.
LCGE_IMPORT void lcge_clock_tick | ( | LCGE_clock * | clock | ) |
tickst the clock.
Ticks the clock to get as close to the max fps as possible
LCGE_IMPORT int lcge_get_key | ( | int | key | ) |
Gets the input status of a key.
Takes in a key code, eg. LCGE_KEY_<key_name>
LCGE_IMPORT int lcge_get_mouse_button | ( | int | button | ) |
Gets input status of a mouse button.
Takes in LCGE_MOUSE_BUTTON_<1 through 8> OR LCGE_MOUSE_BUTTON_<LAST, LEFT, RIGHT, or MIDDLE>
returns LCGE_MOUSE_BUTTON_<PRESSED or RELEASE>
LCGE_IMPORT LCGE_cursor_pos lcge_get_cursor_position | ( | ) |
LCGE_IMPORT LCGE_font* lcge_font_load | ( | const char * | filepath, |
float | height | ||
) |
Loads a font.
Takes in a path to a .ttf file and the height of characters to be rendered in pixels.
LCGE_IMPORT void lcge_font_delete | ( | LCGE_font * | font | ) |
Deletes a font.
LCGE_IMPORT LCGE_text* lcge_text_load | ( | const char * | text, |
float | x, | ||
float | y, | ||
LCGE_font * | font | ||
) |
Loads a 2D text struct.
Takes in text as a string, x/y coordinates, and the font the x/y coords point to the BOTTOM LEFT of the text
LCGE_IMPORT void lcge_text_delete | ( | LCGE_text * | text | ) |
Deletes a text struct.
LCGE_IMPORT void lcge_text_draw | ( | LCGE_text * | text, |
float | r, | ||
float | g, | ||
float | b | ||
) |
Draws 2D text.
Takes in the loaded text, and r, g, b color values
LCGE_IMPORT void lcge_text_set | ( | LCGE_text * | text, |
const char * | n_text, | ||
float | x, | ||
float | y | ||
) |
Set new data for text.
Lets you specify new x and y values and new text
LCGE_IMPORT float lcge_text_get_x | ( | LCGE_text * | text | ) |
Gets x value of text.
x value is the top left.
LCGE_IMPORT float lcge_text_get_y | ( | LCGE_text * | text | ) |
Gets y value of text.
y value is the top left.
LCGE_IMPORT float lcge_text_get_width | ( | LCGE_text * | text | ) |
Gets the width of the text.
LCGE_IMPORT float lcge_text_get_height | ( | LCGE_text * | text | ) |
Gets the height of the text.
LCGE_IMPORT LCGE_line* lcge_line_load | ( | float | x0, |
float | y0, | ||
float | x1, | ||
float | y1 | ||
) |
LCGE_IMPORT void lcge_line_delete | ( | LCGE_line * | line | ) |
LCGE_IMPORT void lcge_line_draw | ( | LCGE_line * | line, |
float | r, | ||
float | g, | ||
float | b | ||
) |
LCGE_IMPORT void lcge_line_set | ( | LCGE_line * | line, |
float | x0, | ||
float | y0, | ||
float | x1, | ||
float | y1 | ||
) |