Import icculus.org release (2015-02-14)

This commit is contained in:
Steven Fuller 2015-02-14 12:00:00 +01:00 committed by Patryk Obara
parent 22475d6d94
commit 0de664d0a8
24 changed files with 1874 additions and 1400 deletions

View file

@ -12,6 +12,8 @@ ENDIF(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
PROJECT(avp)
# required dependencies
INCLUDE(FindOpenGLES.cmake)
INCLUDE(FindOpenGLES2.cmake)
INCLUDE(FindSDL2.cmake)
INCLUDE(FindSDL)
INCLUDE(FindOpenGL)
@ -27,6 +29,18 @@ IF(NOT SDL_TYPE STREQUAL "AUTO" AND NOT SDL_TYPE STREQUAL "SDL" AND NOT SDL_TYPE
MESSAGE(FATAL_ERROR "Invalid SDL_TYPE setting ${SDL_TYPE}; must be one of AUTO SDL SDL2")
ENDIF(NOT SDL_TYPE STREQUAL "AUTO" AND NOT SDL_TYPE STREQUAL "SDL" AND NOT SDL_TYPE STREQUAL "SDL2")
IF(SDL_FOUND)
IF(SDL_VERSION_STRING VERSION_LESS "1.2.0")
MESSAGE(WARNING "SDL 1.2 was claimed to be found with version ${SDL_VERSION_STRING}, ignoring...")
UNSET(SDL_FOUND)
ENDIF(SDL_VERSION_STRING VERSION_LESS "1.2.0")
IF(SDL_VERSION_STRING VERSION_GREATER "1.2.99")
MESSAGE(WARNING "SDL 1.2 was claimed to be found with version ${SDL_VERSION_STRING}, ignoring...")
UNSET(SDL_FOUND)
ENDIF(SDL_VERSION_STRING VERSION_GREATER "1.2.99")
ENDIF(SDL_FOUND)
IF(SDL_TYPE STREQUAL "AUTO")
IF(SDL_FOUND)
MESSAGE(STATUS "SDL 1.2 found; using that.")
@ -58,12 +72,49 @@ IF(SDL_TYPE STREQUAL "SDL2")
MESSAGE(WARNING "SDL 2.0 support is EXPERIMENTAL and INCOMPLETE.")
ENDIF(SDL_TYPE STREQUAL "SDL2")
IF(NOT OPENGL_FOUND)
MESSAGE(FATAL_ERROR "OpenGL is required but CMake couldn't find it")
ENDIF(NOT OPENGL_FOUND)
# Use Desktop OpenGL if it is available, else try OpenGL ES.
IF(NOT OPENGL_TYPE)
SET(OPENGL_TYPE AUTO CACHE STRING "OpenGL Version; one of: AUTO OPENGL OPENGLES")
SET_PROPERTY(CACHE OPENGL_TYPE PROPERTY STRINGS "AUTO" "OPENGL" "OPENGLES")
ENDIF(NOT OPENGL_TYPE)
IF(NOT OPENGL_TYPE STREQUAL "AUTO" AND NOT OPENGL_TYPE STREQUAL "OPENGL" AND NOT OPENGL_TYPE STREQUAL "OPENGLES")
MESSAGE(FATAL_ERROR "Invalid OPENGL_TYPE setting ${OPENGL_TYPE}; must be one of AUTO OPENGL OPENGLES")
ENDIF(NOT OPENGL_TYPE STREQUAL "AUTO" AND NOT OPENGL_TYPE STREQUAL "OPENGL" AND NOT OPENGL_TYPE STREQUAL "OPENGLES")
IF(OPENGL_TYPE STREQUAL "AUTO")
IF(OPENGL_FOUND)
MESSAGE(STATUS "OpenGL found; using that.")
SET(OPENGL_TYPE "OPENGL")
ENDIF(OPENGL_FOUND)
ENDIF(OPENGL_TYPE STREQUAL "AUTO")
IF(OPENGL_TYPE STREQUAL "AUTO")
IF(OPENGLES_FOUND)
MESSAGE(STATUS "OpenGL ES found; using that.")
SET(OPENGL_TYPE "OPENGLES")
ENDIF(OPENGLES_FOUND)
ENDIF(OPENGL_TYPE STREQUAL "AUTO")
IF(OPENGL_TYPE STREQUAL "AUTO")
MESSAGE(FATAL_ERROR "OpenGL is required but CMake couldn't find it.")
ENDIF(OPENGL_TYPE STREQUAL "AUTO")
IF(OPENGL_TYPE STREQUAL "OPENGL")
IF(NOT OPENGL_FOUND)
MESAGE(FATAL_ERROR "OpenGL was requested but CMake couldn't find it.")
ENDIF(NOT OPENGL_FOUND)
ENDIF(OPENGL_TYPE STREQUAL "OPENGL")
IF(OPENGL_TYPE STREQUAL "OPENGLES")
IF(NOT OPENGLES_FOUND)
MESSAGE(FATAL_ERROR "OpenGL ES was requested but CMake couldn't find it.")
ENDIF(NOT OPENGLES_FOUND)
ENDIF(OPENGL_TYPE STREQUAL "OPENGLES")
# OpenAL
IF(NOT OPENAL_FOUND)
MESSAGE(FATAL_ERROR "OpenAL is required but CMake couldn't find it")
MESSAGE(FATAL_ERROR "OpenAL is required but CMake couldn't find it.")
ENDIF(NOT OPENAL_FOUND)
# required source files
@ -307,7 +358,7 @@ ENDIF(SDL_TYPE STREQUAL "SDL2")
# auto-include directories with source files
FOREACH(sourcefile IN LISTS source)
GET_FILENAME_COMPONENT(includedir ${sourcefile} DIRECTORY)
GET_FILENAME_COMPONENT(includedir ${sourcefile} PATH) # newer CMake uses DIRECTORY
LIST(APPEND include ${includedir})
ENDFOREACH(sourcefile)
INCLUDE_DIRECTORIES(${include})
@ -326,7 +377,16 @@ IF(SDL_TYPE STREQUAL "SDL2")
INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIR})
ENDIF(SDL_TYPE STREQUAL "SDL2")
INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
IF(OPENGL_TYPE STREQUAL "OPENGL")
INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
ENDIF(OPENGL_TYPE STREQUAL "OPENGL")
IF(OPENGL_TYPE STREQUAL "OPENGLES")
ADD_DEFINITIONS(-DUSE_OPENGL_ES=1)
INCLUDE_DIRECTORIES(${OPENGLES_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${EGL_INCLUDE_DIR})
ENDIF(OPENGL_TYPE STREQUAL "OPENGLES")
INCLUDE_DIRECTORIES(${OPENAL_INCLUDE_DIR})
IF(SDL_TYPE STREQUAL "SDL")
@ -337,5 +397,13 @@ IF(SDL_TYPE STREQUAL "SDL2")
TARGET_LINK_LIBRARIES(avp ${SDL2_LIBRARY})
ENDIF(SDL_TYPE STREQUAL "SDL2")
TARGET_LINK_LIBRARIES(avp ${OPENGL_gl_LIBRARY})
IF(OPENGL_TYPE STREQUAL "OPENGL")
TARGET_LINK_LIBRARIES(avp ${OPENGL_gl_LIBRARY})
ENDIF(OPENGL_TYPE STREQUAL "OPENGL")
IF(OPENGL_TYPE STREQUAL "OPENGLES")
TARGET_LINK_LIBRARIES(avp ${OPENGLES_gl_LIBRARY})
TARGET_LINK_LIBRARIES(avp ${EGL_LIBRARIES})
ENDIF(OPENGL_TYPE STREQUAL "OPENGLES")
TARGET_LINK_LIBRARIES(avp ${OPENAL_LIBRARY})

94
FindOpenGLES.cmake Normal file
View file

@ -0,0 +1,94 @@
#-------------------------------------------------------------------
# This file is part of the CMake build system for OGRE
# (Object-oriented Graphics Rendering Engine)
# For the latest info, see http://www.ogre3d.org/
#
# The contents of this file are placed in the public domain. Feel
# free to make use of it in any way you like.
#-------------------------------------------------------------------
# - Try to find OpenGLES
# Once done this will define
#
# OPENGLES_FOUND - system has OpenGLES
# OPENGLES_INCLUDE_DIR - the GL include directory
# OPENGLES_LIBRARIES - Link these to use OpenGLES
IF (WIN32)
IF (CYGWIN)
FIND_PATH(OPENGLES_INCLUDE_DIR GLES/gl.h )
FIND_LIBRARY(OPENGLES_gl_LIBRARY libgles_cm )
ELSE (CYGWIN)
IF(BORLAND)
SET (OPENGLES_gl_LIBRARY import32 CACHE STRING "OpenGL ES 1.x library for win32")
ELSE(BORLAND)
#MS compiler - todo - fix the following line:
SET (OPENGLES_gl_LIBRARY ${OGRE_SOURCE_DIR}/Dependencies/lib/release/libgles_cm.lib CACHE STRING "OpenGL ES 1.x library for win32")
ENDIF(BORLAND)
ENDIF (CYGWIN)
ELSE (WIN32)
IF (APPLE)
#create_search_paths(/Developer/Platforms)
#findpkg_framework(OpenGLES)
#set(OPENGLES_gl_LIBRARY "-framework OpenGLES")
ELSE(APPLE)
FIND_PATH(OPENGLES_INCLUDE_DIR GLES/gl.h
/opt/vc/include
/opt/graphics/OpenGL/include
/usr/openwin/share/include
/usr/X11R6/include
/usr/include
)
FIND_LIBRARY(OPENGLES_gl_LIBRARY
NAMES GLES_CM GLESv1_CM
PATHS /opt/vc/lib
/opt/graphics/OpenGL/lib
/usr/openwin/lib
/usr/shlib /usr/X11R6/lib
/usr/lib
)
# On Unix OpenGL most certainly always requires X11.
# Feel free to tighten up these conditions if you don't
# think this is always true.
#IF (OPENGLES_gl_LIBRARY)
# IF(NOT X11_FOUND)
# INCLUDE(FindX11)
# ENDIF(NOT X11_FOUND)
# IF (X11_FOUND)
# SET (OPENGLES_LIBRARIES ${X11_LIBRARIES})
# ENDIF (X11_FOUND)
#ENDIF (OPENGLES_gl_LIBRARY)
ENDIF(APPLE)
ENDIF (WIN32)
SET( OPENGLES_FOUND "NO" )
IF(OPENGLES_gl_LIBRARY)
SET( OPENGLES_LIBRARIES ${OPENGLES_gl_LIBRARY} ${OPENGLES_LIBRARIES})
SET( OPENGLES_FOUND "YES" )
ENDIF(OPENGLES_gl_LIBRARY)
MARK_AS_ADVANCED(
OPENGLES_INCLUDE_DIR
OPENGLES_gl_LIBRARY
)
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OPENGLES REQUIRED_VARS OPENGLES_LIBRARIES OPENGLES_INCLUDE_DIR)

170
FindOpenGLES2.cmake Normal file
View file

@ -0,0 +1,170 @@
#-------------------------------------------------------------------
# This file is part of the CMake build system for OGRE
# (Object-oriented Graphics Rendering Engine)
# For the latest info, see http://www.ogre3d.org/
#
# The contents of this file are placed in the public domain. Feel
# free to make use of it in any way you like.
#-------------------------------------------------------------------
# - Try to find OpenGLES and EGL
# If using ARM Mali emulation you can specify the parent directory that contains the bin and include directories by
# setting the MALI_SDK_ROOT variable in the environment.
#
# For AMD emulation use the AMD_SDK_ROOT variable
#
# Once done this will define
#
# OPENGLES2_FOUND - system has OpenGLES
# OPENGLES2_INCLUDE_DIR - the GL include directory
# OPENGLES2_LIBRARIES - Link these to use OpenGLES
#
# EGL_FOUND - system has EGL
# EGL_INCLUDE_DIR - the EGL include directory
# EGL_LIBRARIES - Link these to use EGL
#include(FindPkgMacros)
IF (WIN32)
IF (CYGWIN)
FIND_PATH(OPENGLES2_INCLUDE_DIR GLES2/gl2.h )
FIND_LIBRARY(OPENGLES2_gl_LIBRARY libGLESv2 )
ELSE (CYGWIN)
IF(BORLAND)
SET (OPENGLES2_gl_LIBRARY import32 CACHE STRING "OpenGL ES 2.x library for win32")
ELSE(BORLAND)
#getenv_path(AMD_SDK_ROOT)
#getenv_path(MALI_SDK_ROOT)
SET(POWERVR_SDK_PATH "C:/Imagination/PowerVR/GraphicsSDK/SDK_3.1/Builds")
FIND_PATH(OPENGLES2_INCLUDE_DIR GLES2/gl2.h
${ENV_AMD_SDK_ROOT}/include
${ENV_MALI_SDK_ROOT}/include
${POWERVR_SDK_PATH}/Include
"C:/Imagination Technologies/PowerVR Insider SDK/OGLES2_WINDOWS_X86EMULATION_2.10/Builds/OGLES2/Include"
)
FIND_PATH(EGL_INCLUDE_DIR EGL/egl.h
${ENV_AMD_SDK_ROOT}/include
${ENV_MALI_SDK_ROOT}/include
${POWERVR_SDK_PATH}/Include
"C:/Imagination Technologies/PowerVR Insider SDK/OGLES2_WINDOWS_X86EMULATION_2.10/Builds/OGLES2/Include"
)
FIND_LIBRARY(OPENGLES2_gl_LIBRARY
NAMES libGLESv2
PATHS ${ENV_AMD_SDK_ROOT}/x86
${ENV_MALI_SDK_ROOT}/bin
${POWERVR_SDK_PATH}/Windows/x86_32/Lib
"C:/Imagination Technologies/PowerVR Insider SDK/OGLES2_WINDOWS_X86EMULATION_2.10/Builds/OGLES2/WindowsX86/Lib"
)
FIND_LIBRARY(EGL_egl_LIBRARY
NAMES libEGL
PATHS ${ENV_AMD_SDK_ROOT}/x86
${ENV_MALI_SDK_ROOT}/bin
${POWERVR_SDK_PATH}/Windows/x86_32/Lib
"C:/Imagination Technologies/PowerVR Insider SDK/OGLES2_WINDOWS_X86EMULATION_2.10/Builds/OGLES2/WindowsX86/Lib"
)
ENDIF(BORLAND)
ENDIF (CYGWIN)
ELSE (WIN32)
IF (APPLE)
#create_search_paths(/Developer/Platforms)
#findpkg_framework(OpenGLES2)
#set(OPENGLES2_gl_LIBRARY "-framework OpenGLES")
ELSE(APPLE)
#getenv_path(AMD_SDK_ROOT)
#getenv_path(MALI_SDK_ROOT)
FIND_PATH(OPENGLES2_INCLUDE_DIR GLES2/gl2.h
${ENV_AMD_SDK_ROOT}/include
${ENV_MALI_SDK_ROOT}/include
/opt/Imagination/PowerVR/GraphicsSDK/SDK_3.1/Builds/Include
/opt/vc/include
/usr/openwin/share/include
/opt/graphics/OpenGL/include /usr/X11R6/include
/usr/include
)
FIND_LIBRARY(OPENGLES2_gl_LIBRARY
NAMES GLESv2
PATHS ${ENV_AMD_SDK_ROOT}/x86
${ENV_MALI_SDK_ROOT}/bin
/opt/Imagination/PowerVR/GraphicsSDK/SDK_3.1/Builds/Linux/x86_32/Lib
/opt/vc/lib
/opt/graphics/OpenGL/lib
/usr/openwin/lib
/usr/shlib /usr/X11R6/lib
/usr/lib
)
FIND_PATH(EGL_INCLUDE_DIR EGL/egl.h
${ENV_AMD_SDK_ROOT}/include
${ENV_MALI_SDK_ROOT}/include
/opt/Imagination/PowerVR/GraphicsSDK/SDK_3.1/Builds/Include
/opt/vc/include
/usr/openwin/share/include
/opt/graphics/OpenGL/include /usr/X11R6/include
/usr/include
)
FIND_LIBRARY(EGL_egl_LIBRARY
NAMES EGL
PATHS ${ENV_AMD_SDK_ROOT}/x86
${ENV_MALI_SDK_ROOT}/bin
/opt/Imagination/PowerVR/GraphicsSDK/SDK_3.1/Builds/Linux/x86_32/Lib
/opt/vc/lib
/opt/graphics/OpenGL/lib
/usr/openwin/lib
/usr/shlib /usr/X11R6/lib
/usr/lib
)
# On Unix OpenGL most certainly always requires X11.
# Feel free to tighten up these conditions if you don't
# think this is always true.
# It's not true on OSX.
#IF (OPENGLES2_gl_LIBRARY)
# IF(NOT X11_FOUND)
# INCLUDE(FindX11)
# ENDIF(NOT X11_FOUND)
# IF (X11_FOUND)
# IF (NOT APPLE)
# SET (OPENGLES2_LIBRARIES ${X11_LIBRARIES})
# ENDIF (NOT APPLE)
# ENDIF (X11_FOUND)
#ENDIF (OPENGLES2_gl_LIBRARY)
ENDIF(APPLE)
ENDIF (WIN32)
SET( OPENGLES2_FOUND "YES" )
IF(OPENGLES2_gl_LIBRARY AND EGL_egl_LIBRARY)
SET( OPENGLES2_LIBRARIES ${OPENGLES2_gl_LIBRARY} ${OPENGLES2_LIBRARIES})
SET( EGL_LIBRARIES ${EGL_egl_LIBRARY} ${EGL_LIBRARIES})
SET( OPENGLES2_FOUND "YES" )
ENDIF(OPENGLES2_gl_LIBRARY AND EGL_egl_LIBRARY)
MARK_AS_ADVANCED(
OPENGLES2_INCLUDE_DIR
OPENGLES2_gl_LIBRARY
EGL_INCLUDE_DIR
EGL_egl_LIBRARY
)
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OPENGLES2 REQUIRED_VARS OPENGLES2_LIBRARIES OPENGLES2_INCLUDE_DIR)

17
README
View file

@ -7,7 +7,8 @@ Table of Contents:
3. Compilation
4. Installation
5. Credits
a. Gold edition MD5s
a. Change History
b. Gold edition MD5s
Part 1: Introduction
@ -71,8 +72,20 @@ Chuck Mason, initial OpenAL implementation
For everything else, there's http://community.ioquake.org/c/avp
Appendix A: Change History
--------------------------
Appendix A: Gold edition MD5s
20150214:
OpenGL ES 1.1 compatibility
SDL2 support progress
20141225:
CMake build system
x86_64 support
Beginnings of SDL2 support
Appendix B: Gold edition MD5s
-----------------------------
A proper install of the Gold edition should look similar to this:

View file

@ -130,6 +130,7 @@ void LoadCDTrackList()
//copy the file contents into a buffer
buffer=new char[file_size+1];
fread(buffer, 1, file_size, file);
buffer[file_size]='\0';
fclose(file);
char* bufferptr=buffer;

View file

@ -2121,12 +2121,7 @@ int Fast3dMagnitude(VECTORCH *v)
}
}
#define ZOOM_SCALE_0 1.0f
#define ZOOM_SCALE_1 0.4f
#define ZOOM_SCALE_2 0.1f
#define ZOOM_SCALE_3 0.02f
static float ZoomLevels[] = {1.0f,0.4f,0.1f,0.02f};
static const float ZoomLevels[] = {1.0f,0.4f,0.1f,0.02f};
void MaintainZoomingLevel(void)
{
@ -2173,18 +2168,3 @@ void MaintainZoomingLevel(void)
}

View file

@ -1362,7 +1362,15 @@ enum TEXTSTRING_ID
TEXTSTRING_CUSTOM_LEVEL,
TEXTSTRING_MULTIPLAYER_OPERATETORESPAWN,
TEXTSTRING_MULTIPLAYER_OPERATETOOBSERVE,
MAX_NO_OF_TEXTSTRINGS
MAX_NO_OF_TEXTSTRINGS,
// Not good.
// These strings do not exist in data.
MIN_NEW_TEXTSTRINGS,
TEXTSTRING_MAINMENU_EXITGAME_HELP_NEW,
TEXTSTRING_MAINMENU_CREDITS_NEW,
TEXTSTRING_MAINMENU_CREDITS_HELP_NEW,
MAX_NEW_TEXTSTRINGS
};
#endif

View file

@ -78,8 +78,13 @@ void InitTextStrings(void)
for (i=1; i<MAX_NO_OF_TEXTSTRINGS; i++)
{
/* scan for a quote mark */
while (*textPtr++ != '"')
if (*textPtr == '@') return; /* '@' should be EOF */
while (*textPtr++ != '"') {
if (*textPtr == '@') {
// should be an error as this language file
// doesn't match the game.
return; /* '@' should be EOF */
}
}
/* now pointing to a text string after quote mark*/
TextStringPtr[i] = textPtr;
@ -107,9 +112,20 @@ void KillTextStrings(void)
char *GetTextString(enum TEXTSTRING_ID stringID)
{
// Not good.
// These strings do not exist in data.
if (stringID > MIN_NEW_TEXTSTRINGS && stringID < MAX_NEW_TEXTSTRINGS) {
switch (stringID) {
case TEXTSTRING_MAINMENU_EXITGAME_HELP_NEW: return "Exit the game.";
case TEXTSTRING_MAINMENU_CREDITS_NEW: return "Credits";
case TEXTSTRING_MAINMENU_CREDITS_HELP_NEW: return "View the credits.";
default: break;
}
}
LOCALASSERT(stringID<MAX_NO_OF_TEXTSTRINGS);
return TextStringPtr[stringID];
if (stringID < MAX_NO_OF_TEXTSTRINGS) {
return TextStringPtr[stringID];
}
return EmptyString;
}

View file

@ -5,8 +5,8 @@
#if USE_LEVEL_MEMORY_POOL
#define MAX_NUM_MEMORY_BLOCK 40
#define MEMORY_BLOCK_SIZE (1024*1024)
#define MAX_NUM_MEMORY_BLOCK 64
#define MEMORY_BLOCK_SIZE (8192*1024)
static char* MemoryBlocks[MAX_NUM_MEMORY_BLOCK];
static int CurrentMemoryBlock =-1;
@ -14,6 +14,10 @@ static int CurrentMemoryBlock =-1;
static char* MemoryPoolPtr=0;
static unsigned int MemoryLeft=0;
static size_t AllocationCount=0;
static size_t LargestRequest=0;
static size_t MemoryRequested=0;
static size_t MemoryWasted=0;
void* PoolAllocateMem(unsigned int amount)
{
@ -31,6 +35,8 @@ void* PoolAllocateMem(unsigned int amount)
if(amount>MemoryLeft)
{
MemoryWasted += MemoryLeft;
CurrentMemoryBlock++;
GLOBALASSERT(CurrentMemoryBlock<MAX_NUM_MEMORY_BLOCK);
if (CurrentMemoryBlock >= MAX_NUM_MEMORY_BLOCK)
@ -49,7 +55,14 @@ void* PoolAllocateMem(unsigned int amount)
MemoryLeft=MEMORY_BLOCK_SIZE;
MemoryPoolPtr=MemoryBlocks[CurrentMemoryBlock];
}
if (amount > LargestRequest) {
LargestRequest = amount;
}
MemoryRequested+=amount;
AllocationCount++;
retval=MemoryPoolPtr;
MemoryLeft-=amount;
MemoryPoolPtr+=amount;
@ -62,6 +75,11 @@ void ClearMemoryPool()
{
int i;
#if !defined(NDEBUG)
printf("%d blocks in use, %u bytes left in current block\n", CurrentMemoryBlock + 1, MemoryLeft);
printf("%zu requests, %zu bytes requested, %zu bytes wasted, %zu largest request\n", AllocationCount, MemoryRequested, MemoryWasted, LargestRequest);
#endif
for(i=0;i<=CurrentMemoryBlock;i++)
{
DeallocateMem(MemoryBlocks[i]);
@ -70,8 +88,11 @@ void ClearMemoryPool()
CurrentMemoryBlock=-1;
MemoryPoolPtr=0;
MemoryLeft=0;
MemoryRequested = 0;
MemoryWasted = 0;
LargestRequest = 0;
AllocationCount = 0;
}
#endif

View file

@ -100,7 +100,7 @@ static AVPMENU_ELEMENT AvPMenu_MainMenu[] =
{AVPMENU_ELEMENT_GOTOMENU, {TEXTSTRING_MAINMENU_GAMEPLAYOPTIONS}, {AVPMENU_OPTIONS},{0},{0}, TEXTSTRING_MAINMENU_GAMEPLAYOPTIONS_HELP},
{AVPMENU_ELEMENT_GOTOMENU, {TEXTSTRING_AVOPTIONS_TITLE}, {AVPMENU_MAINMENUAVOPTIONS},{0},{0}, TEXTSTRING_AVOPTIONS_TITLE_HELP},
{AVPMENU_ELEMENT_GOTOMENU, {TEXTSTRING_MAINMENU_CHANGEUSERPROFILE}, {AVPMENU_USERPROFILESELECT},{0},{0}, TEXTSTRING_MAINMENU_CHANGEUSERPROFILE_HELP},
{AVPMENU_ELEMENT_QUITGAME, {TEXTSTRING_MAINMENU_EXITGAME}, {0}, {0}, {0}, TEXTSTRING_MAINMENU_EXITGAME_HELP},
{AVPMENU_ELEMENT_QUITGAME, {TEXTSTRING_MAINMENU_EXITGAME}, {0}, {0}, {0}, TEXTSTRING_MAINMENU_EXITGAME_HELP_NEW},
{AVPMENU_ELEMENT_ENDOFMENU}
};
#endif
@ -116,7 +116,7 @@ static AVPMENU_ELEMENT AvPMenu_MainMenu_WithCheats[] =
{AVPMENU_ELEMENT_GOTOMENU, {TEXTSTRING_AVOPTIONS_TITLE}, {AVPMENU_MAINMENUAVOPTIONS},{0},{0}, TEXTSTRING_AVOPTIONS_TITLE_HELP},
{AVPMENU_ELEMENT_GOTOMENU, {TEXTSTRING_MAINMENU_CHANGEUSERPROFILE}, {AVPMENU_USERPROFILESELECT},{0},{0}, TEXTSTRING_MAINMENU_CHANGEUSERPROFILE_HELP},
{AVPMENU_ELEMENT_GOTOMENU, {TEXTSTRING_MAINMENU_CHEATOPTIONS}, {AVPMENU_CHEATOPTIONS},{0},{0}, TEXTSTRING_MAINMENU_CHEATOPTIONS_HELP},
{AVPMENU_ELEMENT_QUITGAME, {TEXTSTRING_MAINMENU_EXITGAME}, {0}, {0}, {0}, TEXTSTRING_MAINMENU_EXITGAME_HELP},
{AVPMENU_ELEMENT_QUITGAME, {TEXTSTRING_MAINMENU_EXITGAME}, {0}, {0}, {0}, TEXTSTRING_MAINMENU_EXITGAME_HELP_NEW},
{AVPMENU_ELEMENT_ENDOFMENU}
};
static AVPMENU_ELEMENT AvPMenu_Debug_MainMenu[] =
@ -129,7 +129,7 @@ static AVPMENU_ELEMENT AvPMenu_Debug_MainMenu[] =
{AVPMENU_ELEMENT_GOTOMENU, {TEXTSTRING_MAINMENU_GAMEPLAYOPTIONS}, {AVPMENU_OPTIONS},{0},{0}, TEXTSTRING_MAINMENU_GAMEPLAYOPTIONS_HELP},
{AVPMENU_ELEMENT_GOTOMENU, {TEXTSTRING_AVOPTIONS_TITLE}, {AVPMENU_MAINMENUAVOPTIONS},{0},{0}, TEXTSTRING_AVOPTIONS_TITLE_HELP},
{AVPMENU_ELEMENT_GOTOMENU, {TEXTSTRING_MAINMENU_CHANGEUSERPROFILE}, {AVPMENU_USERPROFILESELECT},{0},{0}, TEXTSTRING_MAINMENU_CHANGEUSERPROFILE_HELP},
{AVPMENU_ELEMENT_QUITGAME, {TEXTSTRING_MAINMENU_EXITGAME}, {0}, {0}, {0}, TEXTSTRING_MAINMENU_EXITGAME_HELP},
{AVPMENU_ELEMENT_QUITGAME, {TEXTSTRING_MAINMENU_EXITGAME}, {0}, {0}, {0}, TEXTSTRING_MAINMENU_EXITGAME_HELP_NEW},
{AVPMENU_ELEMENT_ENDOFMENU}
};
static AVPMENU_ELEMENT AvPMenu_Debug_MainMenu_WithCheats[] =
@ -143,7 +143,7 @@ static AVPMENU_ELEMENT AvPMenu_Debug_MainMenu_WithCheats[] =
{AVPMENU_ELEMENT_GOTOMENU, {TEXTSTRING_AVOPTIONS_TITLE}, {AVPMENU_MAINMENUAVOPTIONS},{0},{0}, TEXTSTRING_AVOPTIONS_TITLE_HELP},
{AVPMENU_ELEMENT_GOTOMENU, {TEXTSTRING_MAINMENU_CHANGEUSERPROFILE}, {AVPMENU_USERPROFILESELECT},{0},{0}, TEXTSTRING_MAINMENU_CHANGEUSERPROFILE_HELP},
{AVPMENU_ELEMENT_GOTOMENU, {TEXTSTRING_MAINMENU_CHEATOPTIONS}, {AVPMENU_CHEATOPTIONS},{0},{0}, TEXTSTRING_MAINMENU_CHEATOPTIONS_HELP},
{AVPMENU_ELEMENT_QUITGAME, {TEXTSTRING_MAINMENU_EXITGAME}, {0}, {0}, {0}, TEXTSTRING_MAINMENU_EXITGAME_HELP},
{AVPMENU_ELEMENT_QUITGAME, {TEXTSTRING_MAINMENU_EXITGAME}, {0}, {0}, {0}, TEXTSTRING_MAINMENU_EXITGAME_HELP_NEW},
{AVPMENU_ELEMENT_ENDOFMENU}
};

View file

