Add initial FnixLib development implementation
This commit is contained in:
commit
84742ae38e
33 files changed
+3340
No files matched your search
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* FnixLib - ventanas.
|
||||
*
|
||||
* Uso típico:
|
||||
*
|
||||
* FnixWindow *window = fnix_window_create("Mi juego", 800, 600);
|
||||
* while (!fnix_window_should_close(window)) {
|
||||
* fnix_begin_frame(window); // lee eventos, fija el destino
|
||||
* fnix_clear(FNIX_BLACK);
|
||||
* fnix_draw_circle(400, 300, 50, FNIX_RED);
|
||||
* fnix_end_frame(window); // muestra y limita los FPS
|
||||
* }
|
||||
* fnix_window_destroy(window);
|
||||
*
|
||||
* Limitaciones de la versión 0.1.0: la ventana tiene tamaño fijo y solo existe
|
||||
* la implementación para Linux/X11 (ver README.md).
|
||||
*
|
||||
* Todas las funciones aceptan window == NULL (no hacen nada o devuelven 0).
|
||||
*/
|
||||
#ifndef FNIX_WINDOW_H
|
||||
#define FNIX_WINDOW_H
|
||||
|
||||
#include "fnix/types.h"
|
||||
|
||||
FNIX_BEGIN_DECLS
|
||||
|
||||
/* Crea y muestra una ventana de width x height píxeles (cada lado entre 1 y
|
||||
* FNIX_CANVAS_MAX_SIZE) y su lienzo. Devuelve NULL si falla; el motivo está
|
||||
* en fnix_last_error(). Límite inicial de FPS: 60. */
|
||||
FnixWindow *fnix_window_create(const char *title, int width, int height);
|
||||
|
||||
/* Cierra la ventana y libera todos sus recursos. Acepta NULL. */
|
||||
void fnix_window_destroy(FnixWindow *window);
|
||||
|
||||
/* true cuando el usuario cerró la ventana o se llamó a fnix_window_request_close. */
|
||||
bool fnix_window_should_close(const FnixWindow *window);
|
||||
void fnix_window_request_close(FnixWindow *window);
|
||||
|
||||
int fnix_window_width(const FnixWindow *window);
|
||||
int fnix_window_height(const FnixWindow *window);
|
||||
|
||||
/* Lienzo de la ventana; lo que se dibuje en él se muestra en fnix_end_frame().
|
||||
* Pertenece a la ventana: no se debe destruir por separado. */
|
||||
FnixCanvas *fnix_window_canvas(FnixWindow *window);
|
||||
|
||||
/* Limita los fotogramas por segundo durmiendo en fnix_end_frame().
|
||||
* 0 desactiva el límite (el bucle usará toda la CPU). Valores negativos = 0. */
|
||||
void fnix_window_set_target_fps(FnixWindow *window, int fps);
|
||||
|
||||
/* Segundos entre el inicio del fotograma anterior y el del actual (medidos en
|
||||
* fnix_begin_frame). Vale 0 en el primer fotograma. */
|
||||
double fnix_window_delta_time(const FnixWindow *window);
|
||||
|
||||
/* Inicio de fotograma: borra los "pressed/released" y la rueda del fotograma
|
||||
* anterior, procesa los eventos pendientes del sistema, calcula el delta time
|
||||
* y fija el lienzo de la ventana como destino de dibujo. NO borra el lienzo. */
|
||||
void fnix_begin_frame(FnixWindow *window);
|
||||
|
||||
/* Fin de fotograma: muestra el lienzo en la ventana y espera lo necesario para
|
||||
* respetar el límite de FPS. */
|
||||
void fnix_end_frame(FnixWindow *window);
|
||||
|
||||
FNIX_END_DECLS
|
||||
|
||||
#endif /* FNIX_WINDOW_H */
|
||||
Reference in new issue
Block a user