# HG changeset patch # User John Tsiombikas # Date 1394761177 -7200 # Node ID 3a893f9831ac256cc1183ec9ee867f323d822460 # Parent e9ae6289e14fb1b061398d327f6d3636a7e4f99e ported to SDL2 diff -r e9ae6289e14f -r 3a893f9831ac Makefile --- a/Makefile Fri Mar 07 07:42:48 2014 +0200 +++ b/Makefile Fri Mar 14 03:39:37 2014 +0200 @@ -2,8 +2,8 @@ obj = $(src:.c=.o) bin = mbrot -CFLAGS = -pedantic -Wall -g `pkg-config --cflags sdl` -LDFLAGS = `pkg-config --libs sdl` +CFLAGS = -pedantic -Wall -g `pkg-config --cflags sdl2` +LDFLAGS = `pkg-config --libs sdl2` $(bin): $(obj) $(CC) -o $@ $(obj) $(LDFLAGS) diff -r e9ae6289e14f -r 3a893f9831ac src/mbrot-mt.c --- a/src/mbrot-mt.c Fri Mar 07 07:42:48 2014 +0200 +++ b/src/mbrot-mt.c Fri Mar 14 03:39:37 2014 +0200 @@ -1,17 +1,43 @@ #include #include -#include +#include void display(void); int mandelbrot(float x, float y, int max_iter, int *iter); int handle_event(SDL_Event *ev); -static SDL_Surface *fbsurf; +static SDL_Window *win; +static SDL_Surface *winsurf; static int win_width, win_height; static float win_aspect; static float xoffs, yoffs, zoom = 1.0; static int max_iter = 64; +static void trysdl2stuff(void) +{ + int i, j, num_modes, num_scr; + + num_scr = SDL_GetNumVideoDisplays(); + + for(i=0; ipixels; - xsz = fbsurf->w; - ysz = fbsurf->h; + fbuf = winsurf->pixels; + xsz = winsurf->w; + ysz = winsurf->h; pixptr = fbuf; for(i=0; iresize.w; - win_height = ev->resize.h; - win_aspect = (float)win_width / (float)win_height; + case SDL_WINDOWEVENT: + if(ev->window.event == SDL_WINDOWEVENT_RESIZED) { + win_width = ev->window.data1; + win_height = ev->window.data2; + win_aspect = (float)win_width / (float)win_height; + } break; default: