ref: b6499d0a18497fdd23c6188b54d4191f3b670f40
parent: d46e117f8ab7823ffb1a2fa07dc29622e00ff4fc
author: LTCHIPS <ltchips994@gmail.com>
date: Fri Apr 27 12:37:51 EDT 2018
started attempting a rewrite of rotate buffer stuff
--- a/rott/Makefile
+++ b/rott/Makefile
@@ -14,7 +14,7 @@
# Regular build flags and rules
-CC ?= gcc
+CC ?= gccs
CFLAGS ?= -g -O2
CFLAGS += -Wall -Wno-unused
@@ -29,6 +29,7 @@
LDLIBS += $(shell sdl2-config --libs)
LDLIBS += -lSDL2_mixer
+LDLIBS += -lSDL2_gfx
LDLIBS += $(EXTRALDLIBS)
OBJS :=
--- a/rott/modexlib.c
+++ b/rott/modexlib.c
@@ -44,6 +44,7 @@
#include "rt_view.h"
#include "queue.h"
#include "lumpy.h"
+#include "SDL2/SDL2_rotozoom.h"
//#include <SDL2/SDL_image.h>
@@ -60,6 +61,8 @@
SDL_Surface *sdl_surface = NULL;
+static SDL_Surface * sdl_zoomed_surface = NULL;
+
SDL_Window * window = NULL;
static SDL_Renderer * renderer = NULL;
@@ -453,11 +456,6 @@
SDL_SetRelativeMouseMode(SDL_TRUE);
- //SDL_WM_GrabInput(SDL_GRAB_ON);
- //SDL_WM_SetCaption ("Rise of the Triad", "ROTT");
- //SDL_ShowCursor (0);
-// sdl_surface = SDL_SetVideoMode (320, 200, 8, flags);
-
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "nearest");
if (sdl_fullscreen)
flags = SDL_WINDOW_FULLSCREEN_DESKTOP;
@@ -467,32 +465,26 @@
iGLOBAL_SCREENWIDTH, iGLOBAL_SCREENHEIGHT,
flags);
- //SDL_CreateWindowAndRenderer(iGLOBAL_SCREENWIDTH, iGLOBAL_SCREENHEIGHT, 0, &window, &renderer);
+ if (window == NULL)
+ {
+ Error ("Could not set video mode\n");
+ exit(1);
+ }
- renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
+ renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_SOFTWARE);
sdl_texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ABGR8888,
SDL_TEXTUREACCESS_STREAMING, iGLOBAL_SCREENWIDTH,
iGLOBAL_SCREENHEIGHT);
-
- //sdl_surface = SDL_SetVideoMode (iGLOBAL_SCREENWIDTH, iGLOBAL_SCREENHEIGHT, 8, flags);
sdl_surface = SDL_CreateRGBSurface(0,iGLOBAL_SCREENWIDTH,iGLOBAL_SCREENHEIGHT,8,0,0,0,0);
+
+
SDL_SetSurfaceRLE(sdl_surface, 1);
SDL_RenderSetLogicalSize(renderer, iGLOBAL_SCREENWIDTH, iGLOBAL_SCREENHEIGHT);
- //sdl_draw_obj_queue = malloc(sizeof(Queue));
-
- //queueInit(sdl_draw_obj_queue, sizeof(SDLDrawObj));
-
- //ToggleFullscreen();
- if (window == NULL)
- {
- Error ("Could not set video mode\n");
- }
-
}
/*
@@ -927,6 +919,7 @@
page3start = sdl_surface->pixels;
StretchScreen = 0;
SDL_RenderSetLogicalSize(renderer, iGLOBAL_SCREENWIDTH, iGLOBAL_SCREENHEIGHT);
+ //SDL_RenderSetLogicalSize(renderer, 320, 200);
}
@@ -1039,6 +1032,81 @@
}
}
+
+}
+
+
+
+void FlipPageRotoZoom (int angle, int zoom )
+{
+ //SDL_RenderSetIntegerScale(renderer, SDL_FALSE);
+
+ if (StretchScreen) { //bna++
+ StretchMemPicture ();
+ } else {
+ DrawCenterAim ();
+ }
+
+ int zoomedSurfWidth = 0;
+
+ int zoomedSurfHeight = 0;
+
+ SDL_SetRelativeMouseMode(SDL_FALSE);
+
+ //SDL_Surface * temp = SDL_ConvertSurfaceFormat(sdl_surface, SDL_PIXELFORMAT_ABGR32,0);
+
+ rotozoomSurfaceSize(sdl_surface->w, sdl_surface->h, 0, 2, &zoomedSurfWidth, &zoomedSurfHeight);
+
+ sdl_zoomed_surface = SDL_CreateRGBSurface(0,zoomedSurfWidth,zoomedSurfHeight,8,0,0,0,0);
+
+ if (sdl_zoomed_surface == NULL)
+ {
+ Error("Out of memory for rotated surface");
+ exit(1);
+
+ }
+
+ sdl_zoomed_surface = rotozoomSurface(sdl_surface, 0, 2, 0);
+
+ SDL_Texture *newTex = SDL_CreateTextureFromSurface(renderer, sdl_zoomed_surface);
+
+ if (newTex == NULL)
+ {
+ Error("CreateTextureFromSurface failed: %s \n", SDL_GetError());
+ exit(1);
+ }
+
+
+ SDL_RenderClear(renderer);
+
+ SDL_RenderCopyEx(renderer, newTex, NULL, NULL, angle, NULL, SDL_FLIP_NONE);
+
+/*
+ if (!StretchScreen && hudRescaleFactor > 1 && doRescaling)
+ {
+ if(SHOW_TOP_STATUS_BAR())
+ RescaleAreaOfTexture(renderer, newTex, (SDL_Rect) {(iGLOBAL_SCREENWIDTH - 320) >> 1, 0, 320, 16},
+ (SDL_Rect) {(iGLOBAL_SCREENWIDTH - (320 * hudRescaleFactor)) >> 1, 0, 320*hudRescaleFactor, 16*hudRescaleFactor}); //Status Bar
+ if(SHOW_BOTTOM_STATUS_BAR())
+ RescaleAreaOfTexture(renderer, newTex,(SDL_Rect) {(iGLOBAL_SCREENWIDTH - 320) >> 1, iGLOBAL_SCREENHEIGHT - 16, 320, 16},
+ (SDL_Rect) {(iGLOBAL_SCREENWIDTH - (320* hudRescaleFactor)) >> 1, iGLOBAL_SCREENHEIGHT - 16*hudRescaleFactor, 320*hudRescaleFactor, 16*hudRescaleFactor}); //Bottom Bar
+
+ }
+*/
+
+ SDL_RenderPresent(renderer);
+
+ SDL_DestroyTexture(newTex);
+
+ SDL_SetRelativeMouseMode(SDL_TRUE);
+
+ //RenderSurface();
+
+}
+
+void FreeSDLSurfaceZoom()
+{
+ SDL_FreeSurface(sdl_zoomed_surface);
}
--- a/rott/rt_draw.c
+++ b/rott/rt_draw.c
@@ -3258,6 +3258,8 @@
//
//******************************************************************************
+void FlipPageRotoZoom(int angle, int zoom);
+
void ScaleAndRotateBuffer (int startangle, int endangle, int startscale, int endscale, int time)
{
int anglestep;
@@ -3281,28 +3283,39 @@
DisableScreenStretch();//bna++
- anglestep=((endangle-startangle)<<16)/time;
- scalestep=((endscale-startscale)<<6)/time;
+ //anglestep=((endangle-startangle)<<16)/time;
+ //scalestep=((endscale-startscale)<<6)/time;
+
+ anglestep = (endangle-startangle)/time;
+ scalestep = (endscale-startscale)/time;
- angle=(startangle<<16);
+ //angle=(startangle<<16);
+
+ angle = startangle;
+
+ scale = startscale;
- scale=(startscale<<6);
+ //scale=(startscale<<6);
CalcTics();
CalcTics();
for (i=0; i<time; i+=tics)
{ //zxcv
- DrawRotatedScreen(Xh,Yh, (byte *)bufferofs,(angle>>16)&(FINEANGLES-1),scale>>6,0);
- FlipPage();
+ //DrawRotatedScreen(Xh,Yh, (byte *)bufferofs,(angle>>16)&(FINEANGLES-1),scale>>6,0);
+ FlipPageRotoZoom(angle,scale );
+
+ //FlipPage();
scale+=(scalestep*tics);
angle+=(anglestep*tics);
CalcTics();
}
+
+ FreeSDLSurfaceZoom();
DrawRotatedScreen(Xh,Yh, (byte *)bufferofs,endangle&(FINEANGLES-1),endscale,0);
- FlipPage();
+ //FlipPage();
DrawRotatedScreen(Xh,Yh, (byte *)bufferofs,endangle&(FINEANGLES-1),endscale,0);
- FlipPage();
+ //FlipPage();
DrawRotatedScreen(Xh,Yh, (byte *)bufferofs,endangle&(FINEANGLES-1),endscale,0);
CalcTics();
CalcTics();
--- a/rott/rt_game.c
+++ b/rott/rt_game.c
@@ -460,8 +460,8 @@
shape = ( pic_t * )W_CacheLumpName( "backtile", PU_CACHE, Cvt_pic_t, 1 );
- DrawTiledRegion( 0, iGLOBAL_SCREENHEIGHT - 16*hudRescaleFactor, iGLOBAL_SCREENWIDTH, 13, 10,10, shape );
- DrawTiledRegion( 0, iGLOBAL_SCREENHEIGHT - 29*hudRescaleFactor, iGLOBAL_SCREENWIDTH, 3, 10,10, shape );
+ DrawTiledRegion( 0, iGLOBAL_SCREENHEIGHT - 16*hudRescaleFactor, iGLOBAL_SCREENWIDTH, 13*hudRescaleFactor, 10,10, shape );
+ DrawTiledRegion( 0, iGLOBAL_SCREENHEIGHT - 29*hudRescaleFactor, iGLOBAL_SCREENWIDTH, 3*hudRescaleFactor, 10,10, shape );
//apparently the line below was causing segfaults on linux...
@@ -473,8 +473,6 @@
GameMemToScreen( shape, topBarCenterOffsetX, iGLOBAL_SCREENHEIGHT - 16, bufferofsonly ); //using topBarCenterOffsetX since bottbar dims == statbar dims
}
-
-
//GameMemToScreen( shape, topBarCenterOffsetX, iGLOBAL_SCREENHEIGHT - 16, bufferofsonly ); //using topBarCenterOffsetX since bottbar dims == statbar dims