1
1
Fork 0
Browse Source

tester program working

thread-physics
alistair 5 years ago
parent
commit
1d2a06a584
  1. 7
      Makefile
  2. BIN
      main
  3. 28
      main.c
  4. BIN
      main.o

7
Makefile

@ -1,12 +1,11 @@ @@ -1,12 +1,11 @@
CXX = gcc
# Update these paths to match your installation
# You may also need to update the linker option rpath, which sets where to look for
# the SDL2 libraries at runtime to match your install
SDL_INCLUDE = -lSDL2 -lSDL2_image
# You may need to change -std=c++11 to -std=c++0x if your compiler is a bit older
CXXFLAGS = $(SDL_INCLUDE)
EXE = main
run: all
./$(EXE)
all: $(EXE)
$(EXE): main.o

BIN
main

Binary file not shown.

28
main.c

@ -1,4 +1,3 @@ @@ -1,4 +1,3 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -88,7 +87,6 @@ typedef struct { @@ -88,7 +87,6 @@ typedef struct {
static sdl_abstract cleanup_queue[100];
static int cleanup_queue_length = 0;
void queue_for_cleanup(void * SDL_thing, sdl_types kind) {
sdl_abstract obj;
obj.kind = kind;
@ -154,7 +152,7 @@ struct SDL_Window* make_window(void) { @@ -154,7 +152,7 @@ struct SDL_Window* make_window(void) {
return SDL_CreateWindow("sdl_tester",
SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED,
screen_width, screen_height, 0);
800, 600, 0);
}
void step(void) {
@ -202,23 +200,21 @@ SDL_Texture * load_image(SDL_Renderer * ren, char fname[]) { @@ -202,23 +200,21 @@ SDL_Texture * load_image(SDL_Renderer * ren, char fname[]) {
void draw_pictures(struct SDL_Renderer * ren) {
// display an initial splash screen
const char file[] = "image.bmp";
SDL_Surface* surface = SDL_LoadBMP(file);
SDL_Texture * texture = SDL_CreateTextureFromSurface(ren,surface);
char png_file[] = "trans.PNG";
const char png_file[] = "trans.PNG";
/*
*SDL_Surface * png_surface = IMG_Load(png_file) ;
*if(!png_surface) {
* printf("IMG_Load: %s\n", IMG_GetError());
* // handle error
*}
*/
SDL_Surface * png_surface = IMG_Load(png_file) ;
if(!png_surface) {
printf("IMG_Load: %s\n", IMG_GetError());
// handle error
}
SDL_Texture * png_image = SDL_CreateTextureFromSurface(ren, png_surface);
SDL_Texture * png_image = load_image(ren, png_file); //SDL_CreateTextureFromSurface(ren, png_surface);
// remove the surface from memory as no longer needed
cleanup(png_surface, SURFACE);
cleanup(surface, SURFACE);
//cleanup(png_surface, SURFACE);
//cleanup(surface, SURFACE);
// check this actually does stuff
SDL_RenderClear(ren);

BIN
main.o

Binary file not shown.
Loading…
Cancel
Save