@ -14,12 +14,10 @@ extern "C"
#include "language.h"
#include "avp_menus.h"
extern SCREENDESCRIPTORBLOCK ScreenDescriptorBlock;
//extern LPDIRECTDRAWSURFACE lpDDSBack; // DirectDraw back surface
extern int DebouncedGotAnyKey;
extern void MinimalNetCollectMessages(void);
extern void NetSendMessages(void);
extern void RenderGrabbedScreen(void);
extern void ThisFramesRenderingHasBegun(void);
extern void ThisFramesRenderingHasFinished(void);
@ -29,28 +27,58 @@ extern int FadingGameInAfterLoading;
extern void InGameFlipBuffers();
extern void RenderStringCentred(char *stringPtr, int centreX, int y, int colour);
extern void BltImage(RECT *dest, DDSurface *image, RECT *src);
extern int CreateOGLTexture(D3DTexture *, unsigned char *);
extern int CreateIMGSurface(D3DTexture *, unsigned char *);
};
static int CurrentPosition=0;
static int BarLeft;
static int BarRight;
static int BarTop;
static int BarBottom;
static const char* Loading_Image_Name="Menus\\Loading.rim";
static const char* Loading_Bar_Empty_Image_Name="Menus\\Loadingbar_empty.rim";
static const char* Loading_Bar_Full_Image_Name="Menus\\Loadingbar_full.rim";
DDSurface *LoadingBarEmpty;
DDSurface *LoadingBarFull;
RECT LoadingBarEmpty_DestRect;
RECT LoadingBarEmpty_SrcRect;
RECT LoadingBarFull_DestRect;
RECT LoadingBarFull_SrcRect;
static DDSurface* LoadingBarEmpty;
static DDSurface* LoadingBarFull;
static RECT LoadingBarEmpty_DestRect;
static RECT LoadingBarEmpty_SrcRect;
static RECT LoadingBarFull_DestRect;
static RECT LoadingBarFull_SrcRect;
static int CurrentPosition=0;
static int LoadingInProgress=0;
static void Draw_Progress_Bar(void) {
ThisFramesRenderingHasBegun();
ColourFillBackBuffer(0);
if (LoadingInProgress != 0 && LoadingBarEmpty != NULL) {
BltImage(&LoadingBarEmpty_DestRect,LoadingBarEmpty,&LoadingBarEmpty_SrcRect);
}
if (LoadingBarFull != NULL) {
BltImage(&LoadingBarFull_DestRect,LoadingBarFull,&LoadingBarFull_SrcRect);
}
FlushD3DZBuffer();
RenderBriefingText(ScreenDescriptorBlock.SDB_Height/2, ONE_FIXED);
if (LoadingInProgress == 0) {
RenderStringCentred(GetTextString(TEXTSTRING_INGAME_PRESSANYKEYTOCONTINUE), ScreenDescriptorBlock.SDB_Width/2, (ScreenDescriptorBlock.SDB_Height*23)/24-9, 0xffffffff);
}
ThisFramesRenderingHasFinished();
InGameFlipBuffers();
}
void Start_Progress_Bar()
{
LoadingBarEmpty = NULL;
LoadingBarFull = NULL;
AAFontImageNumber = CL_LoadImageOnce("Common\\aa_font.RIM",LIO_D3DTEXTURE|LIO_RELATIVEPATH|LIO_RESTORABLE);
/* load other graphics */
@ -114,47 +142,11 @@ void Start_Progress_Bar()
);
}
}
DDSurface* image=0;
CreateOGLTexture(LoadingBarEmpty, NULL);
CreateOGLTexture(LoadingBarFull, NULL);
//set progress bar dimensions
BarLeft=ScreenDescriptorBlock.SDB_Width/6;
BarRight=(ScreenDescriptorBlock.SDB_Width*5)/6;
BarTop=(ScreenDescriptorBlock.SDB_Height*19)/22;
BarBottom=(ScreenDescriptorBlock.SDB_Height*21)/22;
//load background image for bar
char buffer[100];
CL_GetImageFileName(buffer, 100,Loading_Image_Name, LIO_RELATIVEPATH);
//see if graphic can be found in fast file
size_t fastFileLength;
void const * pFastFileData = ffreadbuf(buffer,&fastFileLength);
if(pFastFileData)
{
//load from fast file
image = AwCreateSurface
(
"pxf",
pFastFileData,
fastFileLength,
0
);
}
else
{
//load graphic from rim file
image = AwCreateSurface
(
"sf",
buffer,
0
);
}
//draw initial progress bar
LoadingBarEmpty_SrcRect.left=0;
LoadingBarEmpty_SrcRect.right=639;
LoadingBarEmpty_SrcRect.top=0;
@ -163,47 +155,28 @@ void Start_Progress_Bar()
LoadingBarEmpty_DestRect.right=ScreenDescriptorBlock.SDB_Width-1;
LoadingBarEmpty_DestRect.top=(ScreenDescriptorBlock.SDB_Height *11)/12;
LoadingBarEmpty_DestRect.bottom=ScreenDescriptorBlock.SDB_Height-1;
for (int i=0; i<2; i++)
{
ColourFillBackBuffer(0);
if (LoadingBarEmpty) BltImage(&LoadingBarEmpty_DestRect,LoadingBarEmpty,&LoadingBarEmpty_SrcRect);
FlushD3DZBuffer();
ThisFramesRenderingHasBegun();
RenderBriefingText(ScreenDescriptorBlock.SDB_Height/2, ONE_FIXED);
ThisFramesRenderingHasFinished();
/* FlipBuffers(); */
InGameFlipBuffers();
}
if(image)
{
ReleaseDDSurface(image);
}
if (LoadingBarEmpty)
{
ReleaseDDSurface(LoadingBarEmpty);
}
LoadingBarFull_SrcRect.left=0;
LoadingBarFull_SrcRect.right=0;
LoadingBarFull_SrcRect.top=0;
LoadingBarFull_SrcRect.bottom=39;
LoadingBarFull_DestRect.left=0;
LoadingBarFull_DestRect.right=0;
LoadingBarFull_DestRect.top=(ScreenDescriptorBlock.SDB_Height *11)/12;
LoadingBarFull_DestRect.bottom=ScreenDescriptorBlock.SDB_Height-1;
CurrentPosition=0;
LoadingInProgress=1;
Draw_Progress_Bar();
}
void Set_Progress_Bar_Position(int pos)
{
// int NewPosition=((BarRight-BarLeft)*pos)/PBAR_LENGTH;
int NewPosition = DIV_FIXED(pos,PBAR_LENGTH);
if(NewPosition>CurrentPosition)
{
CurrentPosition=NewPosition;
// ColourFillBackBufferQuad(GetSingleColourForPrimary(0xff0000),BarLeft,BarTop,BarLeft+CurrentPosition,BarBottom);
LoadingBarFull_SrcRect.left=0;
LoadingBarFull_SrcRect.right=MUL_FIXED(639,NewPosition);
LoadingBarFull_SrcRect.top=0;
@ -212,11 +185,8 @@ void Set_Progress_Bar_Position(int pos)
LoadingBarFull_DestRect.right=MUL_FIXED(ScreenDescriptorBlock.SDB_Width-1,NewPosition);
LoadingBarFull_DestRect.top=(ScreenDescriptorBlock.SDB_Height *11)/12;
LoadingBarFull_DestRect.bottom=ScreenDescriptorBlock.SDB_Height-1;
if (LoadingBarFull) BltImage(&LoadingBarFull_DestRect,LoadingBarFull,&LoadingBarFull_SrcRect);
/* FlipBuffers(); */
InGameFlipBuffers();
Draw_Progress_Bar();
/*
If this is a network game , then check the received network messages from
@ -250,12 +220,12 @@ extern "C"
void Game_Has_Loaded(void)
{
extern int NormalFrameTime;
extern void RenderStringCentred(char *stringPtr, int centreX, int y, int colour);
SoundSys_StopAll();
SoundSys_Management();
LoadingInProgress = 0;
int f = 65536;
ResetFrameCounter();
do
@ -285,28 +255,23 @@ void Game_Has_Loaded(void)
LoadingBarFull_DestRect.top=(ScreenDescriptorBlock.SDB_Height *11)/12+h;
LoadingBarFull_DestRect.bottom=ScreenDescriptorBlock.SDB_Height-1-h;
if (LoadingBarFull) BltImage(&LoadingBarFull_DestRect,LoadingBarFull,&LoadingBarFull_SrcRect);
f-=NormalFrameTime;
if (f<0) f=0;
}
{
extern void ThisFramesRenderingHasBegun(void);
ThisFramesRenderingHasBegun();
}
RenderStringCentred(GetTextString(TEXTSTRING_INGAME_PRESSANYKEYTOCONTINUE), ScreenDescriptorBlock.SDB_Width/2, (ScreenDescriptorBlock.SDB_Height*23)/24-9, 0xffffffff);
{
/* after this call, no more graphics can be drawn until the next frame */
extern void ThisFramesRenderingHasFinished(void);
ThisFramesRenderingHasFinished();
} else {
LoadingBarFull_SrcRect.left=0;
LoadingBarFull_SrcRect.right=0;
LoadingBarFull_SrcRect.top=0;
LoadingBarFull_SrcRect.bottom=0;
LoadingBarFull_DestRect.left=0;
LoadingBarFull_DestRect.right=0;
LoadingBarFull_DestRect.top=0;
LoadingBarFull_DestRect.bottom=0;
}
/* FlipBuffers(); */
InGameFlipBuffers();
Draw_Progress_Bar();
FrameCounterHandler();
/* If in a network game then we may as well check the network messages while waiting*/
if(AvP.Network != I_No_Network)
{
@ -321,13 +286,16 @@ void Game_Has_Loaded(void)
}
while(!DebouncedGotAnyKey);
while (0);
FadingGameInAfterLoading=ONE_FIXED;
if (LoadingBarFull)
{
if (LoadingBarFull != NULL) {
ReleaseDDSurface(LoadingBarFull);
LoadingBarFull = NULL;
}
if (LoadingBarEmpty != NULL) {
ReleaseDDSurface(LoadingBarEmpty);
LoadingBarEmpty = NULL;
}
}

View file

@ -612,11 +612,6 @@ int SetOGLVideoMode(int Width, int Height)
SDL_ShowCursor(0);
pglViewport(0, 0, Width, Height);
pglMatrixMode(GL_PROJECTION);
pglLoadIdentity();
pglMatrixMode(GL_MODELVIEW);
pglLoadIdentity();
pglEnable(GL_BLEND);
pglBlendFunc(GL_SRC_ALPHA, GL_ONE);
@ -628,8 +623,6 @@ int SetOGLVideoMode(int Width, int Height)
pglEnable(GL_TEXTURE_2D);
pglPolygonMode(GL_FRONT, GL_FILL);
pglPolygonMode(GL_BACK, GL_FILL);
pglDisable(GL_CULL_FACE);
pglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

View file

@ -45,9 +45,20 @@
#include "version.h"
#include "fmv.h"
#if defined(__IPHONEOS__) || defined(__ANDROID__)
#define FIXED_WINDOW_SIZE 1
#endif
#if defined(__IPHONEOS__) || defined(__ANDROID__)
#define USE_OPENGL_ES 1
#endif
void RE_ENTRANT_QUEUE_WinProc_AddMessage_WM_CHAR(char Ch);
void RE_ENTRANT_QUEUE_WinProc_AddMessage_WM_KEYDOWN(int wParam);
static int SDLCALL SDLEventFilter(void* userData, SDL_Event* event);
char LevelName[] = {"predbit6\0QuiteALongNameActually"}; /* the real way to load levels */
int DebouncedGotAnyKey;
@ -72,15 +83,39 @@ SDL_Joystick *joy;
JOYINFOEX JoystickData;
JOYCAPS JoystickCaps;
/* defaults */
// Window configuration and state
static int WindowWidth;
static int WindowHeight;
static int ViewportWidth;
static int ViewportHeight;
enum RENDERING_MODE {
RENDERING_MODE_SOFTWARE,
RENDERING_MODE_OPENGL
};
enum RENDERING_MODE RenderingMode;
#if defined(FIXED_WINDOW_SIZE)
static int WantFullscreen = 1;
static int WantFullscreenToggle = 0;
static int WantResolutionChange = 0;
static int WantMouseGrab = 1;
#else
static int WantFullscreen = 0;
static int WantFullscreenToggle = 1;
static int WantResolutionChange = 1;
static int WantMouseGrab = 0;
#endif
// Additional configuration
int WantSound = 1;
static int WantCDRom = 0;
static int WantJoystick = 0;
static int ViewportWidth;
static int ViewportHeight;
static GLuint FullscreenTexture;
static GLsizei FullscreenTextureWidth;
static GLsizei FullscreenTextureHeight;
/* originally was "/usr/lib/libGL.so.1:/usr/lib/tls/libGL.so.1:/usr/X11R6/lib/libGL.so" */
static const char * opengl_library = NULL;
@ -171,21 +206,24 @@ void ReadJoysticks()
unsigned char *GetScreenShot24(int *width, int *height)
{
#if 0//REVIEW
unsigned char *buf;
// Uint16 redtable[256], greentable[256], bluetable[256];
if (surface == NULL) {
return NULL;
}
buf = (unsigned char *)malloc(surface->w * surface->h * 3);
if (surface->flags & SDL_WINDOW_OPENGL) {
if (RenderingMode == RENDERING_MODE_OPENGL) {
buf = (unsigned char *)malloc(ViewportWidth * ViewportHeight * 3);
*width = ViewportWidth;
*height = ViewportHeight;
pglPixelStorei(GL_PACK_ALIGNMENT, 1);
pglPixelStorei(GL_UNPACK_ALIGNMENT, 1);
pglReadPixels(0, 0, surface->w, surface->h, GL_RGB, GL_UNSIGNED_BYTE, buf);
pglReadPixels(0, 0, ViewportWidth, ViewportHeight, GL_RGB, GL_UNSIGNED_BYTE, buf);
} else {
buf = (unsigned char *)malloc(surface->w * surface->h * 3);
unsigned char *ptrd;
unsigned short int *ptrs;
int x, y;
@ -213,15 +251,17 @@ unsigned char *GetScreenShot24(int *width, int *height)
}
}
*width = surface->w;
*height = surface->h;
if (SDL_MUSTLOCK(surface)) {
SDL_UnlockSurface(surface);
}
}
*width = surface->w;
*height = surface->h;
#if 0
#if 0
Uint16 redtable[256], greentable[256], bluetable[256];
if (SDL_GetGammaRamp(redtable, greentable, bluetable) != -1) {
unsigned char *ptr;
int i;
@ -234,10 +274,9 @@ unsigned char *GetScreenShot24(int *width, int *height)
ptr += 3;
}
}
#endif
return buf;
#endif
return NULL;
return buf;
}
/* ** */
@ -279,6 +318,16 @@ void LoadDeviceAndVideoModePreferences()
fp = OpenGameFile("AvP_TempVideo.cfg", FILEMODE_READONLY, FILETYPE_CONFIG);
if (fp != NULL) {
// fullscreen mode (0=window,1=fullscreen,2=fullscreen desktop)
// window width
// window height
// fullscreen width
// fullscreen height
// fullscreen desktop aspect ratio n
// fullscreen desktop aspect ratio d
// fullscreen desktop scale n
// fullscreen desktop scale d
// multisample number of samples (0/2/4)
if (fscanf(fp, "%d", &mode) == 1) {
fclose(fp);
@ -373,6 +422,8 @@ int InitSDL()
atexit(SDL_Quit);
SDL_AddEventWatch(SDLEventFilter, NULL);
#if 0
SDL_Rect **SDL_AvailableVideoModes;
SDL_AvailableVideoModes = SDL_ListModes(NULL, SDL_WINDOW_FULLSCREEN | SDL_WINDOW_OPENGL);
@ -480,10 +531,128 @@ int InitSDL()
return 0;
}
#if !defined(NDEBUG)
static void DumpVideoModeInfo(SDL_Window* w) {
int numVideoDisplays;
int displayIndex;
int numDisplayModes;
int modeIndex;
const char* displayName;
numVideoDisplays = SDL_GetNumVideoDisplays();
if (numVideoDisplays > 0) {
for (displayIndex = 0; displayIndex < numVideoDisplays; displayIndex++) {
displayName = SDL_GetDisplayName(displayIndex);
printf("%d: %s\n", displayIndex, displayName);
SDL_Rect bounds;
SDL_DisplayMode mode;
if (SDL_GetDisplayBounds(displayIndex, &bounds) == 0) {
printf("\tbounds: %4d,%4d,%4d,%4d\n",
bounds.x,
bounds.y,
bounds.w,
bounds.h);
}
if (SDL_GetDesktopDisplayMode(displayIndex, &mode) == 0) {
printf("\tdesktop: %08x,%4d,%4d,%d\n",
mode.format,
mode.w,
mode.h,
mode.refresh_rate);
}
if (SDL_GetCurrentDisplayMode(displayIndex, &mode) == 0) {
printf("\tcurrent: %08x,%4d,%4d,%d\n",
mode.format,
mode.w,
mode.h,
mode.refresh_rate);
}
numDisplayModes = SDL_GetNumDisplayModes(displayIndex);
for (modeIndex = 0; modeIndex < numDisplayModes; modeIndex++) {
if (SDL_GetDisplayMode(displayIndex, modeIndex, &mode) == 0) {
printf("\t%2d: %08x,%4d,%4d,%d\n",
modeIndex,
mode.format,
mode.w,
mode.h,
mode.refresh_rate);
}
}
}
}
if (w != NULL) {
int displayIndex;
SDL_DisplayMode mode;
displayIndex = SDL_GetWindowDisplayIndex(w);
printf("Window display index: %d\n", displayIndex);
if (SDL_GetWindowDisplayMode(w, &mode) == 0) {
printf("Window display mode: %08x,%4d,%4d,%d\n",
mode.format,
mode.w,
mode.h,
mode.refresh_rate);
}
}
}
#endif
static void SetWindowSize(int PhysicalWidth, int PhysicalHeight, int VirtualWidth, int VirtualHeight)
{
#if !defined(NDEBUG)
fprintf(stderr, "SetWindowSize(%d,%d,%d,%d); %d\n", PhysicalWidth, PhysicalHeight, VirtualWidth, VirtualHeight, CurrentVideoMode);
#endif
ViewportWidth = PhysicalWidth;
ViewportHeight = PhysicalHeight;
ScreenDescriptorBlock.SDB_Width = VirtualWidth;
ScreenDescriptorBlock.SDB_Height = VirtualHeight;
ScreenDescriptorBlock.SDB_CentreX = VirtualWidth/2;
ScreenDescriptorBlock.SDB_CentreY = VirtualHeight/2;
ScreenDescriptorBlock.SDB_ProjX = VirtualWidth/2;
ScreenDescriptorBlock.SDB_ProjY = VirtualHeight/2;
ScreenDescriptorBlock.SDB_ClipLeft = 0;
ScreenDescriptorBlock.SDB_ClipRight = VirtualWidth;
ScreenDescriptorBlock.SDB_ClipUp = 0;
ScreenDescriptorBlock.SDB_ClipDown = VirtualHeight;
if (window != NULL) {
SDL_SetWindowSize(window, PhysicalWidth, PhysicalHeight);
//pglViewport(0, 0, ViewportWidth, ViewportHeight);
}
#if !defined(NDEBUG)
DumpVideoModeInfo(window);
#endif
}
static int SetSoftVideoMode(int Width, int Height, int Depth)
{
//TODO: clear surface
RenderingMode = RENDERING_MODE_SOFTWARE;
ScanDrawMode = ScanDrawD3DHardwareRGB;
GotMouse = 1;
// reset input
IngameKeyboardInput_ClearBuffer();
SetWindowSize(ViewportWidth, ViewportHeight, Width, Height);
return 0;
}
/* ** */
static void load_opengl_library(const char *lib)
{
#if 0//REVIEW
char tmppath[PATH_MAX];
size_t len, copylen;
@ -499,9 +668,9 @@ static void load_opengl_library(const char *lib)
while (lib != NULL && *lib) {
len = strcspn(lib, ":");
copylen = min(len, PATH_MAX-1);
strncpy(tmppath, lib, copylen);
tmppath[copylen] = 0;
@ -516,33 +685,9 @@ static void load_opengl_library(const char *lib)
fprintf(stderr, "ERROR: unable to initialize opengl library: %s\n", SDL_GetError());
exit(EXIT_FAILURE);
#endif
}
int SetSoftVideoMode(int Width, int Height, int Depth)
{
//TODO: clear surface
ScanDrawMode = ScanDrawD3DHardwareRGB;
GotMouse = 1;
// reset input
IngameKeyboardInput_ClearBuffer();
ScreenDescriptorBlock.SDB_Width = Width;
ScreenDescriptorBlock.SDB_Height = Height;
ScreenDescriptorBlock.SDB_CentreX = Width/2;
ScreenDescriptorBlock.SDB_CentreY = Height/2;
ScreenDescriptorBlock.SDB_ProjX = Width/2;
ScreenDescriptorBlock.SDB_ProjY = Height/2;
ScreenDescriptorBlock.SDB_ClipLeft = 0;
ScreenDescriptorBlock.SDB_ClipRight = Width;
ScreenDescriptorBlock.SDB_ClipUp = 0;
ScreenDescriptorBlock.SDB_ClipDown = Height;
return 0;
}
/* ** */
static int SDLCALL SDLEventFilter(void* userData, SDL_Event* event) {
(void) userData;
@ -557,30 +702,45 @@ static int SDLCALL SDLEventFilter(void* userData, SDL_Event* event) {
return 1;
}
int SetOGLVideoMode(int Width, int Height)
static int InitSDLVideo(void) {
return 0;
}
static int SetOGLVideoMode(int Width, int Height)
{
int oldflags;
int flags;
RenderingMode = RENDERING_MODE_OPENGL;
ScanDrawMode = ScanDrawD3DHardwareRGB;
GotMouse = 1;
#if defined(FIXED_WINDOW_SIZE)
// force the game to use the full desktop
SDL_DisplayMode dm;
if (SDL_GetDesktopDisplayMode(0, &dm) == 0) {
Width = dm.w;
Height = dm.h;
}
#endif
if (window == NULL) {
load_ogl_functions(0);
/*
if (window != NULL) {
oldflags = SDL_GetWindowFlags(window);
SDL_DestroyWindow(window);
}
*/
flags = SDL_WINDOW_OPENGL;
#if defined(FIXED_WINDOW_SIZE)
flags |= SDL_WINDOW_BORDERLESS;
flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
#else
if (WantFullscreen) {
flags |= SDL_WINDOW_FULLSCREEN;
flags |= (WantResolutionChange != 0 ? SDL_WINDOW_FULLSCREEN : SDL_WINDOW_FULLSCREEN_DESKTOP);
}
// the game doesn't properly support window resizing
//flags |= SDL_WINDOW_RESIZABLE;
#endif
// reset input
IngameKeyboardInput_ClearBuffer();
@ -588,27 +748,35 @@ int SetOGLVideoMode(int Width, int Height)
SDL_QuitSubSystem(SDL_INIT_VIDEO);
SDL_InitSubSystem(SDL_INIT_VIDEO);
load_opengl_library(opengl_library);
// set OpenGL attributes first
#if defined(USE_OPENGL_ES)
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
#else
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
#endif
// These should be configurable video options.
// If user requests 8bpp, try that, else fall back to 5.
// Same with depth. Try 32, 24, 16.
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
load_opengl_library(opengl_library);
// These should be configurable video options.
//SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
//SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4);
SDL_GL_SetSwapInterval(1);
window = SDL_CreateWindow("Aliens vs Predator",
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
Width,
Height,
WindowWidth,
WindowHeight,
flags);
if (window == NULL) {
fprintf(stderr, "(OpenGL) SDL SDL_CreateWindow failed: %s\n", SDL_GetError());
@ -622,27 +790,41 @@ int SetOGLVideoMode(int Width, int Height)
}
SDL_GL_MakeCurrent(window, context);
SDL_AddEventWatch(SDLEventFilter, NULL); //TODO move this to startup?
// These should be configurable video options.
SDL_GL_SetSwapInterval(1);
load_ogl_functions(1);
///* this is for supporting keyboard input processing with little hassle */
//SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
//SDL_SetRelativeMouseMode(isgrab);
SDL_GetWindowSize(window, &Width, &Height);
pglViewport(0, 0, Width, Height);
// create fullscreen window texture
pglGenTextures(1, &FullscreenTexture);
pglBindTexture(GL_TEXTURE_2D, FullscreenTexture);
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
FullscreenTextureWidth = 1024;
FullscreenTextureHeight = 512;
pglTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, FullscreenTextureWidth, FullscreenTextureHeight, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, NULL);
}
SDL_GetWindowSize(window, &Width, &Height);
ViewportWidth = Width;
ViewportHeight = Height;
SDL_SetWindowSize(window, Width, Height);
pglViewport(0, 0, Width, Height);
pglMatrixMode(GL_PROJECTION);
pglLoadIdentity();
pglMatrixMode(GL_MODELVIEW);
pglLoadIdentity();
SetWindowSize(Width, Height, Width, Height);
int NewWidth, NewHeight;
SDL_GetWindowSize(window, &Width, &Height);
if (Width != NewWidth || Height != NewHeight) {
//printf("Failed to change size: %d,%d vs. %d,%d\n", Width, Height, NewWidth, NewHeight);
//Width = NewWidth;
//Height = NewHeight;
//SetWindowSize(Width, Height, Width, Height);
}
pglEnable(GL_BLEND);
pglBlendFunc(GL_SRC_ALPHA, GL_ONE);
@ -654,22 +836,9 @@ int SetOGLVideoMode(int Width, int Height)
pglEnable(GL_TEXTURE_2D);
pglPolygonMode(GL_FRONT, GL_FILL);
pglPolygonMode(GL_BACK, GL_FILL);
pglDisable(GL_CULL_FACE);
pglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
ScreenDescriptorBlock.SDB_Width = Width;
ScreenDescriptorBlock.SDB_Height = Height;
ScreenDescriptorBlock.SDB_CentreX = Width/2;
ScreenDescriptorBlock.SDB_CentreY = Height/2;
ScreenDescriptorBlock.SDB_ProjX = Width/2;
ScreenDescriptorBlock.SDB_ProjY = Height/2;
ScreenDescriptorBlock.SDB_ClipLeft = 0;
ScreenDescriptorBlock.SDB_ClipRight = Width;
ScreenDescriptorBlock.SDB_ClipUp = 0;
ScreenDescriptorBlock.SDB_ClipDown = Height;
InitOpenGL();
@ -687,6 +856,11 @@ int ExitWindowsSystem()
SDL_JoystickClose(joy);
}
if (FullscreenTexture != 0) {
pglDeleteTextures(1, &FullscreenTexture);
}
FullscreenTexture = 0;
load_ogl_functions(0);
if (surface != NULL) {
@ -941,6 +1115,9 @@ static void handle_keypress(int key, int unicode, int press)
if (press) {
switch(key) {
case KEY_CR:
RE_ENTRANT_QUEUE_WinProc_AddMessage_WM_CHAR('\r');
break;
case KEY_BACKSPACE:
RE_ENTRANT_QUEUE_WinProc_AddMessage_WM_KEYDOWN(VK_BACK);
break;
@ -986,33 +1163,6 @@ static void handle_keypress(int key, int unicode, int press)
KeyboardInput[key] = press;
}
static void handle_buttonpress(int button, int press)
{
int key;
switch(button) {
case 4: /* mouse wheel up */
key = KEY_MOUSEWHEELUP;
break;
case 5: /* mouse wheel down */
key = KEY_MOUSEWHEELDOWN;
break;
default: /* other buttons are handled elsewhere */
return;
}
/* since this currently only handles wheel up/down */
if (press == 0)
return;
if (press && !KeyboardInput[key]) {
DebouncedKeyboardInput[key] = 1;
}
GotAnyKey = 1;
KeyboardInput[key] = press;
}
void CheckForWindowsMessages()
{
SDL_Event event;
@ -1022,52 +1172,77 @@ void CheckForWindowsMessages()
DebouncedGotAnyKey = 0;
memset(DebouncedKeyboardInput, 0, sizeof(DebouncedKeyboardInput));
wantmouse = 0; //(surface->flags & SDL_FULLSCREEN) ||
//(SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_ON);
wantmouse = (SDL_GetRelativeMouseMode() == SDL_TRUE);
// "keyboard" events that don't have an up event
KeyboardInput[KEY_MOUSEWHEELUP] = 0;
KeyboardInput[KEY_MOUSEWHEELDOWN] = 0;
if (SDL_PollEvent(&event)) {
do {
switch(event.type) {
case SDL_MOUSEBUTTONDOWN:
if (wantmouse)
handle_buttonpress(event.button.button, 1);
break;
case SDL_MOUSEBUTTONUP:
break;
case SDL_TEXTINPUT: {
int unicode = event.text.text[0]; //TODO convert to utf-32
if (unicode && !(unicode & 0xFF80)) {
RE_ENTRANT_QUEUE_WinProc_AddMessage_WM_CHAR(unicode);
KeyboardEntryQueue_Add(unicode);
while (SDL_PollEvent(&event)) {
switch(event.type) {
case SDL_MOUSEBUTTONDOWN:
break;
case SDL_MOUSEBUTTONUP:
break;
case SDL_MOUSEWHEEL:
if (wantmouse) {
if (event.wheel.y < 0) {
handle_keypress(KEY_MOUSEWHEELDOWN, 0, 1);
} else if (event.wheel.y > 0) {
handle_keypress(KEY_MOUSEWHEELUP, 0, 1);
}
}
break;
case SDL_TEXTINPUT: {
int unicode = event.text.text[0]; //TODO convert to utf-32
if (unicode && !(unicode & 0xFF80)) {
RE_ENTRANT_QUEUE_WinProc_AddMessage_WM_CHAR(unicode);
KeyboardEntryQueue_Add(unicode);
}
}
break;
case SDL_KEYDOWN:
if (event.key.keysym.sym == SDLK_PRINTSCREEN) {
if (HavePrintScn == 0)
GotPrintScn = 1;
HavePrintScn = 1;
} else {
handle_keypress(KeySymToKey(event.key.keysym.sym), 0, 1);
}
break;
case SDL_KEYUP:
if (event.key.keysym.sym == SDLK_PRINTSCREEN) {
GotPrintScn = 0;
HavePrintScn = 0;
} else {
handle_keypress(KeySymToKey(event.key.keysym.sym), 0, 0);
}
break;
case SDL_WINDOWEVENT:
switch (event.window.event) {
case SDL_WINDOWEVENT_FOCUS_LOST:
// disable mouse grab?
break;
case SDL_WINDOWEVENT_RESIZED:
//printf("test, %d,%d\n", event.window.data1, event.window.data2);
WindowWidth = event.window.data1;
WindowHeight = event.window.data2;
if (RenderingMode == RENDERING_MODE_SOFTWARE) {
SetWindowSize(WindowWidth, WindowHeight, 640, 480);
} else {
SetWindowSize(WindowWidth, WindowHeight, WindowWidth, WindowHeight);
}
}
break;
case SDL_KEYDOWN:
if (event.key.keysym.sym == SDLK_PRINTSCREEN) {
if (HavePrintScn == 0)
GotPrintScn = 1;
HavePrintScn = 1;
} else {
handle_keypress(KeySymToKey(event.key.keysym.sym), 0, 1);
}
break;
case SDL_KEYUP:
if (event.key.keysym.sym == SDLK_PRINTSCREEN) {
GotPrintScn = 0;
HavePrintScn = 0;
} else {
handle_keypress(KeySymToKey(event.key.keysym.sym), 0, 0);
}
break;
case SDL_QUIT:
AvP.MainLoopRunning = 0; /* TODO */
exit(0); //TODO
break;
}
} while (SDL_PollEvent(&event));
if (pglViewport != NULL) {
pglViewport(0, 0, WindowWidth, WindowHeight);
}
break;
}
break;
case SDL_QUIT:
AvP.MainLoopRunning = 0; /* TODO */
exit(0); //TODO
break;
}
}
buttons = SDL_GetRelativeMouseState(&x, &y);
@ -1085,7 +1260,7 @@ void CheckForWindowsMessages()
handle_keypress(KEY_RMOUSE, 0, 1);
else
handle_keypress(KEY_RMOUSE, 0, 0);
MouseVelX = DIV_FIXED(x, NormalFrameTime);
MouseVelY = DIV_FIXED(y, NormalFrameTime);
} else {
@ -1117,31 +1292,47 @@ void CheckForWindowsMessages()
}
}
//#warning Redo WantX, need to split it out better so fullscreen can temporary set relative without clobbering user setting
if ((KeyboardInput[KEY_LEFTALT]||KeyboardInput[KEY_RIGHTALT]) && DebouncedKeyboardInput[KEY_CR]) {
//SDL_GrabMode gm;
//
//SDL_WM_ToggleFullScreen(surface);
//
//gm = SDL_WM_GrabInput(SDL_GRAB_QUERY);
//if (gm == SDL_GRAB_OFF && !(surface->flags & SDL_FULLSCREEN))
// SDL_ShowCursor(1);
//else
// SDL_ShowCursor(0);
if (WantFullscreenToggle != 0) {
int displayMode = SDL_GetWindowFlags(window);
//printf("Current window mode:%08x\n", displayMode);
if ((displayMode & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_FULLSCREEN_DESKTOP)) != 0) {
SDL_SetWindowFullscreen(window, 0);
} else {
SDL_SetWindowFullscreen(window, WantResolutionChange ? SDL_WINDOW_FULLSCREEN : SDL_WINDOW_FULLSCREEN_DESKTOP);
}
displayMode = SDL_GetWindowFlags(window);
//printf("New window mode:%08x\n", displayMode);
if ((displayMode & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_FULLSCREEN_DESKTOP)) != 0) {
SDL_SetRelativeMouseMode(SDL_TRUE);
WantFullscreen = 1;
} else {
SDL_SetRelativeMouseMode(WantMouseGrab ? SDL_TRUE : SDL_FALSE);
WantFullscreen = 0;
}
}
}
if (KeyboardInput[KEY_LEFTCTRL] && DebouncedKeyboardInput[KEY_G]) {
//SDL_GrabMode gm;
//
//gm = SDL_WM_GrabInput(SDL_GRAB_QUERY);
//SDL_WM_GrabInput((gm == SDL_GRAB_ON) ? SDL_GRAB_OFF : SDL_GRAB_ON);
//
//gm = SDL_WM_GrabInput(SDL_GRAB_QUERY);
//if (gm == SDL_GRAB_OFF && !(surface->flags & SDL_FULLSCREEN))
// SDL_ShowCursor(1);
//else
// SDL_ShowCursor(0);
int IsWindowed = (SDL_GetWindowFlags(window) & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_FULLSCREEN_DESKTOP)) == 0;
if (IsWindowed) {
WantMouseGrab = WantMouseGrab != 0 ? 0 : 1;
if (WantMouseGrab != 0) {
SDL_SetRelativeMouseMode(SDL_TRUE);
} else {
SDL_SetRelativeMouseMode(SDL_FALSE);
}
WantMouseGrab = (SDL_GetRelativeMouseMode() == SDL_TRUE);
}
}
// a second reset of relative mouse state because
// enabling relative mouse mode moves the mouse
SDL_GetRelativeMouseState(NULL, NULL);
if (GotPrintScn) {
GotPrintScn = 0;
@ -1151,45 +1342,24 @@ void CheckForWindowsMessages()
void InGameFlipBuffers()
{
if (window != NULL) {
SDL_GL_SwapWindow(window);
}
#if !defined(NDEBUG)
check_for_errors();
#endif
SDL_GL_SwapWindow(window);
}
void FlipBuffers()
{
// TODO: move this to init
static GLuint t;
if (t == 0) {
pglGenTextures(1, &t);
pglBindTexture(GL_TEXTURE_2D, t);
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
pglTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 640, 480, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, NULL);
}
pglDisableClientState(GL_VERTEX_ARRAY);
pglDisableClientState(GL_TEXTURE_COORD_ARRAY);
pglDisableClientState(GL_COLOR_ARRAY);
pglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
pglMatrixMode(GL_PROJECTION);
pglLoadIdentity();
pglMatrixMode(GL_MODELVIEW);
pglLoadIdentity();
pglDisable(GL_ALPHA_TEST);
pglDisable(GL_BLEND);
pglDisable(GL_DEPTH_TEST);
pglBindTexture(GL_TEXTURE_2D, t);
pglBindTexture(GL_TEXTURE_2D, FullscreenTexture);
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
pglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
pglTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 640, 480, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, surface->pixels);
@ -1197,6 +1367,10 @@ void FlipBuffers()
GLfloat x1;
GLfloat y0;
GLfloat y1;
GLfloat s0;
GLfloat s1;
GLfloat t0;
GLfloat t1;
// figure out the best way to fit the 640x480 virtual window
GLfloat a = ViewportHeight * 640.0f / 480.0f;
@ -1218,24 +1392,55 @@ void FlipBuffers()
y0 = -y1;
}
pglBegin(GL_QUADS);
s0 = 0.0f;
s1 = 640.0f / (float) FullscreenTextureWidth;
t0 = 0.0f;
t1 = 480.0f / (float) FullscreenTextureHeight;
pglTexCoord2f(0.0, 1.0);
pglVertex3f(x0, y0, -1.0);
GLfloat v[4*4];
GLshort s[6];
pglTexCoord2f(1.0, 1.0);
pglVertex3f(x1, y0, -1.0);
v[0+0*4] = x0;
v[1+0*4] = y0;
v[2+0*4] = s0;
v[3+0*4] = t1;
v[0+1*4] = x1;
v[1+1*4] = y0;
v[2+1*4] = s1;
v[3+1*4] = t1;
v[0+2*4] = x1;
v[1+2*4] = y1;
v[2+2*4] = s1;
v[3+2*4] = t0;
v[0+3*4] = x0;
v[1+3*4] = y1;
v[2+3*4] = s0;
v[3+3*4] = t0;
pglTexCoord2f(1.0, 0.0);
pglVertex3f(x1, y1, -1.0);
s[0] = 0;
s[1] = 1;
s[2] = 2;
s[3] = 0;
s[4] = 2;
s[5] = 3;
pglTexCoord2f(0.0, 0.0);
pglVertex3f(x0, y1, -1.0);
pglEnableClientState(GL_VERTEX_ARRAY);
pglVertexPointer(2, GL_FLOAT, sizeof(GLfloat) * 4, &v[0]);
pglEnd();
pglEnableClientState(GL_TEXTURE_COORD_ARRAY);
pglTexCoordPointer(2, GL_FLOAT, sizeof(GLfloat) * 4, &v[2]);
pglDisableClientState(GL_COLOR_ARRAY);
pglColor4f(1.0f, 1.0f, 1.0f, 1.0f);
pglDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, s);
pglBindTexture(GL_TEXTURE_2D, 0);
#if !defined(NDEBUG)
check_for_errors();
#endif
SDL_GL_SwapWindow(window);
}
@ -1339,10 +1544,9 @@ int main(int argc, char *argv[])
#endif
InitGame();
//NEW
SetOGLVideoMode(VideoModeList[1].w, VideoModeList[1].h);
//NEW
WindowWidth = VideoModeList[CurrentVideoMode].w;
WindowHeight = VideoModeList[CurrentVideoMode].h;
SetOGLVideoMode(0, 0);
SetSoftVideoMode(640, 480, 16);
InitialVideoMode();
@ -1391,16 +1595,8 @@ if (AvP_MainMenus())
/* turn off any special effects */
d3d_light_ctrl.ctrl = LCCM_NORMAL;
//NEW
//TODO
// need to watch for CurrentVideoMode to change in all cases
// the menu will always render in a 640x480 virtual window
// game will render in a user-specified virtual window
// real window will be which ever size is available
//TODO
//NEW
SetOGLVideoMode(VideoModeList[CurrentVideoMode].w, VideoModeList[CurrentVideoMode].h);
SetOGLVideoMode(0, 0);
InitialiseGammaSettings(RequestedGammaSetting);

