moved the drawFps call to the backends so it works automatically for
authorJohn Tsiombikas <nuclear@mutantstargoat.com>
Wed, 5 Oct 2016 01:19:46 +0000 (04:19 +0300)
committerJohn Tsiombikas <nuclear@mutantstargoat.com>
Wed, 5 Oct 2016 01:19:46 +0000 (04:19 +0300)
any part

src/bump.c
src/demo.c
src/dos/main.c
src/fract.c
src/plasma.c
src/sdl/main.c

index 104b127..a6f7aad 100644 (file)
@@ -7,7 +7,6 @@
 
 #include "demo.h"
 #include "screen.h"
-#include "tinyfps.h"
 
 static int init(void);
 static void destroy(void);
@@ -60,7 +59,6 @@ static int init(void)
        const float rgbMul[9] = { 1.0f, 0.0f, 0.0f, 
                                                                  0.0f, 1.0f, 0.0f,
                                                                  0.0f, 0.0f, 1.0f};
-       initFpsFonts();
 
        heightmap = malloc(sizeof(*heightmap) * fb_size);
        lightmap = malloc(sizeof(*lightmap) * fb_size);
@@ -265,7 +263,5 @@ static void draw(void)
        renderLights();
        renderBump((unsigned short*)vmem_back);
 
-       drawFps((unsigned short*)vmem_back);
-
        swap_buffers(0);
 }
index 472da32..518bb53 100644 (file)
@@ -9,6 +9,7 @@
 #include "3dgfx.h"
 #include "music.h"
 #include "cfgopt.h"
+#include "tinyfps.h"
 
 int fb_width = 320;
 int fb_height = 240;
@@ -35,6 +36,8 @@ int demo_init(int argc, char **argv)
                return -1;
        }
 
+       initFpsFonts();
+
        if(g3d_init() == -1) {
                return -1;
        }
index 53b8888..051cdb5 100644 (file)
@@ -76,6 +76,9 @@ void swap_buffers(void *pixels)
        /* TODO implement page flipping */
        if(pixels) {
                /*wait_vsync();*/
+               drawFps(pixels);
                memcpy(vmem_front, pixels, fbsize);
+       } else {
+               drawFps(vmem_back);
        }
 }
index 15da79d..a17550b 100644 (file)
@@ -12,7 +12,6 @@ static int init(void);
 static void destroy(void);
 static void draw(void);
 static int julia(long x, long y, long cx, long cy, int max_iter);
-static int calc_walk(struct vec2x *path, long x, long y, int max_steps);
 
 static struct screen scr = {
        "fract",
@@ -49,9 +48,8 @@ static void destroy(void)
 
 static void draw(void)
 {
-       int i, j, len, x, y;
-       unsigned short *pixels = fb_pixels;
-       struct vec2x walkpos[WALK_SIZE];
+       int i, j;
+       unsigned short *pixels = vmem_back;
 
        cx = mouse_x;
        cy = mouse_y;
@@ -63,29 +61,9 @@ static void draw(void)
                }
        }
 
-       pixels = fb_pixels;
-
-       if((len = calc_walk(walkpos, mouse_x, mouse_y, WALK_SIZE))) {
-               x = walkpos[0].x >> 16;
-               y = walkpos[0].y >> 16;
-
-               for(i=1; i<len; i++) {
-                       int x0 = x;
-                       int y0 = y;
-                       int x1 = walkpos[i].x >> 16;
-                       int y1 = walkpos[i].y >> 16;
-
-                       if(clip_line(&x0, &y0, &x1, &y1, 0, 0, fb_width - 1, fb_height - 1)) {
-                               draw_line(x0, y0, x1, y1, PACK_RGB16(32, 128, 255));
-                       }
-                       x = x1;
-                       y = y1;
-               }
-       }
-
+       pixels = vmem_back;
        pixels[mouse_y * fb_width + mouse_x] = 0xffe;
-
-       swap_buffers(fb_pixels);
+       swap_buffers(vmem_back);
 }
 
 static long normalize_coord(long x, long range)
@@ -94,12 +72,6 @@ static long normalize_coord(long x, long range)
        return (x << 17) / range - 65536;
 }
 
-static long device_coord(long x, long range)
-{
-       /* (x + 1) / 2 * (range - 1) */
-       return ((x + 65536) >> 1) * (range - 1);
-}
-
 static int julia(long x, long y, long cx, long cy, int max_iter)
 {
        int i;
@@ -124,30 +96,3 @@ static int julia(long x, long y, long cx, long cy, int max_iter)
 
        return i < max_iter ? (256 * i / max_iter) : 0;
 }
-
-static int calc_walk(struct vec2x *path, long x, long y, int max_steps)
-{
-       int i;
-       long cx, cy;
-
-       /* convert to fixed point roughly [-1, 1] */
-       x = cx = (normalize_coord(x, fb_width) >> 8) * xscale_24x8;
-       y = cy = (normalize_coord(y, fb_height) >> 8) * yscale_24x8;
-
-       for(i=0; i<max_steps; i++) {
-               /* z_n = z_{n-1}**2 + c */
-               long px = x >> 8;
-               long py = y >> 8;
-
-               path[i].x = device_coord((x << 8) / xscale_24x8, fb_width);
-               path[i].y = device_coord((y << 8) / yscale_24x8, fb_height);
-
-               if(px * px + py * py > (4 << 16)) {
-                       break;
-               }
-               x = px * px - py * py + cx;
-               y = (px * py << 1) + cy;
-       }
-
-       return i;
-}
index 132cff3..c20ff63 100644 (file)
@@ -5,7 +5,6 @@
 
 #include "demo.h"
 #include "screen.h"
-#include "tinyfps.h"
 
 static int init(void);
 static void destroy(void);
@@ -41,8 +40,6 @@ static int init(void)
 {
        int i;
 
-       initFpsFonts();
-
        psin1 = (unsigned char*)malloc(sizeof(unsigned char) * PSIN_SIZE);
        psin2 = (unsigned char*)malloc(sizeof(unsigned char) * PSIN_SIZE);
        psin3 = (unsigned char*)malloc(sizeof(unsigned char) * PSIN_SIZE);
@@ -67,7 +64,6 @@ static int init(void)
                plasmaPal[i] = (r<<11) | (g<<5) | b;
        }
 
-       //return 0xCAFE;
        return 0;
 }
 
@@ -111,7 +107,5 @@ static void draw(void)
                }
        }
 
-       drawFps((unsigned short*)vmem_back);
-
        swap_buffers(0);
 }
index 48852f5..05744e8 100644 (file)
@@ -3,6 +3,7 @@
 #include <limits.h>
 #include <SDL/SDL.h>
 #include "demo.h"
+#include "tinyfps.h"
 
 static void handle_event(SDL_Event *ev);
 static void toggle_fullscreen(void);
@@ -61,6 +62,7 @@ int main(int argc, char **argv)
 
                time_msec = SDL_GetTicks() - start_time;
                demo_draw();
+               drawFps(fb_pixels);
 
                if(SDL_MUSTLOCK(fbsurf)) {
                        SDL_LockSurface(fbsurf);