diff --git a/defs.h b/defs.h index abdf5b9..f1ef68c 100644 --- a/defs.h +++ b/defs.h @@ -15,6 +15,8 @@ #define DISPLAY_ACTIVE 30 #define TRAIL_TTL_STEP 2 +#define MIN_MAP_FEATURE 2 + #define FRAMETIME 33 #define PAD 5 diff --git a/draw.c b/draw.c index 19e78dc..c04bd1d 100644 --- a/draw.c +++ b/draw.c @@ -529,7 +529,7 @@ void drawPolys(QuadTree *tree, double screen_lat_min, double screen_lat_max, dou } - if((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1) < 100){ + if((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1) < MIN_MAP_FEATURE){ currentPoint = currentPoint->next; continue; } @@ -538,7 +538,7 @@ void drawPolys(QuadTree *tree, double screen_lat_min, double screen_lat_max, dou double factor = 1.0 - (d1+d2) / (3* appData.maxDist * appData.maxDist); - SDL_Color lineColor = lerpColor(blue, purple, factor); + SDL_Color lineColor = lerpColor(purple, blue, factor); lineRGBA(appData.renderer, x1, y1, x2, y2, lineColor.r, lineColor.g, lineColor.b, 255); @@ -865,17 +865,10 @@ void resolveLabelConflicts() { } -void drawMap() { +void drawPlanes() { struct planeObj *p = planes; time_t now = time(NULL); SDL_Color planeColor; - drawGeography(); - - drawScaleBars(); - - for(int i = 0; i < 4; i++) { - resolveLabelConflicts(); - } //draw all trails first so they don't cover up planes and text @@ -931,10 +924,14 @@ void drawMap() { } if(p == selectedPlane) { - appData.centerLon += 0.1 * (p->lon - appData.centerLon); - appData.centerLat += 0.1 * (p->lat - appData.centerLat); - + if(fabs(p->lon - appData.centerLon) > 0.0001 || fabs(p->lat - appData.centerLat) > .0001) { + appData.centerLon += 0.1 * (p->lon - appData.centerLon); + appData.centerLat += 0.1 * (p->lat - appData.centerLat); + + appData.mapMoved = 1; + } + thickLineRGBA(appData.renderer, x - 40, y - 40, x - 10, y - 40, 4, pink.r, pink.g, pink.b, 255); thickLineRGBA(appData.renderer, x - 40, y - 40, x - 40, y - 10, 4, pink.r, pink.g, pink.b, 255); @@ -1004,26 +1001,54 @@ void drawMap() { // void draw() { - - if ((mstime() - appData.lastFrameTime) < FRAMETIME) { - return; - } - - appData.lastFrameTime = mstime(); - + uint64_t drawStartTime = mstime(); + updatePlanes(); updateStatus(); - SDL_SetRenderDrawColor( appData.renderer, 0, 15, 30, 0); + if(appData.mapMoved) { + SDL_SetRenderTarget(appData.renderer, appData.mapTexture); + SDL_SetRenderDrawColor(appData.renderer, 0, 0, 0, 0); + SDL_RenderClear(appData.renderer); + + drawGeography(); + drawScaleBars(); + + SDL_SetRenderTarget(appData.renderer, NULL ); + + appData.mapMoved = 0; + } + + for(int i = 0; i < 4; i++) { + resolveLabelConflicts(); + } + + //SDL_SetRenderDrawColor( appData.renderer, 0, 15, 30, 0); + SDL_SetRenderDrawColor(appData.renderer, 0, 0, 0, 0); SDL_RenderClear(appData.renderer); - drawMap(); + SDL_RenderCopy(appData.renderer, appData.mapTexture, NULL, NULL); + + drawPlanes(); drawStatus(); + if(appData.showList) { drawList(0); } - SDL_RenderPresent(appData.renderer); + char fps[10] = " "; + snprintf(fps,10," %ffps", 1000.0 / (mstime() - appData.lastFrameTime)); + drawStringBG(fps, 0,0, appData.mapFont, grey, black); + + + SDL_RenderPresent(appData.renderer); + + + appData.lastFrameTime = mstime(); + + if ((mstime() - drawStartTime) < FRAMETIME) { + usleep(1000 * (FRAMETIME - (mstime() - drawStartTime))); + } } \ No newline at end of file diff --git a/draw.o.REMOVED.git-id b/draw.o.REMOVED.git-id index 127f6f3..38449cd 100644 --- a/draw.o.REMOVED.git-id +++ b/draw.o.REMOVED.git-id @@ -1 +1 @@ -d08aaa37cf2b39ef11671ed4f318ae82fcf0c1dd \ No newline at end of file +e35f478e482bb67eed7951d8c622b7fc5ad06aa7 \ No newline at end of file diff --git a/font.o b/font.o index 3f98783..85b9bb7 100644 Binary files a/font.o and b/font.o differ diff --git a/init.c b/init.c index 720cd3a..d740e1d 100644 --- a/init.c +++ b/init.c @@ -37,11 +37,13 @@ void init(char *title) { appData.window = SDL_CreateWindow(title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, appData.screen_width, appData.screen_height, flags); appData.renderer = SDL_CreateRenderer(appData.window, -1, 0); - appData.texture = SDL_CreateTexture(appData.renderer, + appData.mapTexture = SDL_CreateTexture(appData.renderer, SDL_PIXELFORMAT_ARGB8888, - SDL_TEXTUREACCESS_STREAMING, + SDL_TEXTUREACCESS_TARGET, appData.screen_width, appData.screen_height); + appData.mapMoved = 1; + if(appData.fullscreen) { //\SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear"); // make the scaled rendering look smoother. SDL_RenderSetLogicalSize(appData.renderer, appData.screen_width, appData.screen_height); diff --git a/init.o b/init.o index 82dcfa3..f256814 100644 Binary files a/init.o and b/init.o differ diff --git a/input.c b/input.c index 4fe055d..9480445 100644 --- a/input.c +++ b/input.c @@ -47,10 +47,12 @@ void getInput() case SDL_MOUSEWHEEL: appData.maxDist *= 1.0 + event.wheel.y / 10.0; + appData.mapMoved = 1; break; case SDL_MULTIGESTURE: appData.maxDist /=1.0 + 4.0*event.mgesture.dDist; + appData.mapMoved = 1; break; case SDL_FINGERMOTION:; @@ -74,6 +76,7 @@ void getInput() appData.centerLon += outLon; appData.centerLat += outLat; + appData.mapMoved = 1; break; diff --git a/input.o.REMOVED.git-id b/input.o.REMOVED.git-id index 896993b..82d3329 100644 --- a/input.o.REMOVED.git-id +++ b/input.o.REMOVED.git-id @@ -1 +1 @@ -71b217637379d15bac063de1731f31a46620dce5 \ No newline at end of file +d4947b5d39abcf0073465f4b5683173294132874 \ No newline at end of file diff --git a/list.o b/list.o index bf26832..ed2a71d 100644 Binary files a/list.o and b/list.o differ diff --git a/monokai.o b/monokai.o index a21da71..f3c046f 100644 Binary files a/monokai.o and b/monokai.o differ diff --git a/planeObj.o b/planeObj.o index 1be9b9e..22a7674 100644 Binary files a/planeObj.o and b/planeObj.o differ diff --git a/status.o.REMOVED.git-id b/status.o.REMOVED.git-id index 17750e5..6ca3b1e 100644 --- a/status.o.REMOVED.git-id +++ b/status.o.REMOVED.git-id @@ -1 +1 @@ -006a8fe10b2ac3777a05e5056d4166533ad2fae5 \ No newline at end of file +9aa844df5159c2a246895c0eb2a306f53d0a36fd \ No newline at end of file diff --git a/structs.h b/structs.h index 45b64d7..3fac6c5 100644 --- a/structs.h +++ b/structs.h @@ -7,7 +7,7 @@ typedef struct AppData { SDL_Window *window; SDL_Renderer *renderer; - SDL_Texture *texture; + SDL_Texture *mapTexture; TTF_Font *mapFont; TTF_Font *mapBoldFont; @@ -43,6 +43,8 @@ typedef struct AppData int touchx; int touchy; + int mapMoved; + uint64_t lastFrameTime; } AppData; diff --git a/view1090.REMOVED.git-id b/view1090.REMOVED.git-id index 6735ea2..54b83a0 100644 --- a/view1090.REMOVED.git-id +++ b/view1090.REMOVED.git-id @@ -1 +1 @@ -607b9efc8cc81bbdd0c6f524632fc9b69ab1e244 \ No newline at end of file +8796641d884a28c9d0b97396f099bd3333607849 \ No newline at end of file diff --git a/view1090.c b/view1090.c index 47944fd..b3e8210 100644 --- a/view1090.c +++ b/view1090.c @@ -358,7 +358,7 @@ int main(int argc, char **argv) { } modesReadFromClient(c,"",decodeBinMessage); - usleep(10000); + //usleep(10000); } // The user has stopped us, so close any socket we opened diff --git a/view1090.o.REMOVED.git-id b/view1090.o.REMOVED.git-id index c48ad66..56946c2 100644 --- a/view1090.o.REMOVED.git-id +++ b/view1090.o.REMOVED.git-id @@ -1 +1 @@ -188de208d70a8a746cda5dd29c243ac3053a9c0c \ No newline at end of file +790297577270307a97648484360f0eeb3de83233 \ No newline at end of file