Skip to content

Commit fbd614c

Browse files
committed
SDL2 support for demo app
1 parent f40af86 commit fbd614c

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

include/SU/SU_pixelmanip.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
#ifndef SU_pixelmanip_h
22
#define SU_pixelmanip_h
33

4-
#include <SDL/SDL.h>
4+
#if USING_SDL1
5+
#include <SDL/SDL.h>
6+
#else
7+
#include <SDL2/SDL.h>
8+
#endif
9+
510
#include "SU/SU_etc.h"
611

712
void SDL_Surface_putpixel_nolock(SDL_Surface* s, int x, int y, int color);

src/main.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <vector>
88
#include <numeric>
99

10-
#if 0
10+
#ifdef MAIN_FULLSCREEN
1111
#define WIDTH 1920
1212
#define HEIGHT 1080
1313
#else
@@ -453,6 +453,8 @@ std::vector<Uint32>::iterator current_render_time = render_times.begin();
453453

454454
int main( int argc, char* args[] )
455455
{
456+
srand(time(NULL));
457+
456458
Uint32 currentSec = 0;
457459
Uint32 currentSecFPS = 0;
458460
Uint8 previousSecFPS = 0;
@@ -502,7 +504,7 @@ int main( int argc, char* args[] )
502504
SU::setFlag(SU::Flags::LIGHTING);
503505

504506

505-
TTF_Font *font = TTF_OpenFont("./Dina_r400-10.bdf", 0);
507+
TTF_Font *font = TTF_OpenFont("./cft.ttf", 16);
506508
if (font == NULL)
507509
DIE(TTF_GetError());
508510

@@ -654,6 +656,7 @@ int main( int argc, char* args[] )
654656
}
655657
break;
656658

659+
#if USING_SDL1
657660
case SDL_MOUSEBUTTONDOWN:
658661
{
659662
switch(e.button.button)
@@ -670,6 +673,21 @@ int main( int argc, char* args[] )
670673
}
671674
}
672675
break;
676+
#else
677+
case SDL_MOUSEWHEEL:
678+
{
679+
if (e.wheel.y > 0)
680+
{
681+
Camera.distance *= (0.9 * e.wheel.y);
682+
}
683+
else
684+
{
685+
Camera.distance /= (0.9 * abs(e.wheel.y));
686+
}
687+
688+
}
689+
break;
690+
#endif
673691

674692
default: break;
675693
}

0 commit comments

Comments
 (0)