View file

@ -1,6 +1,7 @@
#include <math.h>
#include "3dc.h"
#include "mathline.h"
void ADD_LL(LONGLONGCH *a, LONGLONGCH *b, LONGLONGCH *c);
void ADD_LL_PP(LONGLONGCH *c, LONGLONGCH *a);
@ -12,21 +13,13 @@ void EQUALS_LL(LONGLONGCH *a, LONGLONGCH *b);
void NEG_LL(LONGLONGCH *a);
void ASR_LL(LONGLONGCH *a, int shift);
void IntToLL(LONGLONGCH *a, int *b);
int MUL_FIXED(int a, int b);
int DIV_FIXED(int a, int b);
#define DIV_INT(a, b) ((a) / (b))
int NarrowDivide(LONGLONGCH *a, int b);
int WideMulNarrowDiv(int a, int b, int c);
void RotateVector_ASM(VECTORCH *v, MATRIXCH *m);
void RotateAndCopyVector_ASM(VECTORCH *v1, VECTORCH *v2, MATRIXCH *m);
#if 0
int FloatToInt(float);
#define f2i(a, b) { a = FloatToInt(b); }
#endif
#undef ASM386
#if !defined(ASM386)
@ -450,63 +443,10 @@ __asm__("movl 0(%%esi), %%eax \n\t"
#endif
}
/*
Fixed Point Multiply.
16.16 * 16.16 -> 16.16
or
16.16 * 0.32 -> 0.32
A proper version of this function ought to read
16.16 * 16.16 -> 32.16
but this would require a __int64 result
Algorithm:
Take the mid 32 bits of the 64 bit result
*/
/*
These functions have been checked for suitability for
a Pentium and look as if they would work adequately.
Might be worth a more detailed look at optimising
them though.
*/
int MUL_FIXED(int a, int b)
{
/*
int retval;
_asm
{
mov eax,a
imul b
shrd eax,edx,16
mov retval,eax
}
*/
#if defined(ASM386)
int retval;
__asm__("imull %2 \n\t"
"shrdl $16, %%edx, %%eax \n\t"
: "=a" (retval)
: "0" (a), "m" (b)
: "%edx", "cc"
);
return retval;
#else
__int64 aa = (__int64) a;
__int64 bb = (__int64) b;
__int64 cc = aa * bb;
return (int) ((cc >> 16) & 0xffffffff);
#endif
}
//
// Fixed Point Multiply - MUL_FIXED
// See mathline.h
//
/*
@ -561,17 +501,6 @@ __asm__("cdq \n\t"
*/
/*
32/32 division
This macro is a function on some other platforms
*/
#define DIV_INT(a, b) ((a) / (b))
/*
A Narrowing 64/32 Division
@ -687,31 +616,7 @@ __asm__ volatile
return sqrt_temp;
#else
return (int) sqrt( (float)A );
#endif
}
/*
This may look ugly (it is) but it is a MUCH faster way to convert "float" into "int" than
the function call "CHP" used by the WATCOM compiler.
*/
volatile float fti_fptmp;
volatile int fti_itmp;
void FloatToInt()
{
#if defined(ASM386)
__asm__ volatile
("flds fti_fptmp \n\t"
"fistpl fti_itmp \n\t"
:
:
: "memory", "cc"
);
#else
fti_itmp = (int)fti_fptmp;
float fA = A;
return lrintf(sqrtf(fA));
#endif
}

