Gfx engine changes: always 32bpp internally (facilitates alpha channel usage), optimized and asm scaler code, only using alpha channel where needed (speed gain)

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1964 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
avolkov
2005-11-07 21:22:53 +00:00
parent 39618a5ad9
commit 412e962074
16 changed files with 644 additions and 3353 deletions
+129 -24
View File
@@ -4,7 +4,7 @@
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=UrQuanMasters - Win32 Debug
CFG=URQUANMASTERS - WIN32 DEBUG
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
@@ -13,19 +13,20 @@ CFG=UrQuanMasters - Win32 Debug
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "UrQuanMasters.mak" CFG="UrQuanMasters - Win32 Debug"
!MESSAGE NMAKE /f "UrQuanMasters.mak" CFG="URQUANMASTERS - WIN32 DEBUG"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "UrQuanMasters - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "UrQuanMasters - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE "UrQuanMasters - Win32 Release NoAL" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
CPP=xicl6.exe
RSC=rc.exe
!IF "$(CFG)" == "UrQuanMasters - Win32 Release"
@@ -42,14 +43,14 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "." /I ".." /I "..\sc2code" /I "..\sc2code\libs" /I "..\sc2code\ships" /I "..\regex" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D _VW=320 /D _VH=240 /D "HAVE_OPENGL" /D "GFXMODULE_SDL" /D "HAVE_OPENAL" /D "HAVE_ZIP" /D "ZLIB_DLL" /FD /c
# ADD CPP /nologo /G6 /MD /W3 /GX /Zi /O2 /I "." /I ".." /I "..\sc2code" /I "..\sc2code\libs" /I "..\sc2code\ships" /I "..\regex" /D "NDEBUG" /D "USE_PLATFORM_ACCEL" /D "USE_DEBUG_KEY" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D _VW=320 /D _VH=240 /D "HAVE_OPENGL" /D "GFXMODULE_SDL" /D "HAVE_OPENAL" /D "HAVE_ZIP" /D "ZLIB_DLL" /FD /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
LINK32=xilink6.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib SDL.lib SDLmain.lib SDL_image.lib zdll.lib /nologo /subsystem:console /pdb:none /debug /machine:I386 /nodefaultlib:"msvcrtd.lib" /out:"../../uqm.exe"
# Begin Special Build Tool
@@ -72,24 +73,57 @@ PostBuild_Cmds=rebase -b 0x400000 -x . "../../uqm.exe"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /GX /Zi /Od /I "." /I ".." /I "..\sc2code" /I "..\sc2code\libs" /I "..\sc2code\ships" /I "..\regex" /D "DEBUG" /D "_DEBUG" /D "DEBUG_TRACK_SEM" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D _VW=320 /D _VH=240 /D "HAVE_OPENGL" /D "GFXMODULE_SDL" /D "HAVE_OPENAL" /D "HAVE_ZIP" /D "ZLIB_DLL" /FR /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /GX /Zi /Od /I "." /I ".." /I "..\sc2code" /I "..\sc2code\libs" /I "..\sc2code\ships" /I "..\regex" /D "DEBUG" /D "_DEBUG" /D "DEBUG_TRACK_SEM" /D "USE_PLATFORM_ACCEL" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D _VW=320 /D _VH=240 /D "HAVE_OPENGL" /D "GFXMODULE_SDL" /D "HAVE_OPENAL" /D "HAVE_ZIP" /D "ZLIB_DLL" /FR /FD /GZ /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo /o"UrQuanMasters.bsc"
LINK32=link.exe
LINK32=xilink6.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib SDL.lib SDLmain.lib SDL_image.lib zdll.lib /nologo /subsystem:console /debug /machine:I386 /nodefaultlib:"msvcrt.lib" /out:"../../uqmdebug.exe" /pdbtype:sept
# SUBTRACT LINK32 /nodefaultlib
!ELSEIF "$(CFG)" == "UrQuanMasters - Win32 Release NoAL"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "UrQuanMasters___Win32_Release_NoAL"
# PROP BASE Intermediate_Dir "UrQuanMasters___Win32_Release_NoAL"
# PROP BASE Ignore_Export_Lib 0
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release_NoAL"
# PROP Intermediate_Dir "Release_NoAL"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MD /W3 /GX /Zi /O2 /I "." /I ".." /I "..\sc2code" /I "..\sc2code\libs" /I "..\sc2code\ships" /I "..\regex" /D "NDEBUG" /D "USE_PLATFORM_ACCEL" /D "USE_DEBUG_KEY" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D _VW=320 /D _VH=240 /D "HAVE_OPENGL" /D "GFXMODULE_SDL" /D "HAVE_OPENAL" /D "HAVE_ZIP" /D "ZLIB_DLL" /FD /c
# SUBTRACT BASE CPP /YX
# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "." /I ".." /I "..\sc2code" /I "..\sc2code\libs" /I "..\sc2code\ships" /I "..\regex" /D "NDEBUG" /D "USE_PLATFORM_ACCEL" /D "USE_DEBUG_KEY" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D _VW=320 /D _VH=240 /D "HAVE_OPENGL" /D "GFXMODULE_SDL" /D "HAVE_ZIP" /D "ZLIB_DLL" /FD /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=xilink6.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib SDL.lib SDLmain.lib SDL_image.lib zdll.lib /nologo /subsystem:console /pdb:none /debug /machine:I386 /nodefaultlib:"msvcrtd.lib" /out:"../../uqm.exe"
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib SDL.lib SDLmain.lib SDL_image.lib zdll.lib /nologo /subsystem:console /pdb:none /debug /machine:I386 /nodefaultlib:"msvcrtd.lib" /out:"../../uqm.exe"
# Begin Special Build Tool
SOURCE="$(InputPath)"
PostBuild_Desc=Stripping debug info...
PostBuild_Cmds=rebase -b 0x400000 -x . "../../uqm.exe"
# End Special Build Tool
!ENDIF
# Begin Target
# Name "UrQuanMasters - Win32 Release"
# Name "UrQuanMasters - Win32 Debug"
# Name "UrQuanMasters - Win32 Release NoAL"
# Begin Group "Source Files"
# PROP Default_Filter ""
@@ -186,10 +220,6 @@ SOURCE=..\sc2code\libs\file\temp.c
# Begin Group "graphics"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\sc2code\libs\graphics\prim.h
# End Source File
# Begin Group "sdl"
# PROP Default_Filter ""
@@ -203,6 +233,22 @@ SOURCE=..\sc2code\libs\graphics\sdl\2xscalers.h
# End Source File
# Begin Source File
SOURCE=..\sc2code\libs\graphics\sdl\2xscalers_3dnow.c
# End Source File
# Begin Source File
SOURCE=..\sc2code\libs\graphics\sdl\2xscalers_mmx.c
# End Source File
# Begin Source File
SOURCE=..\sc2code\libs\graphics\sdl\2xscalers_mmx.h
# End Source File
# Begin Source File
SOURCE=..\sc2code\libs\graphics\sdl\2xscalers_sse.c
# End Source File
# Begin Source File
SOURCE=..\sc2code\libs\graphics\sdl\3do_blt.c
# End Source File
# Begin Source File
@@ -223,6 +269,14 @@ SOURCE=..\sc2code\libs\graphics\sdl\bbox.h
# End Source File
# Begin Source File
SOURCE=..\sc2code\libs\graphics\sdl\biadv2x.c
# End Source File
# Begin Source File
SOURCE=..\sc2code\libs\graphics\sdl\bilinear2x.c
# End Source File
# Begin Source File
SOURCE=..\sc2code\libs\graphics\sdl\canvas.c
# End Source File
# Begin Source File
@@ -231,6 +285,14 @@ SOURCE=..\sc2code\libs\graphics\sdl\dcqueue.c
# End Source File
# Begin Source File
SOURCE=..\sc2code\libs\graphics\sdl\hq2x.c
# End Source File
# Begin Source File
SOURCE=..\sc2code\libs\graphics\sdl\nearest2x.c
# End Source File
# Begin Source File
SOURCE=..\sc2code\libs\graphics\sdl\opengl.c
# End Source File
# Begin Source File
@@ -259,11 +321,27 @@ SOURCE=..\sc2code\libs\graphics\sdl\rndzoom.c
# End Source File
# Begin Source File
SOURCE=..\sc2code\libs\graphics\sdl\rotozoom.c
# End Source File
# Begin Source File
SOURCE=..\sc2code\libs\graphics\sdl\rotozoom.h
# End Source File
# Begin Source File
SOURCE=..\sc2code\libs\graphics\sdl\rotozoom.c
SOURCE=..\sc2code\libs\graphics\sdl\scaleint.h
# End Source File
# Begin Source File
SOURCE=..\sc2code\libs\graphics\sdl\scalemmx.h
# End Source File
# Begin Source File
SOURCE=..\sc2code\libs\graphics\sdl\scalers.c
# End Source File
# Begin Source File
SOURCE=..\sc2code\libs\graphics\sdl\scalers.h
# End Source File
# Begin Source File
@@ -281,6 +359,10 @@ SOURCE=..\sc2code\libs\graphics\sdl\sdluio.c
SOURCE=..\sc2code\libs\graphics\sdl\sdluio.h
# End Source File
# Begin Source File
SOURCE=..\sc2code\libs\graphics\sdl\triscan2x.c
# End Source File
# End Group
# Begin Source File
@@ -368,6 +450,10 @@ SOURCE=..\sc2code\libs\graphics\pixmap.c
# End Source File
# Begin Source File
SOURCE=..\sc2code\libs\graphics\prim.h
# End Source File
# Begin Source File
SOURCE=..\sc2code\libs\graphics\resgfx.c
# End Source File
# Begin Source File
@@ -952,6 +1038,11 @@ SOURCE=..\sc2code\libs\uio\debug.c
!ELSEIF "$(CFG)" == "UrQuanMasters - Win32 Debug"
!ELSEIF "$(CFG)" == "UrQuanMasters - Win32 Release NoAL"
# PROP BASE Exclude_From_Build 1
# PROP Exclude_From_Build 1
!ENDIF
# End Source File
@@ -1003,6 +1094,11 @@ SOURCE=..\sc2code\libs\uio\hashtable.c
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "UrQuanMasters - Win32 Release NoAL"
# PROP BASE Exclude_From_Build 1
# PROP Exclude_From_Build 1
!ENDIF
# End Source File
@@ -1054,6 +1150,11 @@ SOURCE=..\sc2code\libs\uio\memdebug.c
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "UrQuanMasters - Win32 Release NoAL"
# PROP BASE Exclude_From_Build 1
# PROP Exclude_From_Build 1
!ENDIF
# End Source File
@@ -1160,6 +1261,10 @@ SOURCE=..\sc2code\libs\misc.h
# End Source File
# Begin Source File
SOURCE=..\sc2code\libs\platform.h
# End Source File
# Begin Source File
SOURCE=..\sc2code\libs\reslib.h
# End Source File
# Begin Source File
@@ -1338,10 +1443,6 @@ SOURCE=..\sc2code\comm\comandr\restypes.h
SOURCE=..\sc2code\comm\comandr\strings.h
# End Source File
# End Group
# Begin Source File
SOURCE=..\sc2code\comm\commall.h
# End Source File
# Begin Group "druuge.comm"
# PROP Default_Filter ""
@@ -2102,6 +2203,10 @@ SOURCE=..\sc2code\comm\zoqfot\strings.h
SOURCE=..\sc2code\comm\zoqfot\zoqfotc.c
# End Source File
# End Group
# Begin Source File
SOURCE=..\sc2code\comm\commall.h
# End Source File
# End Group
# Begin Group "planets"
@@ -2306,10 +2411,6 @@ SOURCE=..\sc2code\planets\surface.c
# Begin Group "ships"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\sc2code\ships\ship.h
# End Source File
# Begin Group "androsyn"
# PROP Default_Filter ""
@@ -3314,6 +3415,10 @@ SOURCE=..\sc2code\ships\zoqfot\restypes.h
SOURCE=..\sc2code\ships\zoqfot\zoqfot.c
# End Source File
# End Group
# Begin Source File
SOURCE=..\sc2code\ships\ship.h
# End Source File
# End Group
# Begin Source File
@@ -3709,10 +3814,6 @@ SOURCE=..\sc2code\starbase.c
# End Source File
# Begin Source File
SOURCE=..\sc2code\strtemp.h
# End Source File
# Begin Source File
SOURCE=..\sc2code\starbase.h
# End Source File
# Begin Source File
@@ -3741,6 +3842,10 @@ SOURCE=..\sc2code\status.c
# End Source File
# Begin Source File
SOURCE=..\sc2code\strtemp.h
# End Source File
# Begin Source File
SOURCE=..\sc2code\tactrans.c
# End Source File
# Begin Source File
+1
View File
@@ -52,6 +52,7 @@ typedef BYTE CREATE_FLAGS;
#define WANT_MASK (CREATE_FLAGS)(1 << 0)
#define WANT_PIXMAP (CREATE_FLAGS)(1 << 1)
#define MAPPED_TO_DISPLAY (CREATE_FLAGS)(1 << 2)
#define WANT_ALPHA (CREATE_FLAGS)(1 << 3)
typedef struct extent
{
+2 -1
View File
@@ -123,7 +123,8 @@ CreateDrawable (CREATE_FLAGS CreateFlags, SIZE width, SIZE height, COUNT
Drawable = _request_drawable (
(COUNT)num_frames, (DRAWABLE_TYPE)RAM_DRAWABLE,
(CREATE_FLAGS)(CreateFlags & (WANT_MASK | WANT_PIXMAP | MAPPED_TO_DISPLAY)),
(CREATE_FLAGS)(CreateFlags & (WANT_MASK | WANT_PIXMAP
| WANT_ALPHA | MAPPED_TO_DISPLAY)),
(SIZE)width, (SIZE)height
);
if (Drawable)
File diff suppressed because it is too large Load Diff
@@ -1,4 +1,3 @@
//Copyright Paul Reiche, Fred Ford. 1992-2002
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -18,11 +17,14 @@
#ifndef _2XSCALERS_H_
#define _2XSCALERS_H_
void Scale_PrepYUV (void);
void Scale_Nearest (SDL_Surface *src, SDL_Surface *dst, SDL_Rect *r);
void Scale_BilinearFilter (SDL_Surface *src, SDL_Surface *dst, SDL_Rect *r);
void Scale_BiAdaptFilter (SDL_Surface *src, SDL_Surface *dst, SDL_Rect *r);
void Scale_BiAdaptAdvFilter (SDL_Surface *src, SDL_Surface *dst, SDL_Rect *r);
void Scale_TriScanFilter (SDL_Surface *src, SDL_Surface *dst, SDL_Rect *r);
void Scale_HqFilter (SDL_Surface *src, SDL_Surface *dst, SDL_Rect *r);
#endif
extern const Scale_FuncDef_t Scale_C_Functions[];
#endif /* _2XSCALERS_H_ */
@@ -388,6 +388,7 @@ FRAMEPTR Build_Font_Effect (FRAMEPTR FramePtr, Uint32 from, Uint32 to, BYTE type
to_a = to & 0xFF;
clear = SDL_MapRGBA (img->format, 0, 0, 0, 0);
TFB_DrawCanvas_SetTransparentColor (img, 0, 0, 0, FALSE);
for (y = 0; y < 2; y++)
for (x = 0; x < width; x++)
putpix (img, x, y, clear);
@@ -842,7 +843,8 @@ _request_drawable (COUNT NumFrames, DRAWABLE_TYPE DrawableType,
TFB_Image *Image;
if (DrawableType == RAM_DRAWABLE && imgw > 0 && imgh > 0
&& (Image = TFB_DrawImage_New (TFB_DrawCanvas_New_TrueColor (imgw, imgh, FALSE))))
&& (Image = TFB_DrawImage_New (TFB_DrawCanvas_New_TrueColor (
imgw, imgh, (flags & WANT_ALPHA) ? TRUE : FALSE))))
{
FramePtr->image = Image;
}
+4 -1
View File
@@ -1,3 +1,6 @@
uqm_CFILES="3do_blt.c 3do_funcs.c 3do_getbody.c dcqueue.c opengl.c
primitives.c pure.c rndzoom.c sdl_common.c
canvas.c bbox.c 2xscalers.c sdluio.c rotozoom.c"
scalers.c 2xscalers.c
2xscalers_mmx.c 2xscalers_sse.c 2xscalers_3dnow.c
nearest2x.c bilinear2x.c biadv2x.c triscan2x.c hq2x.c
canvas.c bbox.c sdluio.c rotozoom.c"
+22 -10
View File
@@ -154,7 +154,11 @@ TFB_Canvas
TFB_DrawCanvas_New_TrueColor (int w, int h, BOOLEAN hasalpha)
{
SDL_Surface *new_surf;
new_surf = SDL_CreateRGBSurface (SDL_SWSURFACE, w, h, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, hasalpha ? 0xff000000 : 0);
SDL_PixelFormat* fmt = format_conv_surf->format;
new_surf = SDL_CreateRGBSurface (SDL_SWSURFACE, w, h,
fmt->BitsPerPixel, fmt->Rmask, fmt->Gmask, fmt->Bmask,
hasalpha ? fmt->Amask : 0);
if (!new_surf) {
fprintf(stderr, "INTERNAL PANIC: Failed to create TFB_Canvas: %s", SDL_GetError());
exit(-1);
@@ -173,12 +177,13 @@ TFB_DrawCanvas_New_ForScreen (int w, int h, BOOLEAN withalpha)
fprintf(stderr, "TFB_DrawCanvas_New_ForScreen() WARNING:"
"Paletted display format will be slow");
new_surf = SDL_CreateRGBSurface (SDL_SWSURFACE, w, h,
32, 0x000000ff, 0x0000ff00, 0x00ff0000,
withalpha ? 0xff000000 : 0);
new_surf = TFB_DrawCanvas_New_TrueColor (w, h, withalpha);
}
else
{
if (withalpha && fmt->Amask == 0)
fmt = format_conv_surf->format; // Screen has no alpha and we need it
new_surf = SDL_CreateRGBSurface (SDL_SWSURFACE, w, h,
fmt->BitsPerPixel, fmt->Rmask, fmt->Gmask, fmt->Bmask,
withalpha ? fmt->Amask : 0);
@@ -259,8 +264,10 @@ TFB_DrawCanvas_New_ScaleTarget (TFB_Canvas canvas, TFB_Canvas oldcanvas, int typ
}
if (!old)
{
newsurf = SDL_CreateRGBSurface (SDL_SWSURFACE, src->w, src->h, 32,
0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000);
if (SDL_Screen->format->BitsPerPixel == 32)
newsurf = TFB_DrawCanvas_New_ForScreen (src->w, src->h, TRUE);
else
newsurf = TFB_DrawCanvas_New_TrueColor (src->w, src->h, TRUE);
}
}
@@ -348,8 +355,12 @@ TFB_DrawCanvas_ToScreenFormat (TFB_Canvas canvas)
fprintf (stderr, "WARNING: Could not convert sprite-canvas to display format.\n");
return canvas;
}
else if (result == canvas)
{ // no conversion was necessary
return canvas;
}
else
{
{ // converted
TFB_DrawCanvas_Delete (canvas);
return result;
}
@@ -590,7 +601,8 @@ TFB_DrawCanvas_Rescale_Trilinear (TFB_Canvas src_canvas, TFB_Canvas dest_canvas,
SDL_Surface *dst = (SDL_Surface *)dest_canvas;
SDL_Surface *mipmap = (SDL_Surface *)src_mipmap;
SDL_PixelFormat *dstfmt = dst->format;
const int dstopaque = 0xff << dstfmt->Ashift;
const int dstopaque = dstfmt->Amask;
const int dsttransparent = (dst->flags & SDL_SRCCOLORKEY) ? dstfmt->colorkey : 0;
const int w = size.width, h = size.height;
const int ALPHA_THRESHOLD = 128;
@@ -785,7 +797,7 @@ TFB_DrawCanvas_Rescale_Trilinear (TFB_Canvas src_canvas, TFB_Canvas dest_canvas,
}
else
{
*dst_p++ = 0;
*dst_p++ = dsttransparent;
}
sx0 += fsx0;
@@ -985,7 +997,7 @@ TFB_DrawCanvas_Rescale_Trilinear (TFB_Canvas src_canvas, TFB_Canvas dest_canvas,
}
else
{
*dst_p++ = 0;
*dst_p++ = dsttransparent;
}
sx0 += fsx0;
+60 -95
View File
@@ -20,18 +20,18 @@
#include "libs/graphics/sdl/opengl.h"
#include "bbox.h"
#include "2xscalers.h"
#include "scalers.h"
static SDL_Surface *format_conv_surf = NULL;
static SDL_Surface *scaled_display = NULL;
static SDL_Surface *scaled_transition = NULL;
static int ScreenFilterMode;
static GLuint DisplayTexture;
static GLuint TransitionTexture;
static BOOLEAN scanlines;
static BOOLEAN upload_transitiontexture = FALSE;
static TFB_ScaleFunc scaler = NULL;
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
#define R_MASK 0xff000000
#define G_MASK 0x00ff0000
@@ -46,16 +46,26 @@ static BOOLEAN upload_transitiontexture = FALSE;
static SDL_Surface *
Create_Screen (void)
Create_Screen (SDL_Surface *template, int w, int h)
{
SDL_Surface *result = SDL_CreateRGBSurface(SDL_SWSURFACE, ScreenWidth, ScreenHeight, 32,
R_MASK, G_MASK, B_MASK, 0x00000000);
if (result == NULL)
{
fprintf (stderr, "Couldn't create screen buffer: %s\n", SDL_GetError());
exit (-1);
SDL_Surface *newsurf = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h,
template->format->BitsPerPixel,
template->format->Rmask, template->format->Gmask,
template->format->Bmask, 0);
if (newsurf == 0) {
fprintf (stderr, "Couldn't create screen buffers: %s\n", SDL_GetError());
}
return result;
return newsurf;
}
static int
ReInit_Screen (SDL_Surface **screen, SDL_Surface *template, int w, int h)
{
if (*screen)
SDL_FreeSurface (*screen);
*screen = Create_Screen (template, w, h);
return *screen == 0 ? -1 : 0;
}
int
@@ -122,48 +132,9 @@ TFB_GL_ConfigureVideo (int driver, int flags, int width, int height, int bpp)
glGetString (GL_RENDERER), glGetString (GL_VERSION));
}
if (GfxFlags & TFB_GFXFLAGS_SCALE_SOFT_ONLY)
{
if (scaled_display)
{
SDL_FreeSurface (scaled_display);
scaled_display = NULL;
}
scaled_display = SDL_CreateRGBSurface(SDL_SWSURFACE, ScreenWidth * 2,
ScreenHeight * 2, 32, R_MASK, G_MASK, B_MASK, 0x00000000);
if (scaled_display == NULL)
{
fprintf (stderr, "Couldn't create scaled_display: %s\n", SDL_GetError());
return -1;
}
if (scaled_transition)
{
SDL_FreeSurface (scaled_transition);
scaled_transition = NULL;
}
scaled_transition = SDL_CreateRGBSurface(SDL_SWSURFACE, ScreenWidth * 2,
ScreenHeight * 2, 32, R_MASK, G_MASK, B_MASK, 0x00000000);
if (scaled_transition == NULL)
{
fprintf (stderr, "Couldn't create scaled_transition: %s\n", SDL_GetError());
return -1;
}
texture_width = 1024;
texture_height = 512;
}
else
{
texture_width = 512;
texture_height = 256;
}
if (format_conv_surf)
{
SDL_FreeSurface (format_conv_surf);
format_conv_surf = NULL;
}
format_conv_surf = SDL_CreateRGBSurface(SDL_SWSURFACE, 0, 0, 32,
format_conv_surf = SDL_CreateRGBSurface (SDL_SWSURFACE, 0, 0, 32,
R_MASK, G_MASK, B_MASK, A_MASK);
if (format_conv_surf == NULL)
{
@@ -171,25 +142,44 @@ TFB_GL_ConfigureVideo (int driver, int flags, int width, int height, int bpp)
return -1;
}
if (GfxFlags & TFB_GFXFLAGS_SCALE_ANY)
ScreenFilterMode = GL_LINEAR;
else
ScreenFilterMode = GL_NEAREST;
if (flags & TFB_GFXFLAGS_SCANLINES)
scanlines = TRUE;
else
scanlines = FALSE;
/* TODO: This leaks */
for (i = 0; i < TFB_GFX_NUMSCREENS; i++)
{
SDL_Screens[i] = Create_Screen ();
if (0 != ReInit_Screen (&SDL_Screens[i], format_conv_surf,
ScreenWidth, ScreenHeight))
return -1;
}
SDL_Screen = SDL_Screens[0];
TransitionScreen = SDL_Screens[2];
if (GfxFlags & TFB_GFXFLAGS_SCALE_SOFT_ONLY)
{
if (0 != ReInit_Screen (&scaled_display, format_conv_surf,
ScreenWidth * 2, ScreenHeight * 2))
return -1;
if (0 != ReInit_Screen (&scaled_transition, format_conv_surf,
ScreenWidth * 2, ScreenHeight * 2))
return -1;
texture_width = 1024;
texture_height = 512;
scaler = Scale_PrepPlatform (flags, SDL_Screen->format);
}
else
{
texture_width = 512;
texture_height = 256;
scaler = NULL;
}
if (GfxFlags & TFB_GFXFLAGS_SCALE_ANY)
ScreenFilterMode = GL_LINEAR;
else
ScreenFilterMode = GL_NEAREST;
glViewport (0, 0, ScreenWidthActual, ScreenHeightActual);
glClearColor (0,0,0,0);
glClear (GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
@@ -236,8 +226,8 @@ TFB_GL_InitGraphics (int driver, int flags, int width, int height, int bpp)
exit (-1);
}
// pre-compute the RGB->YUV transformations
Scale_PrepYUV();
// Initialize scalers (let them precompute whatever)
Scale_Init ();
return 0;
}
@@ -322,14 +312,9 @@ TFB_GL_SwapBuffers (int force_full_redraw)
updated.w = TFB_BBox.region.extent.width;
updated.h = TFB_BBox.region.extent.height;
if (GfxFlags & TFB_GFXFLAGS_SCALE_SOFT_ONLY)
if (scaler)
{
if (GfxFlags & TFB_GFXFLAGS_SCALE_BIADAPT)
Scale_BiAdaptFilter (SDL_Screen, scaled_display, &updated);
else if (GfxFlags & TFB_GFXFLAGS_SCALE_BIADAPTADV)
Scale_BiAdaptAdvFilter (SDL_Screen, scaled_display, &updated);
else if (GfxFlags & TFB_GFXFLAGS_SCALE_TRISCAN)
Scale_TriScanFilter (SDL_Screen, scaled_display, &updated);
scaler (SDL_Screen, scaled_display, &updated);
glPixelStorei (GL_UNPACK_ROW_LENGTH, ScreenWidth * 2);
glPixelStorei (GL_UNPACK_SKIP_ROWS, updated.y * 2);
@@ -362,18 +347,14 @@ TFB_GL_SwapBuffers (int force_full_redraw)
if (upload_transitiontexture)
{
if (GfxFlags & TFB_GFXFLAGS_SCALE_SOFT_ONLY)
if (scaler)
{
SDL_Rect r;
r.x = r.y = 0;
r.w = ScreenWidth;
r.h = ScreenHeight;
if (GfxFlags & TFB_GFXFLAGS_SCALE_BIADAPT)
Scale_BiAdaptFilter (TransitionScreen, scaled_transition, &r);
else if (GfxFlags & TFB_GFXFLAGS_SCALE_BIADAPTADV)
Scale_BiAdaptAdvFilter (TransitionScreen, scaled_transition, &r);
else if (GfxFlags & TFB_GFXFLAGS_SCALE_TRISCAN)
Scale_TriScanFilter (TransitionScreen, scaled_transition, &r);
scaler (TransitionScreen, scaled_transition, &r);
glPixelStorei (GL_UNPACK_ROW_LENGTH, ScreenWidth * 2);
glPixelStorei (GL_UNPACK_SKIP_ROWS, 0);
@@ -441,20 +422,4 @@ TFB_GL_SwapBuffers (int force_full_redraw)
SDL_GL_SwapBuffers ();
}
SDL_Surface*
TFB_GL_DisplayFormatAlpha (SDL_Surface *surface)
{
SDL_Surface* newsurf;
newsurf = SDL_ConvertSurface (surface, format_conv_surf->format, surface->flags);
// SDL_SRCCOLORKEY and SDL_SRCALPHA cannot work at the same time,
// so we need to disable one of them
if ((surface->flags & SDL_SRCCOLORKEY) && newsurf
&& (newsurf->flags & SDL_SRCCOLORKEY)
&& (newsurf->flags & SDL_SRCALPHA))
SDL_SetAlpha (newsurf, 0, 255);
return newsurf;
}
#endif
@@ -25,7 +25,6 @@ int TFB_GL_InitGraphics (int driver, int flags, int width, int height, int bpp);
int TFB_GL_ConfigureVideo (int driver, int flags, int width, int height, int bpp);
void TFB_GL_UploadTransitionScreen (void);
void TFB_GL_SwapBuffers (int force_full_redraw);
SDL_Surface* TFB_GL_DisplayFormatAlpha (SDL_Surface *surface);
#ifdef HAVE_OPENGL
+152 -124
View File
@@ -19,28 +19,43 @@
#include "pure.h"
#include "bbox.h"
#include "2xscalers.h"
#include "scalers.h"
static SDL_Surface *fade_black = NULL;
static SDL_Surface *fade_white = NULL;
static SDL_Surface *fade_temp = NULL;
static SDL_Surface *scaled_display = NULL;
static TFB_ScaleFunc scaler = NULL;
static SDL_Surface *
Create_Screen (SDL_Surface *template)
Create_Screen (SDL_Surface *template, int w, int h)
{
SDL_Surface *newsurf = SDL_DisplayFormat (template);
SDL_Surface *newsurf = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h,
template->format->BitsPerPixel,
template->format->Rmask, template->format->Gmask,
template->format->Bmask, 0);
if (newsurf == 0) {
fprintf (stderr, "Couldn't create screen buffers: %s\n", SDL_GetError());
exit(-1);
}
return newsurf;
}
static int
ReInit_Screen (SDL_Surface **screen, SDL_Surface *template, int w, int h)
{
if (*screen)
SDL_FreeSurface (*screen);
*screen = Create_Screen (template, w, h);
return *screen == 0 ? -1 : 0;
}
int
TFB_Pure_ConfigureVideo (int driver, int flags, int width, int height, int bpp)
{
int i, videomode_flags;
SDL_Surface *test_extra;
SDL_Surface *temp_surf;
GraphicsDriver = driver;
ScreenColorDepth = bpp;
@@ -83,51 +98,67 @@ TFB_Pure_ConfigureVideo (int driver, int flags, int width, int height, int bpp)
SDL_GetVideoSurface()->format->BitsPerPixel);
}
test_extra = SDL_CreateRGBSurface(SDL_SWSURFACE, ScreenWidth, ScreenHeight, 32,
0x000000ff, 0x0000ff00, 0x00ff0000, 0x00000000);
if (test_extra == NULL)
// Create a 32bpp surface in a compatible format which will supply
// the format information to all other surfaces used in the game
if (format_conv_surf)
{
fprintf (stderr, "Couldn't create back buffer: %s\n", SDL_GetError());
SDL_FreeSurface (format_conv_surf);
format_conv_surf = NULL;
}
temp_surf = SDL_CreateRGBSurface (SDL_SWSURFACE, 0, 0, 32,
0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000);
if (temp_surf)
{ // acquire a fast compatible format from SDL
format_conv_surf = SDL_DisplayFormatAlpha (temp_surf);
if (!format_conv_surf || format_conv_surf->format->BitsPerPixel != 32)
{ // absolute fallback case
format_conv_surf = SDL_CreateRGBSurface (SDL_SWSURFACE, 0, 0, 32,
0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
}
SDL_FreeSurface (temp_surf);
}
if (!format_conv_surf)
{
fprintf (stderr, "Couldn't create format_conv_surf: %s\n", SDL_GetError());
return -1;
}
for (i = 0; i < TFB_GFX_NUMSCREENS; i++)
{
SDL_Screens[i] = Create_Screen (test_extra);
if (0 != ReInit_Screen (&SDL_Screens[i], format_conv_surf,
ScreenWidth, ScreenHeight))
return -1;
}
SDL_Screen = SDL_Screens[0];
TransitionScreen = SDL_Screens[2];
if (fade_white)
{
SDL_FreeSurface (fade_white);
fade_white = NULL;
}
fade_white = Create_Screen(test_extra);
SDL_FillRect (fade_white, NULL, SDL_MapRGB (fade_white->format, 255, 255, 255));
if (fade_black)
{
SDL_FreeSurface (fade_black);
fade_black = NULL;
}
fade_black = Create_Screen(test_extra);
SDL_FillRect (fade_black, NULL, SDL_MapRGB (fade_black->format, 0, 0, 0));
if (fade_temp)
{
SDL_FreeSurface (fade_temp);
fade_temp = NULL;
}
fade_temp = Create_Screen(test_extra);
SDL_FreeSurface (test_extra);
if (SDL_Video->format->BytesPerPixel != SDL_Screen->format->BytesPerPixel)
{
fprintf (stderr, "Fatal error: SDL_Video and SDL_Screen bpp doesn't match (%d vs. %d)\n",
SDL_Video->format->BytesPerPixel,SDL_Screen->format->BytesPerPixel);
if (0 != ReInit_Screen (&fade_white, format_conv_surf,
ScreenWidth, ScreenHeight))
return -1;
SDL_FillRect (fade_white, NULL, SDL_MapRGB (fade_white->format, 255, 255, 255));
if (0 != ReInit_Screen (&fade_black, format_conv_surf,
ScreenWidth, ScreenHeight))
return -1;
SDL_FillRect (fade_black, NULL, SDL_MapRGB (fade_black->format, 0, 0, 0));
if (0 != ReInit_Screen (&fade_temp, format_conv_surf,
ScreenWidth, ScreenHeight))
return -1;
if (ScreenWidthActual > ScreenWidth || ScreenHeightActual > ScreenHeight)
{
if (0 != ReInit_Screen (&scaled_display, format_conv_surf,
ScreenWidthActual, ScreenHeightActual))
return -1;
scaler = Scale_PrepPlatform (flags, SDL_Screen->format);
}
else
{ // no need to scale
scaler = NULL;
}
return 0;
@@ -160,88 +191,35 @@ TFB_Pure_InitGraphics (int driver, int flags, int width, int height, int bpp)
exit (-1);
}
// pre-compute the RGB->YUV transformations
Scale_PrepYUV();
// Initialize scalers (let them precompute whatever)
Scale_Init ();
return 0;
}
static void ScanLines (SDL_Surface *dst, SDL_Rect *r)
static void
ScanLines (SDL_Surface *dst, SDL_Rect *r)
{
const int rx = r->x * 2;
const int rw = r->w * 2;
const int ry1 = r->y * 2;
const int ry2 = ry1 + r->h * 2;
Uint8 *pixels = (Uint8 *) dst->pixels;
const int rh = r->h * 2;
SDL_PixelFormat *fmt = dst->format;
const int pitch = dst->pitch;
const int len = pitch / fmt->BytesPerPixel;
int ddst;
Uint32 *p = (Uint32 *) dst->pixels;
int x, y;
switch (dst->format->BytesPerPixel)
p += len * (r->y * 2) + (r->x * 2);
ddst = len + len - rw;
for (y = rh; y; y -= 2, p += ddst)
{
case 2:
{
for (y = ry1; y < ry2; y += 2)
for (x = rw; x; --x, ++p)
{
Uint16 *p = (Uint16 *) &pixels[y * dst->pitch + (rx << 1)];
for (x = 0; x < rw; ++x)
{
*p = ((((*p & fmt->Rmask) * 3) >> 2) & fmt->Rmask) |
((((*p & fmt->Gmask) * 3) >> 2) & fmt->Gmask) |
((((*p & fmt->Bmask) * 3) >> 2) & fmt->Bmask);
++p;
}
// we ignore the lower bits as the difference
// of 1 in 255 is negligible
*p = ((*p >> 1) & 0x7f7f7f7f) + ((*p >> 2) & 0x3f3f3f3f);
}
break;
}
case 3:
{
for (y = ry1; y < ry2; y += 2)
{
Uint8 *p = (Uint8 *) &pixels[y * dst->pitch + rx * 3];
Uint32 pixval;
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
for (x = 0; x < rw; ++x)
{
pixval = p[0] << 16 | p[1] << 8 | p[2];
pixval = ((((pixval & fmt->Rmask) * 3) >> 2) & fmt->Rmask) |
((((pixval & fmt->Gmask) * 3) >> 2) & fmt->Gmask) |
((((pixval & fmt->Bmask) * 3) >> 2) & fmt->Bmask);
p[0] = (pixval >> 16) & 0xff;
p[1] = (pixval >> 8) & 0xff;
p[2] = pixval & 0xff;
p += 3;
}
#else
for (x = 0; x < rw; ++x)
{
pixval = p[0] | p[1] << 8 | p[2] << 16;
pixval = ((((pixval & fmt->Rmask) * 3) >> 2) & fmt->Rmask) |
((((pixval & fmt->Gmask) * 3) >> 2) & fmt->Gmask) |
((((pixval & fmt->Bmask) * 3) >> 2) & fmt->Bmask);
p[0] = pixval & 0xff;
p[1] = (pixval >> 8) & 0xff;
p[2] = (pixval >> 16) & 0xff;
p += 3;
}
#endif
}
break;
}
case 4:
{
for (y = ry1; y < ry2; y += 2)
{
Uint32 *p = (Uint32 *) &pixels[y * dst->pitch + (rx << 2)];
for (x = 0; x < rw; ++x)
{
*p = ((((*p & fmt->Rmask) * 3) >> 2) & fmt->Rmask) |
((((*p & fmt->Gmask) * 3) >> 2) & fmt->Gmask) |
((((*p & fmt->Bmask) * 3) >> 2) & fmt->Bmask);
++p;
}
}
break;
}
}
}
@@ -274,12 +252,17 @@ TFB_Pure_SwapBuffers (int force_full_redraw)
last_fade_amount = fade_amount;
last_transition_amount = transition_amount;
if (ScreenWidth == 320 && ScreenHeight == 240 &&
ScreenWidthActual == 640 && ScreenHeightActual == 480)
if (ScreenWidthActual == ScreenWidth * 2 &&
ScreenHeightActual == ScreenHeight * 2)
{
// scales 320x240 backbuffer to 640x480
SDL_Surface *backbuffer = SDL_Screen;
SDL_Surface *scalebuffer = scaled_display;
// we can scale directly onto SDL_Video if video is compatible
if (SDL_Video->format->BitsPerPixel == SDL_Screen->format->BitsPerPixel)
scalebuffer = SDL_Video;
if (transition_amount != 255)
{
@@ -310,27 +293,26 @@ TFB_Pure_SwapBuffers (int force_full_redraw)
}
}
SDL_LockSurface (SDL_Video);
SDL_LockSurface (scalebuffer);
SDL_LockSurface (backbuffer);
if (GfxFlags & TFB_GFXFLAGS_SCALE_BILINEAR)
Scale_BilinearFilter (backbuffer, SDL_Video, &updated);
else if (GfxFlags & TFB_GFXFLAGS_SCALE_BIADAPT)
Scale_BiAdaptFilter (backbuffer, SDL_Video, &updated);
else if (GfxFlags & TFB_GFXFLAGS_SCALE_BIADAPTADV)
Scale_BiAdaptAdvFilter (backbuffer, SDL_Video, &updated);
else if (GfxFlags & TFB_GFXFLAGS_SCALE_TRISCAN)
Scale_TriScanFilter (backbuffer, SDL_Video, &updated);
else
Scale_Nearest (backbuffer, SDL_Video, &updated);
if (scaler)
scaler (backbuffer, scalebuffer, &updated);
if (GfxFlags & TFB_GFXFLAGS_SCANLINES)
ScanLines (SDL_Video, &updated);
ScanLines (scalebuffer, &updated);
SDL_UnlockSurface (backbuffer);
SDL_UnlockSurface (SDL_Video);
SDL_UnlockSurface (scalebuffer);
SDL_UpdateRect (SDL_Video, updated.x * 2, updated.y * 2, updated.w * 2, updated.h * 2);
updated.x *= 2;
updated.y *= 2;
updated.w *= 2;
updated.h *= 2;
if (scalebuffer != SDL_Video)
SDL_BlitSurface (scalebuffer, &updated, SDL_Video, &updated);
SDL_UpdateRects (SDL_Video, 1, &updated);
}
else
{
@@ -362,4 +344,50 @@ TFB_Pure_SwapBuffers (int force_full_redraw)
}
}
void
Scale_PerfTest (void)
{
int fps = 0;
DWORD TimeStart, TimeIn, Now;
SDL_Rect updated = {0, 0, ScreenWidth, ScreenHeight};
int i;
if (!scaler)
{
fprintf (stderr, "No scaler configured! Run with larger resolution, please\n");
return;
}
if (!scaled_display)
{
fprintf (stderr, "Run scaler performance tests in Pure mode, please\n");
return;
}
SDL_LockSurface (SDL_Screen);
SDL_LockSurface (scaled_display);
TimeStart = TimeIn = SDL_GetTicks ();
for (i = 1; i < 1001; ++i) // run for 1000 frames
{
scaler (SDL_Screen, scaled_display, &updated);
if (GfxFlags & TFB_GFXFLAGS_SCANLINES)
ScanLines (scaled_display, &updated);
if (i % 100 == 0)
{
Now = SDL_GetTicks ();
fprintf(stderr, "%03d(%04d) ", 100*1000 / (Now - TimeIn), Now - TimeIn);
TimeIn = Now;
}
}
fprintf (stderr, "Full frames scaled: %d; over %d ms; %d fps\n",
(i - 1), Now - TimeStart, i * 1000 / (Now - TimeStart));
SDL_UnlockSurface (scaled_display);
SDL_UnlockSurface (SDL_Screen);
}
#endif
+27 -7
View File
@@ -41,6 +41,8 @@ SDL_Surface *TransitionScreen;
SDL_Surface *SDL_Screens[TFB_GFX_NUMSCREENS];
SDL_Surface *format_conv_surf = NULL;
volatile int TransitionAmount = 255;
SDL_Rect TransitionClipRect;
static volatile BOOLEAN abortFlag = FALSE;
@@ -223,14 +225,32 @@ TFB_SwapBuffers (int force_full_redraw)
SDL_Surface*
TFB_DisplayFormatAlpha (SDL_Surface *surface)
{
#ifdef HAVE_OPENGL
if (GraphicsDriver == TFB_GFXDRIVER_SDL_OPENGL)
{
return TFB_GL_DisplayFormatAlpha (surface);
}
#endif
SDL_Surface* newsurf;
SDL_PixelFormat* dstfmt;
const SDL_PixelFormat* srcfmt = surface->format;
return SDL_DisplayFormatAlpha (surface);
// figure out what format to use (alpha/no alpha)
if (surface->format->Amask)
dstfmt = format_conv_surf->format;
else
dstfmt = SDL_Screen->format;
if (srcfmt->BytesPerPixel == dstfmt->BytesPerPixel &&
srcfmt->Rmask == dstfmt->Rmask &&
srcfmt->Gmask == dstfmt->Gmask &&
srcfmt->Bmask == dstfmt->Bmask &&
srcfmt->Amask == dstfmt->Amask)
return surface; // no conversion needed
newsurf = SDL_ConvertSurface (surface, dstfmt, surface->flags);
// SDL_SRCCOLORKEY and SDL_SRCALPHA cannot work at the same time,
// so we need to disable one of them
if ((surface->flags & SDL_SRCCOLORKEY) && newsurf
&& (newsurf->flags & SDL_SRCCOLORKEY)
&& (newsurf->flags & SDL_SRCALPHA))
SDL_SetAlpha (newsurf, 0, 255);
return newsurf;
}
void TFB_BlitSurface (SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst,
@@ -39,6 +39,8 @@ extern SDL_Surface *TransitionScreen;
extern SDL_Surface *SDL_Screens[TFB_GFX_NUMSCREENS];
extern SDL_Surface *format_conv_surf;
extern volatile int TransitionAmount;
extern SDL_Rect TransitionClipRect;
+3 -3
View File
@@ -1214,13 +1214,13 @@ void planet_orbit_init ()
Orbit->isPFADefined = (BYTE *)HCalloc (sizeof(BYTE) * MAP_WIDTH);
Orbit->PlanetFrameArray = CaptureDrawable (
CreateDrawable (WANT_PIXMAP, DIAMETER, DIAMETER,
CreateDrawable (WANT_PIXMAP | WANT_ALPHA, DIAMETER, DIAMETER,
(COUNT)MAP_WIDTH));
Orbit->TintFrame = CaptureDrawable (
CreateDrawable (WANT_PIXMAP, (SWORD)MAP_WIDTH,
CreateDrawable (WANT_PIXMAP | WANT_ALPHA, (SWORD)MAP_WIDTH,
(SWORD)MAP_HEIGHT, 2));
Orbit->ShieldFrame = CaptureDrawable (
CreateDrawable (WANT_PIXMAP, SHIELD_DIAM,
CreateDrawable (WANT_PIXMAP | WANT_ALPHA, SHIELD_DIAM,
SHIELD_DIAM, 1));
Orbit->lpTopoData = HMalloc (MAP_WIDTH * MAP_HEIGHT);
+3
View File
@@ -67,6 +67,9 @@ debugKeyPressed (void)
showSpheres ();
// forwardToNextEvent (TRUE);
// Tests
//Scale_PerfTest ();
// Informational:
// dumpEvents (stderr);
// dumpPlanetTypes(stderr);
+25 -4
View File
@@ -32,6 +32,7 @@
#include "libs/tasklib.h"
#include "file.h"
#include "port.h"
#include "libs/platform.h"
#include "options.h"
#include "uqmversion.h"
#include "comm.h"
@@ -108,7 +109,7 @@ main (int argc, char *argv[])
/* .soundFlags = */ audio_QUALITY_MEDIUM,
/* .width = */ 640,
/* .height = */ 480,
/* .bpp = */ 16,
/* .bpp = */ 32,
/* .configDir = */ NULL,
/* .contentDir = */ NULL,
/* .addons = */ NULL,
@@ -313,7 +314,8 @@ enum
SCROLL_OPT,
SOUND_OPT,
STEREOSFX_OPT,
ADDON_OPT
ADDON_OPT,
ACCEL_OPT,
};
static const char *optString = "+r:d:foc:b:spC:n:?hM:S:T:m:q:ug:l:i:v";
@@ -349,6 +351,7 @@ static struct option longOptions[] =
{"sound", 1, NULL, SOUND_OPT},
{"stereosfx", 0, NULL, STEREOSFX_OPT},
{"addon", 1, NULL, ADDON_OPT},
{"accel", 1, NULL, ACCEL_OPT},
{0, 0, 0, 0}
};
@@ -466,6 +469,8 @@ parseOptions(int argc, char *argv[], struct options_struct *options)
options->gfxFlags |= TFB_GFXFLAGS_SCALE_BIADAPTADV;
else if (!strcmp (optarg, "triscan"))
options->gfxFlags |= TFB_GFXFLAGS_SCALE_TRISCAN;
else if (!strcmp (optarg, "hq"))
options->gfxFlags |= TFB_GFXFLAGS_SCALE_HQXX;
else if (strcmp (optarg, "none") != 0)
{
InvalidArgument(optarg, "--scale or -c");
@@ -625,6 +630,22 @@ parseOptions(int argc, char *argv[], struct options_struct *options)
options->addons[options->numAddons - 1] = optarg;
options->addons[options->numAddons] = NULL;
break;
case ACCEL_OPT:
force_platform = PLATFORM_NULL;
if (!strcmp (optarg, "mmx"))
force_platform = PLATFORM_MMX;
else if (!strcmp (optarg, "sse"))
force_platform = PLATFORM_SSE;
else if (!strcmp (optarg, "3dnow"))
force_platform = PLATFORM_3DNOW;
else if (!strcmp (optarg, "none"))
force_platform = PLATFORM_C;
else if (strcmp (optarg, "detect") != 0)
{
InvalidArgument (optarg, "--accel");
badArg = TRUE;
}
break;
default:
fprintf (stderr, "Error: Invalid option '%s' not found.\n",
longOptions[optionIndex].name);
@@ -740,8 +761,8 @@ usage (FILE *out, const struct options_struct *defaultOptions)
fprintf (out, " -d, --bpp=BITSPERPIXEL (default 16)\n");
fprintf (out, " -f, --fullscreen (default off)\n");
fprintf (out, " -o, --opengl (default off)\n");
fprintf (out, " -c, --scale=MODE (bilinear, biadapt, biadv, triscan "
"or none (default) )\n");
fprintf (out, " -c, --scale=MODE (bilinear, biadapt, biadv, triscan, "
"hq or none (default) )\n");
fprintf (out, " -b, --meleezoom=MODE (step, aka pc, or smooth, aka 3do; "
"default is 3do)\n");
fprintf (out, " -s, --scanlines (default off)\n");