Compare commits
3 commits
Author | SHA1 | Date | |
---|---|---|---|
8874d02a66 | |||
ceba81a37f | |||
02374b706e |
10 changed files with 139 additions and 0 deletions
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
*.o
|
||||
*.a
|
||||
*.so
|
||||
*.exe
|
5
AUTHORS
Normal file
5
AUTHORS
Normal file
|
@ -0,0 +1,5 @@
|
|||
Egor Baranovsky (egorgeek)
|
||||
baranovsky.egorka@yandex.ru
|
||||
|
||||
Denis Butorin (dekabu)
|
||||
dyonya0.0@gmail.com
|
35
Makefile
Normal file
35
Makefile
Normal file
|
@ -0,0 +1,35 @@
|
|||
PREFIX = /usr
|
||||
HEADERSDIR = $(PREFIX)/include/glazir
|
||||
LIBDIR = $(PREFIX)/lib64
|
||||
|
||||
HEADERS = src/glazir.h \
|
||||
src/types.h \
|
||||
src/window.h \
|
||||
src/version.h
|
||||
|
||||
OBJ = src/window.o \
|
||||
src/main.o
|
||||
|
||||
libglazir.a: $(OBJ)
|
||||
ar rcs libglazir.a $(OBJ)
|
||||
|
||||
install/headers:
|
||||
mkdir -p $(HEADERSDIR)
|
||||
cp $(HEADERS) $(HEADERSDIR)
|
||||
|
||||
install/static: libglazir.a
|
||||
mkdir -p $(LIBDIR)
|
||||
cp libglazir.a $(LIBDIR)
|
||||
|
||||
install: install/headers install/static
|
||||
|
||||
uninstall/headers:
|
||||
rm -r $(HEADERSDIR)
|
||||
|
||||
uninstall/static:
|
||||
rm $(LIBDIR)/libglazir.a
|
||||
|
||||
uninstall: uninstall/headers uninstall/static
|
||||
|
||||
clean:
|
||||
rm src/*.o
|
17
README.md
17
README.md
|
@ -1,2 +1,19 @@
|
|||
# glazir
|
||||
|
||||
## Описание
|
||||
C-библиотека для математических и физических визуализаций, основанная на [SDL3](https://www.libsdl.org/)
|
||||
|
||||
## Инструкция по сборке
|
||||
1. Склонируйте репозиторий и перейдите в директорию
|
||||
```sh
|
||||
git clone https://git.kpfu.su/GLAZIR/glazir
|
||||
cd glazir
|
||||
```
|
||||
2. Соберите библиотеку
|
||||
```sh
|
||||
make
|
||||
```
|
||||
3. Установите библиотеку
|
||||
```sh
|
||||
make install
|
||||
```
|
||||
|
|
13
src/glazir.h
Normal file
13
src/glazir.h
Normal file
|
@ -0,0 +1,13 @@
|
|||
#ifndef GLAZIR
|
||||
#define GLAZIR
|
||||
|
||||
#include "version.h"
|
||||
#include "window.h"
|
||||
|
||||
void gr_init(int argc, char *argv[]);
|
||||
|
||||
void gr_event(gr_Event *event);
|
||||
|
||||
void gr_frame();
|
||||
|
||||
#endif
|
36
src/main.c
Normal file
36
src/main.c
Normal file
|
@ -0,0 +1,36 @@
|
|||
#define SDL_MAIN_USE_CALLBACKS 1
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_main.h>
|
||||
|
||||
#include "glazir.h"
|
||||
|
||||
SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
|
||||
{
|
||||
if (!SDL_Init(SDL_INIT_VIDEO)) {
|
||||
SDL_Log("Не удалось инициализировать SDL: %s", SDL_GetError());
|
||||
return SDL_APP_FAILURE;
|
||||
}
|
||||
|
||||
gr_init(argc, argv);
|
||||
|
||||
return SDL_APP_CONTINUE;
|
||||
}
|
||||
|
||||
SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event)
|
||||
{
|
||||
gr_event(event);
|
||||
|
||||
return SDL_APP_CONTINUE;
|
||||
}
|
||||
|
||||
SDL_AppResult SDL_AppIterate(void *appstate)
|
||||
{
|
||||
gr_frame();
|
||||
|
||||
return SDL_APP_CONTINUE;
|
||||
}
|
||||
|
||||
void SDL_AppQuit(void *appstate, SDL_AppResult result)
|
||||
{
|
||||
|
||||
}
|
10
src/types.h
Normal file
10
src/types.h
Normal file
|
@ -0,0 +1,10 @@
|
|||
#include <SDL3/SDL.h>
|
||||
|
||||
struct _gr_Window {
|
||||
SDL_Window* w;
|
||||
SDL_Renderer* r;
|
||||
};
|
||||
|
||||
typedef struct _gr_Window gr_Window;
|
||||
|
||||
typedef SDL_Event gr_Event;
|
3
src/version.h
Normal file
3
src/version.h
Normal file
|
@ -0,0 +1,3 @@
|
|||
#define PIE_VERSION_MAJOR 0
|
||||
#define PIE_VERSION_MINOR 1
|
||||
#define PIE_VERSION_PATCH 0
|
11
src/window.c
Normal file
11
src/window.c
Normal file
|
@ -0,0 +1,11 @@
|
|||
#include "window.h"
|
||||
|
||||
int gr_createWindow(const char* title, int width, int height, gr_Window* window)
|
||||
{
|
||||
return SDL_CreateWindowAndRenderer(title, width, height, 0, &window->w, &window->r);
|
||||
}
|
||||
|
||||
void gr_drawWindow(gr_Window* window)
|
||||
{
|
||||
SDL_RenderPresent(window->r);
|
||||
}
|
5
src/window.h
Normal file
5
src/window.h
Normal file
|
@ -0,0 +1,5 @@
|
|||
#include "types.h"
|
||||
|
||||
int gr_createWindow(const char* title, int width, int height, gr_Window* window);
|
||||
|
||||
void gr_drawWindow(gr_Window* window);
|
Loading…
Add table
Add a link
Reference in a new issue