66
src/mathline.h Normal file
View file

@ -0,0 +1,66 @@
#ifndef MATHLINE_H
#define MATHLINE_H
#include <math.h>
#define f2i(a, b) a = lrintf(b)
/*
Fixed Point Multiply.
16.16 * 16.16 -> 16.16
or
16.16 * 0.32 -> 0.32
A proper version of this function ought to read
16.16 * 16.16 -> 32.16
but this would require a __int64 result
Algorithm:
Take the mid 32 bits of the 64 bit result
*/
/*
These functions have been checked for suitability for
a Pentium and look as if they would work adequately.
Might be worth a more detailed look at optimising
them though.
*/
static inline int MUL_FIXED(int a, int b)
{
/*
int retval;
_asm
{
mov eax,a
imul b
shrd eax,edx,16
mov retval,eax
}
*/
#if defined(ASM386)
int retval;
__asm__("imull %2 \n\t"
"shrdl $16, %%edx, %%eax \n\t"
: "=a" (retval)
: "0" (a), "m" (b)
: "%edx", "cc"
);
return retval;
#else
__int64 aa = (__int64) a;
__int64 bb = (__int64) b;
__int64 cc = aa * bb;
return (int) ((cc >> 16) & 0xffffffff);
#endif
}
#endif

View file

