ref: 5c8c5ead11772c1bceb6bab6dd5c4b5d6659a2fa
parent: fafb43915bdf355ed6abb4ca26a76daf1ae4625d
author: LTCHIPS <ltchips994@gmail.com>
date: Thu May 3 22:37:54 EDT 2018
wrote a new rotate function...but it looks like I'll need to redo the calls for it
--- a/rott/modexlib.c
+++ b/rott/modexlib.c
@@ -471,7 +471,7 @@
exit(1);
}
- renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_SOFTWARE);
+ renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
sdl_texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ABGR8888,
SDL_TEXTUREACCESS_STREAMING, iGLOBAL_SCREENWIDTH,
@@ -1035,10 +1035,78 @@
}
+extern int tics;
+void CalcTics (void);
-void FlipPageRotoZoom (int angle, int zoom )
+void DoScreenRotateZoom(int startAngle, int endAngle, float startScale, float endScale, int time)
+{
+ STUB_FUNCTION;
+
+ printf("startAngle: %d \n", startAngle);
+ printf("endAngle: %d \n", endAngle);
+ printf("startScale: %.6f \n", startScale);
+ printf("endScale: %.6f \n", endScale);
+ printf("time: %d \n", time);
+
+
+ int anglestep = (endAngle-startAngle)/time;
+ float scalestep = (float) ((endScale-startScale)/time);
+
+ //angle=(startangle<<16);
+
+ //angle = startangle<<16;
+
+ int angle = startAngle;
+
+ //scale = startscale>>16;
+
+ //scale = startscale;
+
+ float scale = startScale;
+
+ CalcTics();
+
+ int i;
+
+ for (i=0; i<time; i+=tics)
+ {
+ SDL_Texture * newTex = SDL_CreateTextureFromSurface(renderer, sdl_surface);
+
+ SDL_RenderClear(renderer);
+
+ SDL_Rect output;
+
+ output.w = iGLOBAL_SCREENWIDTH * scale;
+
+ output.h = iGLOBAL_SCREENHEIGHT * scale;
+
+ output.x = (iGLOBAL_SCREENWIDTH - output.w)/2;
+
+ output.y = (iGLOBAL_SCREENHEIGHT - output.h)/2;
+
+ SDL_RenderCopyEx(renderer, newTex, NULL, &output, angle, NULL, SDL_FLIP_NONE);
+
+ SDL_RenderPresent(renderer);
+
+ scale+=(scalestep*tics);
+ angle+=(anglestep*tics);
+ CalcTics();
+
+ SDL_DestroyTexture(newTex);
+
+ }
+
+}
+
+
+
+
+
+void FlipPageRotoZoom (int angle, int scale )
{
+ printf("Angle: %d Scale: %d \n", angle, scale);
+
//SDL_RenderSetIntegerScale(renderer, SDL_FALSE);
if (StretchScreen) { //bna++
@@ -1085,14 +1153,76 @@
SDL_RenderClear(renderer);
- SDL_RenderSetScale(renderer, (float)zoom/100, (float)zoom/100);
+ //SDL_RenderSetScale(renderer, (float)zoom/10, (float)zoom/10);
//SDL_RenderSetLogicalSize(renderer, zoomedSurfWidth, zoomedSurfHeight);
//SDL_RenderCopy(renderer, newTex, NULL, NULL);
- SDL_RenderCopyEx(renderer, newTex, NULL, NULL, angle, NULL, SDL_FLIP_NONE);
+ SDL_Point rotateAround;
+/*
+ float scalex, scaley;
+
+
+ if(zoom > 0)
+ {
+ rotateAround.x = (int) ((iGLOBAL_SCREENWIDTH/2)*(scalex));
+ rotateAround.y = (int) ((iGLOBAL_SCREENHEIGHT/2)*(scaley));
+ }
+ else
+ {
+ rotateAround.x = iGLOBAL_SCREENWIDTH/2;
+ rotateAround.y = iGLOBAL_SCREENHEIGHT/2;
+ }
+*/
+ //SDL_RenderGetScale(renderer, &scalex, &scaley);
+
+ //rotateAround.x = (int) ((iGLOBAL_SCREENWIDTH/2)*(scalex));
+ //rotateAround.y = (int) ((iGLOBAL_SCREENHEIGHT/2)*(scaley));
+
+ SDL_Rect dest;
+
+ //SDL_RenderSetLogicalSize(renderer, dest.w, dest.h);
+
+ if (scale > 0)
+ {
+ dest.w = (int) (iGLOBAL_SCREENWIDTH/scale);
+ dest.h = (int) (iGLOBAL_SCREENHEIGHT/scale);
+ }
+ else
+ {
+ dest.w = iGLOBAL_SCREENWIDTH;
+ dest.h = iGLOBAL_SCREENHEIGHT;
+ //dest.x = iGLOBAL_SCREENWIDTH - dest.w;
+ //dest.y = iGLOBAL_SCREENHEIGHT - dest.h;
+
+
+ }
+
+ SDL_RenderSetLogicalSize(renderer, dest.w, dest.h);
+
+ dest.x = 0;
+ dest.y = 0;
+/*
+
+ center.x = rect.w * 0.5;
+center.y = rect.h - ( rect.w * 0.5 );
+*/
+
+
+
+ //SDL_RenderCopyEx(renderer, newTex, NULL, &dest, angle, &(SDL_Rect) {dest.w/2, dest.h/2} , SDL_FLIP_NONE);
+
+ if(SDL_RenderCopyEx(renderer, newTex, NULL, &dest, angle, &(SDL_Rect) {dest.w/2, dest.h}, SDL_FLIP_NONE) == -1)
+ {
+ printf("SDL_RenderCopyEx failed: %s \n", SDL_GetError());
+ exit(1);
+
+
+ }
+
+
SDL_RenderPresent(renderer);
SDL_DestroyTexture(newTex);
@@ -1108,7 +1238,7 @@
void FreeSDLSurfaceZoom()
{
- SDL_RenderSetScale(renderer, 1, 1);
+ //SDL_RenderSetScale(renderer, 1, 1);
/*
SDL_RenderSetLogicalSize(renderer, iGLOBAL_SCREENWIDTH, iGLOBAL_SCREENHEIGHT);
--- a/rott/rt_draw.c
+++ b/rott/rt_draw.c
@@ -3286,16 +3286,18 @@
//anglestep=((endangle-startangle)<<16)/time;
//scalestep=((endscale-startscale)<<6)/time;
- anglestep = (endangle-startangle)/time;
- scalestep = (endscale-startscale)/time;
+ anglestep = (endangle-startangle)<<16/time;
+ scalestep = (endscale-startscale)<<6/time;
//angle=(startangle<<16);
- angle = startangle;
+ angle = startangle<<16;
- scale = startscale>>16;
+ //scale = startscale>>16;
+
+ //scale = startscale;
- //scale=(startscale<<6);
+ scale=(startscale>>6);
CalcTics();
CalcTics();
@@ -3304,7 +3306,7 @@
for (i=0; i<time; i+=tics)
{ //zxcv
//DrawRotatedScreen(Xh,Yh, (byte *)bufferofs,(angle>>16)&(FINEANGLES-1),scale>>6,0);
- FlipPageRotoZoom((angle), scale);
+ FlipPageRotoZoom(angle, scale);
//FlipPage();
scale+=(scalestep*tics);
@@ -3345,6 +3347,8 @@
extern boolean skipRotate;
+void DoScreenRotateZoom(int startAngle, int endAngle, float startScale, float endScale, int time);
+
void RotateBuffer (int startangle, int endangle, int startscale, int endscale, int time)
{
int savetics;
@@ -3352,12 +3356,17 @@
//save off fastcounter
savetics=GetFastTics();
+
+ printf("%d \n", startscale);
+ printf("%d \n", endscale);
- StartupRotateBuffer (0);
+ //StartupRotateBuffer (0);
+
+ DoScreenRotateZoom(startangle, endangle, startscale, endscale, time);
- ScaleAndRotateBuffer (startangle, endangle, startscale, endscale, time);
+ //ScaleAndRotateBuffer (startangle, endangle, startscale, endscale, time);
- ShutdownRotateBuffer ();
+ //ShutdownRotateBuffer ();
// restore fast counter
SetFastTics(savetics);