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
#include "stdio.h"
#ifdef GM_ARGC_MAIN
#else
#endif
int32_t
#ifdef __ZIG_CC__
__attribute__((export_name("gama_run")))
#endif
#ifdef GM_ARGC_MAIN
#else
#endif
}
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 inline int gm_yield() {
static const double alpha = 2.0 / 3.0;
static double _fps = 0;
static double dt = 1;
static double _display_fps = 0;
double current_dt = gm_dt();
dt += current_dt;
double fps = 1 / current_dt;
if (current_dt == 0)
fps = _fps;
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] = {0};
snprintf(fps_text, sizeof(fps_text), "fps: %.2f", _display_fps);
}
static int last_mouse_down = 0;
return ret;
}
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);
}
}
#ifdef __ZIG_CC__
#else
#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
#endif
#define GM_GAMA
The official Gama brand color.
Definition color.h:167
#define GM_BLACK
Black color.
Definition color.h:207
#define GM_WHITE
White color.
Definition color.h:892
uint32_t gmColor
Type definition for color values, stored as a 32-bit unsigned integer. The color components are packe...
Definition color.h:13
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 centered at a point.
Definition draw.h:140
int32_t gm_draw_rectangle(double x, double y, double w, double h, gmColor c)
Draws a rectangle centered at a point.
Definition draw.h:57
Defines the theme and functionality for a frame widget.
int gmw_frame(double x, double y, double width, double height)
Creates and renders a frame widget (a bordered panel).
Definition frame.h:80
void gm_log(const char *txt)
Logs a message to the platform's console.
Definition gama.h:70
void gm_show_fps(int show)
Definition gama.h:85
int __gm_show_fps
Enables or disables the built-in FPS counter display.
Definition gama.h:84
void gm_resize(int width, int height)
Resizes the application window.
Definition gama.h:159
void gm_logo(double x, double y, double s)
Draws the Gama logo.
Definition gama.h:54
void gm_sleep(int milliseconds)
Pauses execution for a specified duration.
Definition gama.h:202
void gm_fullscreen(int fullscreen)
Puts the window in fullscreen.
Definition gama.h:45
void gm_background(gmColor c)
Sets the background color of the window.
Definition gama.h:151
int32_t gama_run()
Definition gama.h:32
void gm_init(int width, int height, const char *title)
Initializes the Gama engine and opens a window.
Definition gama.h:171
Graphics API (GAPI) abstraction layer for Gama.
int32_t gapi_mouse_down()
Checks if the mouse button is currently pressed.
double _gm_dt
Definition gapi.h:20
void gapi_fullscreen(const int32_t fullscreen)
Toggles fullscreen mode for the application window.
double _gm_t
Definition gapi.h:26
int32_t gapi_init(const int32_t width, const int32_t height, const char *title)
Initializes the Graphics API and the application window.
void gapi_resize(const int32_t width, const int32_t height)
Resizes the application window.
void gapi_log(const char *message)
Logs a message to the platform's console.
void gapi_quit()
Requests the application to quit.
int32_t gapi_yield(double *dt)
Yields control to the platform, processes events, and updates timing.
int32_t gapi_runs()
Checks if the application is still running.
int32_t gapi_mouse_get(double *x, double *y)
Retrieves the current mouse cursor position.
void gapi_set_background_color(const gmColor background)
Sets the background color of the application window.
struct _gmMouse gm_mouse
Definition mouse.h:32