mirror of
https://github.com/rzzzwilson/pymlac.git
synced 2025-06-10 09:32:41 +00:00
Start of using SDL2
This commit is contained in:
parent
ec3edee648
commit
1069da7926
8
imlac_sdl/NOTES
Normal file
8
imlac_sdl/NOTES
Normal file
@ -0,0 +1,8 @@
|
||||
Linker options:
|
||||
|
||||
`sdl2-config --cflags --libs` -lSDL2 -lSDL2_mixer -lSDL2_image -lSDL2_ttf
|
||||
|
||||
eg:
|
||||
|
||||
gcc myProgram.c -o myProgram `sdl2-config --cflags --libs` -lSDL2 -lSDL2_mixer -lSDL2_image -lSDL2_ttf
|
||||
g++ myProgram.cpp -o myProgram `sdl2-config --cflags --libs` -lSDL2 -lSDL2_mixer -lSDL2_image -lSDL2_ttf
|
||||
9
imlac_sdl/borderless/Makefile
Normal file
9
imlac_sdl/borderless/Makefile
Normal file
@ -0,0 +1,9 @@
|
||||
CC=gcc
|
||||
LDOPTS=`sdl2-config --cflags --libs` -lSDL2 -lSDL2_mixer -lSDL2_image -lSDL2_ttf
|
||||
|
||||
test: test.c Makefile
|
||||
${CC} test.c -o test ${LDOPTS}
|
||||
|
||||
clean:
|
||||
rm -Rf test
|
||||
|
||||
BIN
imlac_sdl/borderless/test
Executable file
BIN
imlac_sdl/borderless/test
Executable file
Binary file not shown.
64
imlac_sdl/borderless/test.c
Normal file
64
imlac_sdl/borderless/test.c
Normal file
@ -0,0 +1,64 @@
|
||||
#include <stdbool.h>
|
||||
#include <SDL.h>
|
||||
|
||||
#define WIDTH 1024
|
||||
#define HEIGHT 1024
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
// variables
|
||||
bool quit = false;
|
||||
SDL_Event event;
|
||||
|
||||
// init SDL
|
||||
SDL_Init(SDL_INIT_VIDEO);
|
||||
SDL_Window * window = SDL_CreateWindow("SDL2 line drawing",
|
||||
SDL_WINDOWPOS_UNDEFINED,
|
||||
SDL_WINDOWPOS_UNDEFINED,
|
||||
WIDTH, HEIGHT, SDL_WINDOW_BORDERLESS);
|
||||
SDL_Renderer * renderer = SDL_CreateRenderer(window, -1, 0);
|
||||
|
||||
// handle events
|
||||
while (!quit)
|
||||
{
|
||||
SDL_Delay(10);
|
||||
SDL_PollEvent(&event);
|
||||
|
||||
switch (event.type)
|
||||
{
|
||||
case SDL_QUIT:
|
||||
quit = true;
|
||||
break;
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
switch (event.button.button)
|
||||
{
|
||||
case SDL_BUTTON_LEFT:
|
||||
quit = true;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// clear window
|
||||
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
|
||||
SDL_RenderClear(renderer);
|
||||
|
||||
// TODO rendering code goes here
|
||||
SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
|
||||
SDL_RenderDrawLine(renderer, 0, 0, WIDTH, HEIGHT);
|
||||
SDL_RenderDrawLine(renderer, WIDTH, 0, 0, HEIGHT);
|
||||
|
||||
// render window
|
||||
|
||||
SDL_RenderPresent(renderer);
|
||||
}
|
||||
|
||||
// cleanup SDL
|
||||
|
||||
SDL_DestroyRenderer(renderer);
|
||||
SDL_DestroyWindow(window);
|
||||
SDL_Quit();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
9
imlac_sdl/hello_world/Makefile
Normal file
9
imlac_sdl/hello_world/Makefile
Normal file
@ -0,0 +1,9 @@
|
||||
CC=gcc
|
||||
LDOPTS=`sdl2-config --cflags --libs` -lSDL2 -lSDL2_mixer -lSDL2_image -lSDL2_ttf
|
||||
|
||||
hello_world: hello_world.c Makefile
|
||||
${CC} hello_world.c -o hello_world ${LDOPTS}
|
||||
|
||||
clean:
|
||||
rm -Rf hello_world
|
||||
|
||||
BIN
imlac_sdl/hello_world/hello_world
Executable file
BIN
imlac_sdl/hello_world/hello_world
Executable file
Binary file not shown.
9
imlac_sdl/hello_world/hello_world.c
Normal file
9
imlac_sdl/hello_world/hello_world.c
Normal file
@ -0,0 +1,9 @@
|
||||
#include <SDL.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION,
|
||||
"Smoke Test", "Hello, world!", NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user