@ -115,13 +115,6 @@ AVPMENUGFX AvPMenuGfxStorage[MAX_NO_OF_AVPMENUGFXS] =
#endif
};
int CreateIMGSurface(D3DTexture *tex, unsigned char *buf)
{
tex->id = 0;
return 0;
}
static void DrawAvPMenuGlowyBar(int topleftX, int topleftY, int alpha, int length)
{
enum AVPMENUGFX_ID menuGfxID = AVPMENUGFX_GLOWY_MIDDLE;
@ -449,17 +442,25 @@ int RenderMenuText(const char *textPtr, int sx, int sy, int alpha, enum AVPMENUF
char c = *textPtr++;
if (c>=' ') {
int topLeftU = 1;
int topLeftV = 1+(c-32)*33;
int x, y;
int width = IntroFont_Light.FontWidth[(unsigned int) c];
unsigned int topLeftU = 0;
unsigned int topLeftV = 1+(c-32)*33;
unsigned int x, y;
unsigned int width = IntroFont_Light.FontWidth[(unsigned int) c];
unsigned int remainder = 0;
unsigned int stride = width;
if (image->w > width) {
remainder = image->w - width;
} else {
stride = image->w;
}
srcPtr = &image->buf[(topLeftU+topLeftV*image->w)*4];
for (y=sy; y<33+sy; y++) {
destPtr = (unsigned short *)(((unsigned char *)surface->pixels)+y*surface->pitch) + sx;
for (x=width; x>0; x--) {
for (x=stride; x>0; x--) {
if (srcPtr[0] || srcPtr[1] || srcPtr[2]) {
unsigned int destR, destG, destB;
@ -484,7 +485,7 @@ int RenderMenuText(const char *textPtr, int sx, int sy, int alpha, enum AVPMENUF
srcPtr += 4;
destPtr++;
}
srcPtr += (image->w - width) * 4;
srcPtr += remainder * 4;
}
sx += width;
}
@ -546,18 +547,26 @@ int RenderMenuText_Clipped(char *textPtr, int sx, int sy, int alpha, enum AVPMEN
char c = *textPtr++;
if (c>=' ') {
int topLeftU = 1;
int topLeftV = 1+(c-32)*33;
int x, y;
int width = IntroFont_Light.FontWidth[(unsigned int) c];
unsigned int topLeftU = 0;
unsigned int topLeftV = 1+(c-32)*33;
unsigned int x, y;
unsigned int width = IntroFont_Light.FontWidth[(unsigned int) c];
unsigned int remainder = 0;
unsigned int stride = width;
if (image->w > width) {
remainder = image->w - width;
} else {
stride = image->w;
}
srcPtr = &image->buf[(topLeftU+topLeftV*image->w)*4];
for (y=sy; y<33+sy; y++) {
if(y>=topY && y<=bottomY) {
destPtr = (unsigned short *)(((unsigned char *)surface->pixels)+y*surface->pitch) + sx;
for (x=width; x>0; x--) {
for (x=stride; x>0; x--) {
if (srcPtr[0] || srcPtr[1] || srcPtr[2]) {
unsigned int destR, destG, destB;
@ -582,7 +591,7 @@ int RenderMenuText_Clipped(char *textPtr, int sx, int sy, int alpha, enum AVPMEN
srcPtr += 4;
destPtr++;
}
srcPtr += (image->w - width) * 4;
srcPtr += remainder * 4;
} else {
srcPtr += image->w * 4;
}

View file

@ -6,20 +6,11 @@
#include "oglfunc.h"
PFNGLALPHAFUNCPROC pglAlphaFunc;
PFNGLARRAYELEMENTPROC pglArrayElement;
PFNGLBEGINPROC pglBegin;
PFNGLBINDTEXTUREPROC pglBindTexture;
PFNGLBLENDFUNCPROC pglBlendFunc;
PFNGLCLEARPROC pglClear;
PFNGLCLEARCOLORPROC pglClearColor;
PFNGLCOLOR3FPROC pglColor3f;
PFNGLCOLOR3FVPROC pglColor3fv;
PFNGLCOLOR3UBPROC pglColor3ub;
PFNGLCOLOR3UBVPROC pglColor3ubv;
PFNGLCOLOR4FPROC pglColor4f;
PFNGLCOLOR4FVPROC pglColor4fv;
PFNGLCOLOR4UBPROC pglColor4ub;
PFNGLCOLOR4UBVPROC pglColor4ubv;
PFNGLCOLORPOINTERPROC pglColorPointer;
PFNGLCULLFACEPROC pglCullFace;
PFNGLDELETETEXTURESPROC pglDeleteTextures;
@ -28,15 +19,10 @@ PFNGLDEPTHMASKPROC pglDepthMask;
PFNGLDEPTHRANGEPROC pglDepthRange;
PFNGLDISABLEPROC pglDisable;
PFNGLDISABLECLIENTSTATEPROC pglDisableClientState;
PFNGLDRAWBUFFERPROC pglDrawBuffer;
PFNGLDRAWELEMENTSPROC pglDrawElements;
PFNGLDRAWPIXELSPROC pglDrawPixels;
PFNGLDRAWRANGEELEMENTSPROC pglDrawRangeElements;
PFNGLENABLEPROC pglEnable;
PFNGLENABLECLIENTSTATEPROC pglEnableClientState;
PFNGLENDPROC pglEnd;
PFNGLFRONTFACEPROC pglFrontFace;
PFNGLFRUSTUMPROC pglFrustum;
PFNGLGENTEXTURESPROC pglGenTextures;
PFNGLGETERRORPROC pglGetError;
PFNGLGETFLOATVPROC pglGetFloatv;
@ -44,34 +30,10 @@ PFNGLGETINTEGERVPROC pglGetIntegerv;
PFNGLGETSTRINGPROC pglGetString;
PFNGLGETTEXPARAMETERFVPROC pglGetTexParameterfv;
PFNGLHINTPROC pglHint;
PFNGLLOADIDENTITYPROC pglLoadIdentity;
PFNGLLOADMATRIXFPROC pglLoadMatrixf;
PFNGLMATRIXMODEPROC pglMatrixMode;
PFNGLMULTMATRIXFPROC pglMultMatrixf;
PFNGLNORMALPOINTERPROC pglNormalPointer;
PFNGLORTHOPROC pglOrtho;
PFNGLPIXELSTOREIPROC pglPixelStorei;
PFNGLPIXELZOOMPROC pglPixelZoom;
PFNGLPOLYGONMODEPROC pglPolygonMode;
PFNGLPOLYGONOFFSETPROC pglPolygonOffset;
PFNGLPOPATTRIBPROC pglPopAttrib;
PFNGLPOPCLIENTATTRIBPROC pglPopClientAttrib;
PFNGLPOPMATRIXPROC pglPopMatrix;
PFNGLPUSHATTRIBPROC pglPushAttrib;
PFNGLPUSHCLIENTATTRIBPROC pglPushClientAttrib;
PFNGLPUSHMATRIXPROC pglPushMatrix;
PFNGLRASTERPOS2IPROC pglRasterPos2i;
PFNGLREADBUFFERPROC pglReadBuffer;
PFNGLREADPIXELSPROC pglReadPixels;
PFNGLROTATEFPROC pglRotatef;
PFNGLSCALEFPROC pglScalef;
PFNGLSHADEMODELPROC pglShadeModel;
PFNGLTEXCOORD2FPROC pglTexCoord2f;
PFNGLTEXCOORD2FVPROC pglTexCoord2fv;
PFNGLTEXCOORD3FPROC pglTexCoord3f;
PFNGLTEXCOORD3FVPROC pglTexCoord3fv;
PFNGLTEXCOORD4FPROC pglTexCoord4f;
PFNGLTEXCOORD4FVPROC pglTexCoord4fv;
PFNGLTEXCOORDPOINTERPROC pglTexCoordPointer;
PFNGLTEXENVFPROC pglTexEnvf;
PFNGLTEXENVFVPROC pglTexEnvfv;
@ -80,50 +42,37 @@ PFNGLTEXIMAGE2DPROC pglTexImage2D;
PFNGLTEXPARAMETERFPROC pglTexParameterf;
PFNGLTEXPARAMETERIPROC pglTexParameteri;
PFNGLTEXSUBIMAGE2DPROC pglTexSubImage2D;
PFNGLTRANSLATEFPROC pglTranslatef;
PFNGLVERTEX2FPROC pglVertex2f;
PFNGLVERTEX2FVPROC pglVertex2fv;
PFNGLVERTEX3FPROC pglVertex3f;
PFNGLVERTEX3FVPROC pglVertex3fv;
PFNGLVERTEX4FPROC pglVertex4f;
PFNGLVERTEX4FVPROC pglVertex4fv;
PFNGLVERTEXPOINTERPROC pglVertexPointer;
PFNGLVIEWPORTPROC pglViewport;
// GL_EXT_paletted_texture
PFNGLCOLORTABLEEXTPROC pglColorTableEXT;
PFNGLGETCOLORTABLEPARAMETERIVEXTPROC pglGetColorTableParameterivEXT;
// GL_EXT_secondary_color
PFNGLSECONDARYCOLOR3FEXTPROC pglSecondaryColor3fEXT;
PFNGLSECONDARYCOLOR3FVEXTPROC pglSecondaryColor3fvEXT;
PFNGLSECONDARYCOLOR3UBEXTPROC pglSecondaryColor3ubEXT;
PFNGLSECONDARYCOLOR3UBVEXTPROC pglSecondaryColor3ubvEXT;
PFNGLSECONDARYCOLORPOINTEREXTPROC pglSecondaryColorPointerEXT;
int ogl_have_multisample_filter_hint;
int ogl_have_paletted_texture;
int ogl_have_secondary_color;
int ogl_have_texture_filter_anisotropic;
int ogl_use_multisample_filter_hint;
int ogl_use_paletted_texture;
int ogl_use_secondary_color;
int ogl_use_texture_filter_anisotropic;
static void dummyfunc()
{
}
#define LoadOGLProc(type, func) \
{ \
#define LoadOGLProc_(type, func, name) { \
if (!mode) p##func = (type) dummyfunc; else \
p##func = (type) SDL_GL_GetProcAddress(#func); \
p##func = (type) SDL_GL_GetProcAddress(#name); \
if (p##func == NULL) { \
if (!ogl_missing_func) ogl_missing_func = #func; \
} \
}
#define LoadOGLProc(type, func) \
LoadOGLProc_(type, func, func)
#define LoadOGLProc2(type, func1, func2) \
LoadOGLProc_(type, func1, func1); \
if (p##func1 == NULL) { \
ogl_missing_func = NULL; \
LoadOGLProc_(type, func1, func2); \
}
static int check_token(const char *string, const char *token)
{
const char *s = string;
@ -152,37 +101,23 @@ void load_ogl_functions(int mode)
ogl_missing_func = NULL;
LoadOGLProc(PFNGLALPHAFUNCPROC, glAlphaFunc);
LoadOGLProc(PFNGLARRAYELEMENTPROC, glArrayElement);
LoadOGLProc(PFNGLBEGINPROC, glBegin);
LoadOGLProc(PFNGLBINDTEXTUREPROC, glBindTexture);
LoadOGLProc(PFNGLBLENDFUNCPROC, glBlendFunc);
LoadOGLProc(PFNGLCLEARPROC, glClear);
LoadOGLProc(PFNGLCLEARCOLORPROC, glClearColor);
LoadOGLProc(PFNGLCOLOR3FPROC, glColor3f);
LoadOGLProc(PFNGLCOLOR3FVPROC, glColor3fv);
LoadOGLProc(PFNGLCOLOR3UBPROC, glColor3ub);
LoadOGLProc(PFNGLCOLOR3UBVPROC, glColor3ubv);
LoadOGLProc(PFNGLCOLOR4FPROC, glColor4f);
LoadOGLProc(PFNGLCOLOR4FVPROC, glColor4fv);
LoadOGLProc(PFNGLCOLOR4UBPROC, glColor4ub);
LoadOGLProc(PFNGLCOLOR4UBVPROC, glColor4ubv);
LoadOGLProc(PFNGLCOLORPOINTERPROC, glColorPointer);
LoadOGLProc(PFNGLCULLFACEPROC, glCullFace);
LoadOGLProc(PFNGLDELETETEXTURESPROC, glDeleteTextures);
LoadOGLProc(PFNGLDEPTHFUNCPROC, glDepthFunc);
LoadOGLProc(PFNGLDEPTHMASKPROC, glDepthMask);
LoadOGLProc(PFNGLDEPTHRANGEPROC, glDepthRange);
LoadOGLProc2(PFNGLDEPTHRANGEPROC, glDepthRange, glDepthRangef);
LoadOGLProc(PFNGLDISABLEPROC, glDisable);
LoadOGLProc(PFNGLDISABLECLIENTSTATEPROC, glDisableClientState);
LoadOGLProc(PFNGLDRAWBUFFERPROC, glDrawBuffer);
LoadOGLProc(PFNGLDRAWELEMENTSPROC, glDrawElements);
LoadOGLProc(PFNGLDRAWPIXELSPROC, glDrawPixels);
LoadOGLProc(PFNGLDRAWRANGEELEMENTSPROC, glDrawRangeElements);
LoadOGLProc(PFNGLENABLEPROC, glEnable);
LoadOGLProc(PFNGLENABLECLIENTSTATEPROC, glEnableClientState);
LoadOGLProc(PFNGLENDPROC, glEnd);
LoadOGLProc(PFNGLFRONTFACEPROC, glFrontFace);
LoadOGLProc(PFNGLFRUSTUMPROC, glFrustum);
LoadOGLProc(PFNGLGENTEXTURESPROC, glGenTextures);
LoadOGLProc(PFNGLGETERRORPROC, glGetError);
LoadOGLProc(PFNGLGETFLOATVPROC, glGetFloatv);
@ -190,34 +125,10 @@ void load_ogl_functions(int mode)
LoadOGLProc(PFNGLGETSTRINGPROC, glGetString);
LoadOGLProc(PFNGLGETTEXPARAMETERFVPROC, glGetTexParameterfv);
LoadOGLProc(PFNGLHINTPROC, glHint);
LoadOGLProc(PFNGLLOADIDENTITYPROC, glLoadIdentity);
LoadOGLProc(PFNGLLOADMATRIXFPROC, glLoadMatrixf);
LoadOGLProc(PFNGLMATRIXMODEPROC, glMatrixMode);
LoadOGLProc(PFNGLMULTMATRIXFPROC, glMultMatrixf);
LoadOGLProc(PFNGLNORMALPOINTERPROC, glNormalPointer);
LoadOGLProc(PFNGLORTHOPROC, glOrtho);
LoadOGLProc(PFNGLPIXELSTOREIPROC, glPixelStorei);
LoadOGLProc(PFNGLPIXELZOOMPROC, glPixelZoom);
LoadOGLProc(PFNGLPOLYGONMODEPROC, glPolygonMode);
LoadOGLProc(PFNGLPOLYGONOFFSETPROC, glPolygonOffset);
LoadOGLProc(PFNGLPOPATTRIBPROC, glPopAttrib);
LoadOGLProc(PFNGLPOPCLIENTATTRIBPROC, glPopClientAttrib);
LoadOGLProc(PFNGLPOPMATRIXPROC, glPopMatrix);
LoadOGLProc(PFNGLPUSHATTRIBPROC, glPushAttrib);
LoadOGLProc(PFNGLPUSHCLIENTATTRIBPROC, glPushClientAttrib);
LoadOGLProc(PFNGLPUSHMATRIXPROC, glPushMatrix);
LoadOGLProc(PFNGLRASTERPOS2IPROC, glRasterPos2i);
LoadOGLProc(PFNGLREADBUFFERPROC, glReadBuffer);
LoadOGLProc(PFNGLREADPIXELSPROC, glReadPixels);
LoadOGLProc(PFNGLROTATEFPROC, glRotatef);
LoadOGLProc(PFNGLSCALEFPROC, glScalef);
LoadOGLProc(PFNGLSHADEMODELPROC, glShadeModel);
LoadOGLProc(PFNGLTEXCOORD2FPROC, glTexCoord2f);
LoadOGLProc(PFNGLTEXCOORD2FVPROC, glTexCoord2fv);
LoadOGLProc(PFNGLTEXCOORD3FPROC, glTexCoord3f);
LoadOGLProc(PFNGLTEXCOORD3FVPROC, glTexCoord3fv);
LoadOGLProc(PFNGLTEXCOORD4FPROC, glTexCoord4f);
LoadOGLProc(PFNGLTEXCOORD4FVPROC, glTexCoord4fv);
LoadOGLProc(PFNGLTEXCOORDPOINTERPROC, glTexCoordPointer);
LoadOGLProc(PFNGLTEXENVFPROC, glTexEnvf);
LoadOGLProc(PFNGLTEXENVFVPROC, glTexEnvfv);
@ -226,23 +137,10 @@ void load_ogl_functions(int mode)
LoadOGLProc(PFNGLTEXPARAMETERFPROC, glTexParameterf);
LoadOGLProc(PFNGLTEXPARAMETERIPROC, glTexParameteri);
LoadOGLProc(PFNGLTEXSUBIMAGE2DPROC, glTexSubImage2D);
LoadOGLProc(PFNGLTRANSLATEFPROC, glTranslatef);
LoadOGLProc(PFNGLVERTEX2FPROC, glVertex2f);
LoadOGLProc(PFNGLVERTEX2FVPROC, glVertex2fv);
LoadOGLProc(PFNGLVERTEX3FPROC, glVertex3f);
LoadOGLProc(PFNGLVERTEX3FVPROC, glVertex3fv);
LoadOGLProc(PFNGLVERTEX4FPROC, glVertex4f);
LoadOGLProc(PFNGLVERTEX4FVPROC, glVertex4fv);
LoadOGLProc(PFNGLVERTEXPOINTERPROC, glVertexPointer);
LoadOGLProc(PFNGLVIEWPORTPROC, glViewport);
if (!mode) {
ogl_have_paletted_texture = 0;
ogl_have_secondary_color = 0;
ogl_use_paletted_texture = 0;
ogl_use_secondary_color = 0;
return;
}
@ -251,67 +149,24 @@ void load_ogl_functions(int mode)
exit(EXIT_FAILURE);
}
#if !defined(NDEBUG)
printf("GL_VENDOR: %s\n", pglGetString(GL_VENDOR));
printf("GL_RENDERER: %s\n", pglGetString(GL_RENDERER));
printf("GL_VERSION: %s\n", pglGetString(GL_VERSION));
//printf("GL_SHADING_LANGUAGE_VERSION: %s\n", pglGetString(GL_SHADING_LANGUAGE_VERSION));
printf("GL_EXTENSIONS: %s\n", pglGetString(GL_EXTENSIONS));
#endif
ext = (const char *) pglGetString(GL_EXTENSIONS);
ogl_have_multisample_filter_hint = check_token(ext, "GL_NV_multisample_filter_hint");
ogl_have_paletted_texture = check_token(ext, "GL_EXT_paletted_texture");
ogl_have_secondary_color = check_token(ext, "GL_EXT_secondary_color");
ogl_have_texture_filter_anisotropic = check_token(ext, "GL_EXT_texture_filter_anisotropic");
#ifndef GL_COLOR_TABLE_WIDTH_EXT
#define GL_COLOR_TABLE_WIDTH_EXT GL_COLOR_TABLE_WIDTH
#endif
if (ogl_have_paletted_texture) {
ogl_missing_func = NULL;
LoadOGLProc(PFNGLCOLORTABLEEXTPROC, glColorTableEXT);
LoadOGLProc(PFNGLGETCOLORTABLEPARAMETERIVEXTPROC, glGetColorTableParameterivEXT);
if (!ogl_missing_func) {
GLint size;
pglColorTableEXT(GL_PROXY_TEXTURE_2D, GL_RGBA, 256, GL_BGRA_EXT, GL_UNSIGNED_BYTE, NULL);
pglGetColorTableParameterivEXT(GL_PROXY_TEXTURE_2D, GL_COLOR_TABLE_WIDTH_EXT, &size);
if (size != 256) {
ogl_have_paletted_texture = 0;
}
} else {
ogl_have_paletted_texture = 0;
}
}
if (ogl_have_secondary_color) {
ogl_missing_func = NULL;
LoadOGLProc(PFNGLSECONDARYCOLOR3FEXTPROC, glSecondaryColor3fEXT);
LoadOGLProc(PFNGLSECONDARYCOLOR3FVEXTPROC, glSecondaryColor3fvEXT);
LoadOGLProc(PFNGLSECONDARYCOLOR3UBEXTPROC, glSecondaryColor3ubEXT);
LoadOGLProc(PFNGLSECONDARYCOLOR3UBVEXTPROC, glSecondaryColor3ubvEXT);
LoadOGLProc(PFNGLSECONDARYCOLORPOINTEREXTPROC, glSecondaryColorPointerEXT);
if (ogl_missing_func) {
ogl_have_secondary_color = 0;
}
}
ogl_use_multisample_filter_hint = ogl_have_multisample_filter_hint;
ogl_use_paletted_texture = ogl_have_paletted_texture;
ogl_use_secondary_color = ogl_have_secondary_color;
ogl_use_texture_filter_anisotropic = ogl_have_texture_filter_anisotropic;
#if 0
fprintf(stderr, "RENDER DEBUG: pal:%d sec:%d mfh:%d tfa:%d\n",
ogl_use_paletted_texture,
ogl_use_secondary_color,
ogl_use_multisample_filter_hint,
ogl_use_texture_filter_anisotropic
);
#endif
}
int check_for_errors(const char *file, int line)
int check_for_errors_(const char *file, int line)
{
GLenum error;
int diderror = 0;

View file

@ -5,25 +5,32 @@
#include <windows.h>
#endif
#if defined(USE_OPENGL_ES)
#include "SDL_opengles.h"
// OpenGL compatibility
typedef GLclampf GLclampd;
typedef GLfloat GLdouble;
#else
#include "SDL_opengl.h"
//#include <GL/gl.h>
//#include <GL/glext.h>
#endif
#if !defined(GL_CLAMP_TO_EDGE)
// Originally added by GL_SGIS_texture_edge_clamp; part of OpenGL 1.2 core.
#define GL_CLAMP_TO_EDGE 0x812F
#endif
#if !defined(APIENTRY)
#define APIENTRY
#endif
typedef void (APIENTRY *PFNGLALPHAFUNCPROC)(GLenum, GLclampf);
typedef void (APIENTRY *PFNGLARRAYELEMENTPROC)(GLint);
typedef void (APIENTRY *PFNGLBEGINPROC)(GLenum);
typedef void (APIENTRY *PFNGLBINDTEXTUREPROC)(GLenum, GLuint);
typedef void (APIENTRY *PFNGLBLENDFUNCPROC)(GLenum, GLenum);
typedef void (APIENTRY *PFNGLCLEARPROC)(GLbitfield);
typedef void (APIENTRY *PFNGLCLEARCOLORPROC)(GLclampf, GLclampf, GLclampf, GLclampf);
typedef void (APIENTRY *PFNGLCOLOR3FPROC)(GLfloat, GLfloat, GLfloat);
typedef void (APIENTRY *PFNGLCOLOR3FVPROC)(const GLfloat *);
typedef void (APIENTRY *PFNGLCOLOR3UBPROC)(GLubyte, GLubyte, GLubyte);
typedef void (APIENTRY *PFNGLCOLOR3UBVPROC)(const GLubyte *);
typedef void (APIENTRY *PFNGLCOLOR4FPROC)(GLfloat, GLfloat, GLfloat, GLfloat);
typedef void (APIENTRY *PFNGLCOLOR4FVPROC)(const GLfloat *);
typedef void (APIENTRY *PFNGLCOLOR4UBPROC)(GLubyte, GLubyte, GLubyte, GLubyte);
typedef void (APIENTRY *PFNGLCOLOR4UBVPROC)(const GLubyte *);
typedef void (APIENTRY *PFNGLCOLORPOINTERPROC)(GLint, GLenum, GLsizei, const GLvoid *);
typedef void (APIENTRY *PFNGLCULLFACEPROC)(GLenum);
typedef void (APIENTRY *PFNGLDELETETEXTURESPROC)(GLsizei,const GLuint*);
@ -32,15 +39,10 @@ typedef void (APIENTRY *PFNGLDEPTHMASKPROC)(GLboolean);
typedef void (APIENTRY *PFNGLDEPTHRANGEPROC)(GLclampd, GLclampd);
typedef void (APIENTRY *PFNGLDISABLEPROC)(GLenum);
typedef void (APIENTRY *PFNGLDISABLECLIENTSTATEPROC)(GLenum);
typedef void (APIENTRY *PFNGLDRAWBUFFERPROC)(GLenum);
typedef void (APIENTRY *PFNGLDRAWELEMENTSPROC)(GLenum, GLsizei, GLenum, const GLvoid *);
typedef void (APIENTRY *PFNGLDRAWPIXELSPROC)(GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
typedef void (APIENTRY *PFNGLDRAWRANGEELEMENTSPROC)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *);
typedef void (APIENTRY *PFNGLENABLEPROC)(GLenum);
typedef void (APIENTRY *PFNGLENABLECLIENTSTATEPROC)(GLenum);
typedef void (APIENTRY *PFNGLENDPROC)(GLvoid);
typedef void (APIENTRY *PFNGLFRONTFACEPROC)(GLenum);
typedef void (APIENTRY *PFNGLFRUSTUMPROC)(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble);
typedef void (APIENTRY *PFNGLGENTEXTURESPROC)(GLsizei,GLuint*);
typedef GLenum (APIENTRY *PFNGLGETERRORPROC)(void);
typedef void (APIENTRY *PFNGLGETFLOATVPROC)(GLenum, GLfloat *);
@ -48,34 +50,10 @@ typedef void (APIENTRY *PFNGLGETINTEGERVPROC)(GLenum, GLint *);
typedef const GLubyte* (APIENTRY *PFNGLGETSTRINGPROC)(GLenum);
typedef void (APIENTRY *PFNGLGETTEXPARAMETERFVPROC)(GLenum, GLenum, GLfloat*);
typedef void (APIENTRY *PFNGLHINTPROC)(GLenum, GLenum);
typedef void (APIENTRY *PFNGLLOADIDENTITYPROC)(void);
typedef void (APIENTRY *PFNGLLOADMATRIXFPROC)(const GLfloat *);
typedef void (APIENTRY *PFNGLMATRIXMODEPROC)(GLenum);
typedef void (APIENTRY *PFNGLMULTMATRIXFPROC)(const GLfloat *);
typedef void (APIENTRY *PFNGLNORMALPOINTERPROC)(GLenum, GLsizei, const GLvoid *);
typedef void (APIENTRY *PFNGLORTHOPROC)(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble);
typedef void (APIENTRY *PFNGLPIXELSTOREIPROC)(GLenum, GLint);
typedef void (APIENTRY *PFNGLPIXELZOOMPROC)(GLfloat, GLfloat);
typedef void (APIENTRY *PFNGLPOLYGONMODEPROC)(GLenum, GLenum);
typedef void (APIENTRY *PFNGLPOLYGONOFFSETPROC)(GLfloat, GLfloat);
typedef void (APIENTRY *PFNGLPOPATTRIBPROC)(void);
typedef void (APIENTRY *PFNGLPOPCLIENTATTRIBPROC)(void);
typedef void (APIENTRY *PFNGLPOPMATRIXPROC)(void);
typedef void (APIENTRY *PFNGLPUSHATTRIBPROC)(GLbitfield);
typedef void (APIENTRY *PFNGLPUSHCLIENTATTRIBPROC)(GLbitfield);
typedef void (APIENTRY *PFNGLPUSHMATRIXPROC)(void);
typedef void (APIENTRY *PFNGLRASTERPOS2IPROC)(GLint, GLint);
typedef void (APIENTRY *PFNGLREADBUFFERPROC)(GLenum);
typedef void (APIENTRY *PFNGLREADPIXELSPROC)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid *);
typedef void (APIENTRY *PFNGLROTATEFPROC)(GLfloat, GLfloat, GLfloat, GLfloat);
typedef void (APIENTRY *PFNGLSCALEFPROC)(GLfloat,GLfloat,GLfloat);
typedef void (APIENTRY *PFNGLSHADEMODELPROC)(GLenum);
typedef void (APIENTRY *PFNGLTEXCOORD2FPROC)(GLfloat, GLfloat);
typedef void (APIENTRY *PFNGLTEXCOORD2FVPROC)(const GLfloat *);
typedef void (APIENTRY *PFNGLTEXCOORD3FPROC)(GLfloat, GLfloat, GLfloat);
typedef void (APIENTRY *PFNGLTEXCOORD3FVPROC)(const GLfloat *);
typedef void (APIENTRY *PFNGLTEXCOORD4FPROC)(GLfloat, GLfloat, GLfloat);
typedef void (APIENTRY *PFNGLTEXCOORD4FVPROC)(const GLfloat *);
typedef void (APIENTRY *PFNGLTEXCOORDPOINTERPROC)(GLint, GLenum, GLsizei, const GLvoid *);
typedef void (APIENTRY *PFNGLTEXENVFPROC)(GLenum, GLenum, GLfloat);
typedef void (APIENTRY *PFNGLTEXENVFVPROC)(GLenum, GLenum, const GLfloat *);
@ -84,60 +62,15 @@ typedef void (APIENTRY *PFNGLTEXIMAGE2DPROC)(GLenum,GLint,GLint,GLsizei,GLsizei,
typedef void (APIENTRY *PFNGLTEXPARAMETERFPROC)(GLenum, GLenum, GLfloat);
typedef void (APIENTRY *PFNGLTEXPARAMETERIPROC)(GLenum, GLenum, GLint);
typedef void (APIENTRY *PFNGLTEXSUBIMAGE2DPROC)(GLenum,GLint,GLint,GLint,GLsizei,GLsizei,GLenum,GLenum,const GLvoid*);
typedef void (APIENTRY *PFNGLTRANSLATEFPROC)(GLfloat, GLfloat, GLfloat);
typedef void (APIENTRY *PFNGLVERTEX2FPROC)(GLfloat, GLfloat);
typedef void (APIENTRY *PFNGLVERTEX2FVPROC)(const GLfloat *);
typedef void (APIENTRY *PFNGLVERTEX3FPROC)(GLfloat, GLfloat, GLfloat);
typedef void (APIENTRY *PFNGLVERTEX3FVPROC)(const GLfloat *);
typedef void (APIENTRY *PFNGLVERTEX4FPROC)(GLfloat, GLfloat, GLfloat, GLfloat);
typedef void (APIENTRY *PFNGLVERTEX4FVPROC)(const GLfloat *);
typedef void (APIENTRY *PFNGLVERTEXPOINTERPROC)(GLint, GLenum, GLsizei, const GLvoid *);
typedef void (APIENTRY *PFNGLVIEWPORTPROC)(GLint, GLint, GLsizei, GLsizei);
/*
typedef void (APIENTRY * PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
typedef void (APIENTRY * PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *data);
typedef void (APIENTRY * PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
typedef void (APIENTRY * PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params);
*/
#if defined(_MSC_VER)
typedef void (APIENTRY * PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue);
typedef void (APIENTRY * PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v);
typedef void (APIENTRY * PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue);
typedef void (APIENTRY * PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v);
typedef void (APIENTRY * PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue);
typedef void (APIENTRY * PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v);
typedef void (APIENTRY * PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue);
typedef void (APIENTRY * PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v);
typedef void (APIENTRY * PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue);
typedef void (APIENTRY * PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v);
typedef void (APIENTRY * PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue);
typedef void (APIENTRY * PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v);
typedef void (APIENTRY * PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue);
typedef void (APIENTRY * PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v);
typedef void (APIENTRY * PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue);
typedef void (APIENTRY * PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v);
typedef void (APIENTRY * PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
#endif
typedef void (APIENTRY *PFNGLXSWAPINTERVALSGIPROC)(int interval);
extern PFNGLALPHAFUNCPROC pglAlphaFunc;
extern PFNGLARRAYELEMENTPROC pglArrayElement;
extern PFNGLBEGINPROC pglBegin;
extern PFNGLBINDTEXTUREPROC pglBindTexture;
extern PFNGLBLENDFUNCPROC pglBlendFunc;
extern PFNGLCLEARPROC pglClear;
extern PFNGLCLEARCOLORPROC pglClearColor;
extern PFNGLCOLOR3FPROC pglColor3f;
extern PFNGLCOLOR3FVPROC pglColor3fv;
extern PFNGLCOLOR3UBPROC pglColor3ub;
extern PFNGLCOLOR3UBVPROC pglColor3ubv;
extern PFNGLCOLOR4FPROC pglColor4f;
extern PFNGLCOLOR4FVPROC pglColor4fv;
extern PFNGLCOLOR4UBPROC pglColor4ub;
extern PFNGLCOLOR4UBVPROC pglColor4ubv;
extern PFNGLCOLORPOINTERPROC pglColorPointer;
extern PFNGLCULLFACEPROC pglCullFace;
extern PFNGLDELETETEXTURESPROC pglDeleteTextures;
@ -146,15 +79,10 @@ extern PFNGLDEPTHMASKPROC pglDepthMask;
extern PFNGLDEPTHRANGEPROC pglDepthRange;
extern PFNGLDISABLEPROC pglDisable;
extern PFNGLDISABLECLIENTSTATEPROC pglDisableClientState;
extern PFNGLDRAWBUFFERPROC pglDrawBuffer;
extern PFNGLDRAWELEMENTSPROC pglDrawElements;
extern PFNGLDRAWPIXELSPROC pglDrawPixels;
extern PFNGLDRAWRANGEELEMENTSPROC pglDrawRangeElements;
extern PFNGLENABLEPROC pglEnable;
extern PFNGLENABLECLIENTSTATEPROC pglEnableClientState;
extern PFNGLENDPROC pglEnd;
extern PFNGLFRONTFACEPROC pglFrontFace;
extern PFNGLFRUSTUMPROC pglFrustum;
extern PFNGLGENTEXTURESPROC pglGenTextures;
extern PFNGLGETERRORPROC pglGetError;
extern PFNGLGETFLOATVPROC pglGetFloatv;
@ -162,34 +90,10 @@ extern PFNGLGETINTEGERVPROC pglGetIntegerv;
extern PFNGLGETSTRINGPROC pglGetString;
extern PFNGLGETTEXPARAMETERFVPROC pglGetTexParameterfv;
extern PFNGLHINTPROC pglHint;
extern PFNGLLOADIDENTITYPROC pglLoadIdentity;
extern PFNGLLOADMATRIXFPROC pglLoadMatrixf;
extern PFNGLMATRIXMODEPROC pglMatrixMode;
extern PFNGLMULTMATRIXFPROC pglMultMatrixf;
extern PFNGLNORMALPOINTERPROC pglNormalPointer;
extern PFNGLORTHOPROC pglOrtho;
extern PFNGLPIXELSTOREIPROC pglPixelStorei;
extern PFNGLPIXELZOOMPROC pglPixelZoom;
extern PFNGLPOLYGONMODEPROC pglPolygonMode;
extern PFNGLPOLYGONOFFSETPROC pglPolygonOffset;
extern PFNGLPOPATTRIBPROC pglPopAttrib;
extern PFNGLPOPCLIENTATTRIBPROC pglPopClientAttrib;
extern PFNGLPOPMATRIXPROC pglPopMatrix;
extern PFNGLPUSHATTRIBPROC pglPushAttrib;
extern PFNGLPUSHCLIENTATTRIBPROC pglPushClientAttrib;
extern PFNGLPUSHMATRIXPROC pglPushMatrix;
extern PFNGLRASTERPOS2IPROC pglRasterPos2i;
extern PFNGLREADBUFFERPROC pglReadBuffer;
extern PFNGLREADPIXELSPROC pglReadPixels;
extern PFNGLROTATEFPROC pglRotatef;
extern PFNGLSCALEFPROC pglScalef;
extern PFNGLSHADEMODELPROC pglShadeModel;
extern PFNGLTEXCOORD2FPROC pglTexCoord2f;
extern PFNGLTEXCOORD2FVPROC pglTexCoord2fv;
extern PFNGLTEXCOORD3FPROC pglTexCoord3f;
extern PFNGLTEXCOORD3FVPROC pglTexCoord3fv;
extern PFNGLTEXCOORD4FPROC pglTexCoord4f;
extern PFNGLTEXCOORD4FVPROC pglTexCoord4fv;
extern PFNGLTEXCOORDPOINTERPROC pglTexCoordPointer;
extern PFNGLTEXENVFPROC pglTexEnvf;
extern PFNGLTEXENVFVPROC pglTexEnvfv;
@ -198,38 +102,18 @@ extern PFNGLTEXIMAGE2DPROC pglTexImage2D;
extern PFNGLTEXPARAMETERFPROC pglTexParameterf;
extern PFNGLTEXPARAMETERIPROC pglTexParameteri;
extern PFNGLTEXSUBIMAGE2DPROC pglTexSubImage2D;
extern PFNGLTRANSLATEFPROC pglTranslatef;
extern PFNGLVERTEX2FPROC pglVertex2f;
extern PFNGLVERTEX2FVPROC pglVertex2fv;
extern PFNGLVERTEX3FPROC pglVertex3f;
extern PFNGLVERTEX3FVPROC pglVertex3fv;
extern PFNGLVERTEX4FPROC pglVertex4f;
extern PFNGLVERTEX4FVPROC pglVertex4fv;
extern PFNGLVERTEXPOINTERPROC pglVertexPointer;
extern PFNGLVIEWPORTPROC pglViewport;
// GL_EXT_paletted_texture
extern PFNGLCOLORTABLEEXTPROC pglColorTableEXT;
extern PFNGLGETCOLORTABLEPARAMETERIVEXTPROC pglGetColorTableParameterivEXT;
// GL_EXT_secondary_color
extern PFNGLSECONDARYCOLOR3FEXTPROC pglSecondaryColor3fEXT;
extern PFNGLSECONDARYCOLOR3FVEXTPROC pglSecondaryColor3fvEXT;
extern PFNGLSECONDARYCOLOR3UBEXTPROC pglSecondaryColor3ubEXT;
extern PFNGLSECONDARYCOLOR3UBVEXTPROC pglSecondaryColor3ubvEXT;
extern PFNGLSECONDARYCOLORPOINTEREXTPROC pglSecondaryColorPointerEXT;
extern int ogl_have_multisample_filter_hint;
extern int ogl_have_paletted_texture;
extern int ogl_have_secondary_color;
extern int ogl_have_texture_filter_anisotropic;
extern int ogl_use_multisample_filter_hint;
extern int ogl_use_paletted_texture;
extern int ogl_use_secondary_color;
extern int ogl_use_texture_filter_anisotropic;
extern void load_ogl_functions(int mode);
extern int check_for_errors(const char *file, int line);
extern int check_for_errors_(const char *file, int line);
#define check_for_errors() check_for_errors_(__FILE__, __LINE__)
#endif

File diff suppressed because it is too large Load diff

View file

@ -167,25 +167,6 @@ void UnlockSurface()
fprintf(stderr, "UnlockSurface()\n");
}
void ReleaseDDSurface(void* DDSurface)
{
/*
fprintf(stderr, "ReleaseDDSurface(%p)\n", DDSurface);
*/
D3DTexture *t = (D3DTexture *)DDSurface;
if (t->id > 0) {
fprintf(stderr, "ReleaseDDSurface(%p) - OpenGL Object (tex = %d, %d, %d)\n", DDSurface, t->id, t->w, t->h);
} else {
if (t->buf) {
free(t->buf);
} else {
fprintf(stderr, "ReleaseDDSurface(%p) - What is This? (tex = %d, %d, %d)\n", DDSurface, t->id, t->w, t->h);
}
}
free(t);
}
BOOL ChangeDirectDrawObject()
{

View file

@ -4,31 +4,28 @@
struct AwBackupTexture;
typedef struct AwBackupTexture * AW_BACKUPTEXTUREHANDLE;
// fake type used by opengl.c
typedef struct DIRECTDRAWSURFACE
{
unsigned char *buf;
int id;
int w;
int h;
unsigned int w;
unsigned int h;
unsigned int IsNpot;
unsigned int TexWidth;
unsigned int TexHeight;
float RecipW;
float RecipH;
int filter;
} DIRECTDRAWSURFACE;
typedef DIRECTDRAWSURFACE * LPDIRECTDRAWSURFACE;
typedef DIRECTDRAWSURFACE DDSurface;
typedef struct DIRECT3DTEXTURE
{
unsigned char *buf;
int id;
int w;
int h;
int filter;
} DIRECT3DTEXTURE;
typedef DIRECTDRAWSURFACE DIRECT3DTEXTURE;
typedef DIRECT3DTEXTURE * LPDIRECT3DTEXTURE;
typedef DIRECT3DTEXTURE D3DTexture;

View file

@ -386,7 +386,7 @@ AwTl::SurfUnion AwBackupTexture::Restore(AwTl::CreateTextureParms const & rParam
if (!pixelFormat.validB)
db_log3("AwCreateGraphic(): ERROR: pixel format not valid");
if (!driverDesc.ddP || !driverDesc.validB && rParams.loadTextureB)
if (!driverDesc.ddP || (!driverDesc.validB && rParams.loadTextureB))
db_log3("AwCreateGraphic(): ERROR: driver description not valid");
awTlLastErr = pixelFormat.validB && driverDesc.ddP && (driverDesc.validB || !rParams.loadTextureB) ? AW_TLE_OK : AW_TLE_NOINIT;
@ -426,13 +426,13 @@ void AwBackupTexture::ChoosePixelFormat(AwTl::CreateTextureParms const & _parmsR
unsigned fMyFlags =
_parmsR.flags & AW_TLF_PREVSRCALL ? db_assert1(_parmsR.restoreH), m_fFlags
: _parmsR.flags & AW_TLF_PREVSRC ? db_assert1(_parmsR.restoreH),
_parmsR.flags & ~AW_TLF_TRANSP | m_fFlags & AW_TLF_TRANSP
((_parmsR.flags & ~AW_TLF_TRANSP) | (m_fFlags & AW_TLF_TRANSP))
: _parmsR.flags;
// transparency?
m_bTranspMask = HasTransparentMask(fMyFlags & AW_TLF_TRANSP ? true : false);
if (_parmsR.loadTextureB || fMyFlags & AW_TLF_TEXTURE)
if (_parmsR.loadTextureB || (fMyFlags & AW_TLF_TEXTURE))
{
#if 0
// use a texture format
@ -521,13 +521,26 @@ AwTl::SurfUnion AwBackupTexture::CreateTexture(AwTl::CreateTextureParms const &
{
using namespace AwTl;
// fprintf(stderr, "AwBackupTexture::CreateTexture(...) This is where we could convert the image to RGB/RGBA, and so on\n");
// which flags to use?
unsigned fMyFlags =
(_parmsR.flags & AW_TLF_PREVSRCALL) ? db_assert1(_parmsR.restoreH),
(_parmsR.flags & (AW_TLF_CHECKLOST|AW_TLF_SKIPNOTLOST)) | (m_fFlags & ~(AW_TLF_CHECKLOST|AW_TLF_SKIPNOTLOST))
: (_parmsR.flags & AW_TLF_PREVSRC) ? db_assert1(_parmsR.restoreH),
((_parmsR.flags & ~AW_TLF_TRANSP) | (m_fFlags & AW_TLF_TRANSP))
: _parmsR.flags;
if (_parmsR.originalWidthP) *_parmsR.originalWidthP = m_nWidth;
if (_parmsR.originalHeightP) *_parmsR.originalHeightP = m_nHeight;
D3DTexture *Tex = (D3DTexture *)malloc(sizeof(D3DTexture));
if (_parmsR.rectA != NULL) {
fprintf(stderr, "AwBackupTexture::CreateTexture - rectangle cutouts?\n");
}
if (pixelFormat.texB && (m_bTranspMask && (!pixelFormat.alphaB || fMyFlags & AW_TLF_CHROMAKEY))) {
fprintf(stderr, "AwBackupTexture::CreateTexture - chroma\n");
}
// convert asset to 32-bit rgba
unsigned char *buf = (unsigned char *)malloc(m_nWidth * m_nHeight * 4);
Colour * paletteP = m_nPaletteSize ? GetPalette() : NULL;
@ -573,19 +586,20 @@ AwTl::SurfUnion AwBackupTexture::CreateTexture(AwTl::CreateTextureParms const &
}
/* temp junk */
// convert to texture
D3DTexture *Tex = (D3DTexture *)calloc(1, sizeof(D3DTexture));
Tex->w = m_nWidth;
Tex->h = m_nHeight;
if (pixelFormat.texB) {
Tex->buf = NULL; /* not used */
CreateOGLTexture(Tex, buf); /* this will set the id */
free(buf);
CreateOGLTexture(Tex, buf);
} else {
Tex->buf = buf; /* hey, I need this! */
CreateIMGSurface(Tex, buf);
}
return static_cast<SurfUnion>(Tex);
#if 0
// which flags to use?

View file

@ -130,8 +130,7 @@ namespace AwTl {
DDSurface * surfaceP;
void * voidP;
SurfUnion(){}
SurfUnion(D3DTexture * p) : textureP(p){}
SurfUnion(DDSurface * p) : surfaceP(p){}
SurfUnion(void * p) : voidP(p){}
};
union PtrUnion

View file

@ -581,6 +581,10 @@ a = itmp;}
#else
// parts of mathline.c that have been re-inlined.
// MUL_FIXED, f2i
#include "mathline.h"
/* inline assembly has been moved to mathline.c */
void ADD_LL(LONGLONGCH *a, LONGLONGCH *b, LONGLONGCH *c);
void ADD_LL_PP(LONGLONGCH *c, LONGLONGCH *a);
@ -592,7 +596,6 @@ void EQUALS_LL(LONGLONGCH *a, LONGLONGCH *b);
void NEG_LL(LONGLONGCH *a);
void ASR_LL(LONGLONGCH *a, int shift);
void IntToLL(LONGLONGCH *a, int *b);
int MUL_FIXED(int a, int b);
int DIV_FIXED(int a, int b);
#define DIV_INT(a, b) ((a) / (b))
@ -602,20 +605,7 @@ int WideMulNarrowDiv(int a, int b, int c);
void RotateVector_ASM(VECTORCH *v, MATRIXCH *m);
void RotateAndCopyVector_ASM(VECTORCH *v1, VECTORCH *v2, MATRIXCH *m);
/*
int FloatToInt(float);
#define f2i(a, b) { a = FloatToInt(b); }
*/
int SqRoot32(int A);
void FloatToInt();
extern float fti_fptmp;
extern int fti_itmp;
#define f2i(a, b) { \
fti_fptmp = (b); \
FloatToInt(); \
a = fti_itmp;}
#endif