in progress reverting to SDL1.2 for pi compatibility, adding sdl_gfx
Former-commit-id: 496ef51b135330911afed2719564b90e6e039c89 Former-commit-id: 85a5e21f8bf4a7bdc0ade370a0872bc2fbc9b59b
This commit is contained in:
parent
372835d743
commit
86d9c85c7e
|
@ -11,7 +11,7 @@ EXTRACFLAGS=-DHTMLPATH=\"$(SHAREDIR)\"
|
|||
endif
|
||||
|
||||
CFLAGS=-O2 -g -Wall -W `pkg-config --cflags librtlsdr`
|
||||
LIBS=`pkg-config --libs librtlsdr` -lpthread -lm `sdl2-config --libs` -lSDL2 -lSDL2_ttf
|
||||
LIBS=`pkg-config --libs librtlsdr` -lpthread -lm `sdl-config --libs` -lSDL -lSDL_ttf -lSDL_gfx
|
||||
CC=gcc
|
||||
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "SDL2/SDL.h"
|
||||
#include "SDL2/SDL_ttf.h"
|
||||
#include "SDL/SDL.h"
|
||||
#include "SDL/SDL_ttf.h"
|
||||
|
||||
#define SCREEN_WIDTH 320
|
||||
#define SCREEN_HEIGHT 240
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "dump1090.h"
|
||||
#include "draw.h"
|
||||
#include "parula.h"
|
||||
#include "SDL/SDL_gfxPrimitives.h"
|
||||
|
||||
extern void drawString(char *, int, int, TTF_Font *, SDL_Color);
|
||||
|
||||
|
@ -11,7 +12,7 @@ void CROSSVP(double *v, double *u, double *w)
|
|||
v[2] = u[0]*w[1] - u[1]*(w)[0];
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
SDL_Point screenCoords(double dx, double dy) {
|
||||
SDL_Point out;
|
||||
out.x = round(320.0 * (0.5 + (dx / 64.0)));
|
||||
|
@ -19,10 +20,11 @@ SDL_Point screenCoords(double dx, double dy) {
|
|||
|
||||
return out;
|
||||
}
|
||||
*/
|
||||
|
||||
void drawPlaneHeading(double dx, double dy, double heading, int signal, char *flight)
|
||||
{
|
||||
|
||||
/*
|
||||
SDL_Point center = screenCoords(dx,dy);
|
||||
|
||||
if(center.x < 0 || center.x >= 320 || center.y < 0 || center.y >= 240 ) {
|
||||
|
@ -87,11 +89,12 @@ void drawPlaneHeading(double dx, double dy, double heading, int signal, char *fl
|
|||
SDL_Color color = { 200, 200, 200 , 255};
|
||||
drawString(flight, center.x + 10, center.y + 10, game.font, color);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void drawPlane(double dx, double dy, int signal)
|
||||
{
|
||||
|
||||
/*
|
||||
SDL_Point center = screenCoords(dx,dy);
|
||||
|
||||
if(center.x < 0 || center.x >= 320 || center.y < 0 || center.y >= 240 ) {
|
||||
|
@ -112,9 +115,12 @@ void drawPlane(double dx, double dy, int signal)
|
|||
|
||||
SDL_RenderDrawLine(game.renderer, center.x-length , center.y , center.x+length , center.y );
|
||||
SDL_RenderDrawLine(game.renderer, center.x , center.y-length , center.x , center.y+length );
|
||||
*/
|
||||
}
|
||||
|
||||
void drawTrail(double *oldDx, double *oldDy, time_t * oldSeen, int idx) {
|
||||
|
||||
/*
|
||||
int currentIdx, prevIdx;
|
||||
|
||||
SDL_Point current, prev;
|
||||
|
@ -163,16 +169,14 @@ void drawTrail(double *oldDx, double *oldDy, time_t * oldSeen, int idx) {
|
|||
|
||||
// SDL_Rect spot = {.x = current.x-1, .y = current.y-1, .w = 2, .h = 2};
|
||||
// SDL_RenderFillRect(game.renderer, &spot);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
void drawGrid()
|
||||
{
|
||||
SDL_SetRenderDrawColor(game.renderer, 40, 40, 40, SDL_ALPHA_OPAQUE);
|
||||
|
||||
SDL_RenderDrawLine(game.renderer, 0, 120, 320, 120);
|
||||
SDL_RenderDrawLine(game.renderer, 160, 0, 160, 240);
|
||||
hlineRGBA (game.screen, 0, 320, 120, 40, 40, 40, SDL_ALPHA_OPAQUE);
|
||||
vlineRGBA (game.screen, 160, 0, 240, 40, 40, 40, SDL_ALPHA_OPAQUE);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -29,27 +29,27 @@ void closeFont(TTF_Font *font)
|
|||
void drawString(char * text, int x, int y, TTF_Font *font, SDL_Color color)
|
||||
{
|
||||
SDL_Surface *surface;
|
||||
SDL_Rect dest;
|
||||
|
||||
// surface = TTF_RenderUTF8_Shaded(font, text, foregroundColor, backgroundColor);
|
||||
surface = TTF_RenderText_Solid(font, text, color);
|
||||
surface = TTF_RenderUTF8_Solid(font, text, color);
|
||||
|
||||
if (surface == NULL)
|
||||
{
|
||||
printf("Couldn't create String: %s\n", SDL_GetError());
|
||||
printf("Couldn't create String %s: %s\n", text, SDL_GetError());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_Texture* Message = SDL_CreateTextureFromSurface(game.renderer, surface); //now you can convert it into a texture
|
||||
/* Blit the entire surface to the screen */
|
||||
|
||||
SDL_Rect Message_rect; //create a rect
|
||||
Message_rect.x = x; //controls the rect's x coordinate
|
||||
Message_rect.y = y; // controls the rect's y coordinte
|
||||
Message_rect.w = surface->w; // controls the width of the rect
|
||||
Message_rect.h = surface->h; // controls the height of the rect
|
||||
dest.x = x;
|
||||
dest.y = y;
|
||||
dest.w = surface->w;
|
||||
dest.h = surface->h;
|
||||
|
||||
SDL_RenderCopy(game.renderer, Message, NULL, &Message_rect); //you put the renderer's name first, the Message, the crop size(you can ignore this if you don't want to dabble with cropping), and the rect which is the size and coordinate of your texture
|
||||
SDL_BlitSurface(surface, NULL, game.screen, &dest);
|
||||
|
||||
/* Free the generated string image */
|
||||
|
||||
SDL_FreeSurface(surface);
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ void init(char *title)
|
|||
{
|
||||
/* Initialise SDL */
|
||||
|
||||
if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_EVENTS) < 0)
|
||||
if (SDL_Init(SDL_INIT_VIDEO) < 0)
|
||||
{
|
||||
printf("Could not initialize SDL: %s\n", SDL_GetError());
|
||||
|
||||
|
@ -24,16 +24,18 @@ void init(char *title)
|
|||
}
|
||||
|
||||
|
||||
if (SDL_CreateWindowAndRenderer(SCREEN_WIDTH, SCREEN_HEIGHT, 0, &(game.window), &(game.renderer)) < 0)
|
||||
{
|
||||
printf("Couldn't initialize Renderer: %s\n", SDL_GetError());
|
||||
game.screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 0, SDL_HWPALETTE|SDL_DOUBLEBUF);
|
||||
|
||||
if (game.screen == NULL)
|
||||
{
|
||||
printf("Couldn't set screen mode to %d x %d: %s\n", SCREEN_WIDTH, SCREEN_HEIGHT, SDL_GetError());
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Set the screen title */
|
||||
|
||||
SDL_SetWindowTitle(game.window,title);
|
||||
SDL_WM_SetCaption(title, NULL);
|
||||
}
|
||||
|
||||
void cleanup()
|
||||
|
@ -46,10 +48,6 @@ void cleanup()
|
|||
|
||||
TTF_Quit();
|
||||
|
||||
|
||||
SDL_DestroyWindow(game.window);
|
||||
|
||||
|
||||
/* Shut down SDL */
|
||||
|
||||
SDL_Quit();
|
||||
|
|
|
@ -472,8 +472,8 @@ void interactiveShowData(void) {
|
|||
}
|
||||
printf(
|
||||
"-------------------------------------------------------------------------------\n");
|
||||
SDL_SetRenderDrawColor(game.renderer, 0, 0, 0, SDL_ALPHA_OPAQUE);
|
||||
SDL_RenderClear(game.renderer);
|
||||
SDL_FillRect(game.screen, NULL, 0);
|
||||
|
||||
drawGrid();
|
||||
|
||||
while(a && (count < Modes.interactive_rows)) {
|
||||
|
@ -573,8 +573,7 @@ void interactiveShowData(void) {
|
|||
a = a->next;
|
||||
}
|
||||
|
||||
SDL_RenderPresent(game.renderer);
|
||||
|
||||
SDL_Flip(game.screen);
|
||||
}
|
||||
//
|
||||
//=========================================================================
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
typedef struct Game
|
||||
{
|
||||
SDL_Window *window;
|
||||
SDL_Renderer *renderer;
|
||||
SDL_Surface *screen;
|
||||
TTF_Font *font;
|
||||
} Game;
|
||||
|
|
|
@ -1 +1 @@
|
|||
a6a9a37e655d982e0f80b7465ae153997cf598a3
|
||||
16533af5cceadbea2c10e6425e91d0560cabdbd8
|
|
@ -238,15 +238,6 @@ void showCopyright(void) {
|
|||
//
|
||||
|
||||
|
||||
int SDLCALL watch(void *userdata, SDL_Event* event) {
|
||||
|
||||
if (event->type == SDL_APP_WILLENTERBACKGROUND) {
|
||||
go = 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
@ -345,7 +336,7 @@ int main(int argc, char **argv) {
|
|||
|
||||
/* Start up SDL */
|
||||
|
||||
init("Parallel Realities Tutorial 7");
|
||||
init("sdl1090");
|
||||
|
||||
/* Call the cleanup function when the program exits */
|
||||
|
||||
|
@ -358,10 +349,6 @@ int main(int argc, char **argv) {
|
|||
|
||||
game.font = loadFont("Arial.ttf", 10);
|
||||
|
||||
/* Loop indefinitely for messages */
|
||||
|
||||
|
||||
SDL_AddEventWatch(watch, NULL);
|
||||
|
||||
|
||||
while (go == 1)
|
||||
|
|
Loading…
Reference in a new issue