Processes events, updates input state, and prepares for the next frame.
Processes events, updates input state, and prepares for the next frame.This function should be called at the end of the main game loop. It handles window events, polls for input, updates mouse and keyboard states, and swaps the graphics buffers.
#pragma once
#define GAMA_VERSION_MAJOR 0
#define GAMA_VERSION_MINOR 1
#define GAMA_VERSION_PATCH 0
#include <stdio.h>
void gm_logo(
double x,
double y,
double s) {
double top_thickness = 0.15 * s;
double left_thickness = 0.1 * s;
double ratio = 0.6;
}
static inline int gm_runs() {
return gapi_runs(); }
static const double alpha = 0.9;
static double _fps = 0;
static double dt = 1;
static double _display_fps = 0;
dt += gm_dt();
double fps = 1 / gm_dt();
if (_fps == 0)
_fps = 60;
else
_fps = (_fps * alpha) + (fps * (1 - alpha));
if (dt >= 0.5) {
dt = 0;
_display_fps = _fps;
}
char fps_text[20];
snprintf(fps_text, sizeof(fps_text), "fps: %.2lf", _display_fps);
}
}
static inline int gm_yield() {
return 1;
} else
return 0;
}
static inline void gm_quit() {
return gapi_quit(); }
}
void gm_init(
int width,
int height,
const char *title) {
char msg[100];
if (code != 0) {
snprintf(msg, sizeof(msg),
"Error starting gama, initialization exited with non zero code %d",
code);
printf("%s", msg);
}
gm_yield();
}
#ifdef _WIN32
#include <windows.h>
void gm_sleep(
int milliseconds) { Sleep(milliseconds); }
#else
#include <unistd.h>
void gm_sleep(
int milliseconds) { usleep(milliseconds * 1000); }
#endif
Functions for animating values with various easing functions.
#define gm_blue(col)
Extracts the blue component from a color.
Definition color.h:29
#define gm_green(col)
Extracts the green component from a color.
Definition color.h:22
unsigned int gmColor
Type definition for color values in RGBA format.
Definition color.h:8
#define gm_red(col)
Extracts the red component from a color.
Definition color.h:15
#define GM_GAMA
The official Gama brand color.
Definition color.h:126
#define GM_BLACK
Black color.
Definition color.h:166
#define gm_alpha(col)
Extracts the alpha component from a color.
Definition color.h:36
#define GM_WHITE
White color.
Definition color.h:851
Functions for drawing shapes, text, and images.
int32_t gm_draw_text(double x, double y, const char *text, const char *font, double font_size, gmColor c)
Draws text.
Definition draw.h:135
int32_t gm_draw_rectangle(double x, double y, double w, double h, gmColor c)
Draws a rectangle.
Definition draw.h:47
int gmw_frame(double x, double y, double width, double height)
Creates and renders a frame widget (a bordered panel).
Definition frame.h:67
void gm_log(const char *txt)
Definition gama.h:52
void gm_show_fps(int show)
Definition gama.h:63
int __gm_show_fps
Definition gama.h:62
void _gm_fps()
Definition gama.h:65
void gm_resize(int width, int height)
Definition gama.h:138
void gm_logo(double x, double y, double s)
Draws gama logo.
Definition gama.h:41
void gm_sleep(int milliseconds)
Sleep(wait) for aproximately the specified number of milliseconds.
Definition gama.h:178
void gm_fullscreen(int fullscreen)
Puts the window in fullscreen.
Definition gama.h:32
void gm_background(gmColor c)
Sets the background color of the window.
Definition gama.h:134
void gm_sync()
Waits for all pending graphics operations to complete.
Definition gama.h:128
void gm_init(int width, int height, const char *title)
Initializes the Gama engine and opens a window.
Definition gama.h:150
int32_t gapi_mouse_down()
double _gm_dt
Definition gapi.h:6
void gapi_fullscreen(const int32_t fullscreen)
int32_t gapi_mouse_pressed()
void gapi_set_bg_color(const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t a)
double _gm_t
Definition gapi.h:7
int32_t gapi_init(const int32_t width, const int32_t height, const char *title)
void gapi_resize(const int32_t width, const int32_t height)
void gapi_log(const char *message)
void gapi_get_mouse_move(double *x, double *y)
int32_t gapi_yield(double *dt)
struct _gmMouse gm_mouse
Definition gapi.h:19
int32_t gapi_mouse_get(double *x, double *y)