mirror of
https://github.com/kevinbentley/Descent3.git
synced 2025-01-22 11:28:56 +00:00
commit
0e69bf465f
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@ -66,7 +66,7 @@ jobs:
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install -y --no-install-recommends \
|
||||
ninja-build cmake g++ libgtest-dev libsdl1.2-dev libsdl-image1.2-dev libncurses-dev zlib1g-dev libspdlog-dev
|
||||
ninja-build cmake g++ libgtest-dev libsdl2-dev libncurses-dev zlib1g-dev libspdlog-dev
|
||||
|
||||
- name: Configure CMake
|
||||
env:
|
||||
|
3
Brewfile
3
Brewfile
@ -1,8 +1,7 @@
|
||||
# Homebrew dependencies to build Descent3
|
||||
|
||||
# SDL
|
||||
brew "sdl12-compat"
|
||||
brew "sdl2_image"
|
||||
brew "sdl2"
|
||||
|
||||
brew "cmake"
|
||||
brew "googletest"
|
||||
|
@ -76,27 +76,21 @@ if(UNIX)
|
||||
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:-Wno-multichar;${BITS};${EXTRA_CXX_FLAGS}>")
|
||||
add_compile_options("$<$<COMPILE_LANGUAGE:C>:${BITS}>")
|
||||
|
||||
find_package(SDL REQUIRED)
|
||||
if(APPLE)
|
||||
# Provide FIND_PACKAGE( SDL_image ) below with an include dir and library that work with brew-installed sdl2_image
|
||||
find_path(SDL_IMAGE_INCLUDE_DIR NAMES SDL_image.h PATH_SUFFIXES include/SDL2)
|
||||
find_library(SDL_IMAGE_LIBRARY NAMES SDL2_image)
|
||||
endif()
|
||||
|
||||
find_package(SDL_image REQUIRED)
|
||||
find_package(SDL2 REQUIRED)
|
||||
find_package(Curses REQUIRED)
|
||||
find_package(OpenGL REQUIRED)
|
||||
message("SDL Include Dir is " ${SDL_INCLUDE_DIR})
|
||||
# Some versions of the SDL2 find_package set SDL2_INCLUDE_DIR and some set a plural SDL2_INCLUDE_DIRS. Check both.
|
||||
message("SDL2 Include Dir is ${SDL2_INCLUDE_DIR} ${SDL2_INCLUDE_DIRS}")
|
||||
endif()
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
message("Building for Linux")
|
||||
add_compile_definitions(__LINUX__ LINUX _MAX_PATH=260 _MAX_FNAME=256 _REENRANT __32BIT__ HAVEALLOCA_H _USE_OGL_ACTIVE_TEXTURES)
|
||||
set(PLATFORM_INCLUDES "lib/linux" ${SDL_INCLUDE_DIR})
|
||||
set(PLATFORM_INCLUDES "lib/linux" ${SDL2_INCLUDE_DIR} ${SDL2_INCLUDE_DIRS})
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||
message("Building for MAC OSX")
|
||||
add_compile_definitions(__LINUX__ LINUX _MAX_PATH=260 _MAX_FNAME=256 _REENRANT MACOSX=1 _USE_OGL_ACTIVE_TEXTURES)
|
||||
set(PLATFORM_INCLUDES "lib/linux" ${SDL_INCLUDE_DIR})
|
||||
set(PLATFORM_INCLUDES "lib/linux" ${SDL2_INCLUDE_DIR} ${SDL2_INCLUDE_DIRS})
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
list(APPEND CMAKE_LIBRARY_PATH "lib/win" "lib/win/directx")
|
||||
add_compile_options("$<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:CXX>>:/EHsc;/RTC1;/W3;/nologo;/c;/Zi;/TP;/errorReport:prompt>")
|
||||
|
@ -282,13 +282,13 @@ if(WIN32)
|
||||
endif()
|
||||
|
||||
if(UNIX AND NOT APPLE)
|
||||
set(PLATFORM_LIBS linux dd_lnxsound ddvid_lnx lnxcontroller ddio_lnx SDL::SDL m ${CMAKE_DL_LIBS} ${CURSES_LIBRARIES})
|
||||
set(PLATFORM_LIBS linux dd_lnxsound ddvid_lnx lnxcontroller ddio_lnx SDL2::SDL2 m ${CMAKE_DL_LIBS} ${CURSES_LIBRARIES})
|
||||
set(PLATFORM_CPPS loki_utils.c lnxmain.cpp)
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
set(PLATFORM_LIBS linux dd_lnxsound ddvid_lnx lnxcontroller ddio_lnx SDL::SDL ${CURSES_LIBRARIES})
|
||||
set(PLATFORM_CPPS loki_utils.c lnxmain.cpp SDLMain.m)
|
||||
set(PLATFORM_LIBS linux dd_lnxsound ddvid_lnx lnxcontroller ddio_lnx SDL2::SDL2 ${CURSES_LIBRARIES})
|
||||
set(PLATFORM_CPPS loki_utils.c lnxmain.cpp)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "-framework IOKit -framework Cocoa -framework OpenGL -framework Carbon")
|
||||
endif()
|
||||
|
||||
|
@ -307,9 +307,10 @@ static void register_d3_args(void) {
|
||||
int sdlKeyFilter(const SDL_Event *event);
|
||||
int sdlMouseButtonUpFilter(const SDL_Event *event);
|
||||
int sdlMouseButtonDownFilter(const SDL_Event *event);
|
||||
int sdlMouseWheelFilter(const SDL_Event *event);
|
||||
int sdlMouseMotionFilter(const SDL_Event *event);
|
||||
|
||||
int d3SDLEventFilter(const SDL_Event *event) {
|
||||
int SDLCALL d3SDLEventFilter(void *userdata, SDL_Event *event) {
|
||||
switch (event->type) {
|
||||
case SDL_KEYUP:
|
||||
case SDL_KEYDOWN:
|
||||
@ -322,6 +323,13 @@ int d3SDLEventFilter(const SDL_Event *event) {
|
||||
return (sdlMouseButtonUpFilter(event));
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
return (sdlMouseButtonDownFilter(event));
|
||||
case SDL_MOUSEWHEEL:
|
||||
return (sdlMouseWheelFilter(event));
|
||||
case SDL_QUIT:
|
||||
SDL_Quit();
|
||||
_exit(0);
|
||||
break;
|
||||
default: break;
|
||||
} // switch
|
||||
|
||||
return (1);
|
||||
@ -614,8 +622,11 @@ int main(int argc, char *argv[]) {
|
||||
} // if
|
||||
*/
|
||||
|
||||
SDL_ClearError();
|
||||
int rc = SDL_Init(SDL_INIT_VIDEO | SDL_INIT_CDROM);
|
||||
#ifdef DEDICATED
|
||||
setenv("SDL_VIDEODRIVER", "dummy", 1);
|
||||
#endif
|
||||
|
||||
int rc = SDL_Init(SDL_INIT_VIDEO);
|
||||
if (rc != 0) {
|
||||
fprintf(stderr, "SDL: SDL_Init() failed! rc == (%d).\n", rc);
|
||||
fprintf(stderr, "SDL_GetError() reports \"%s\".\n", SDL_GetError());
|
||||
@ -625,7 +636,7 @@ int main(int argc, char *argv[]) {
|
||||
// atexit(SDL_Quit);
|
||||
|
||||
// !!! FIXME: Don't use an event filter!
|
||||
SDL_SetEventFilter(d3SDLEventFilter);
|
||||
SDL_SetEventFilter(d3SDLEventFilter, NULL);
|
||||
install_signal_handlers();
|
||||
|
||||
// build the command line as one long string, seperated by spaces...
|
||||
|
@ -31,6 +31,8 @@
|
||||
#include <errno.h>
|
||||
#include <sys/mount.h>
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
#include "loki_utils.h"
|
||||
|
||||
#define BAIL_IF_MACRO(x, y, z) \
|
||||
@ -174,236 +176,6 @@ int loki_getmountpoint(const char *device, char *mountpoint, int max_size) {
|
||||
}
|
||||
#endif
|
||||
|
||||
char *__PHYSFS_platformCurrentDir(void) {
|
||||
int allocSize = 0;
|
||||
char *retval = NULL;
|
||||
char *ptr;
|
||||
|
||||
do {
|
||||
allocSize += 100;
|
||||
ptr = (char *)realloc(retval, allocSize);
|
||||
if (ptr == NULL) {
|
||||
if (retval != NULL)
|
||||
free(retval);
|
||||
BAIL_MACRO(ERR_OUT_OF_MEMORY, NULL);
|
||||
} /* if */
|
||||
|
||||
retval = ptr;
|
||||
ptr = getcwd(retval, allocSize);
|
||||
} while (ptr == NULL && errno == ERANGE);
|
||||
|
||||
if (ptr == NULL && errno) {
|
||||
/*
|
||||
* getcwd() failed for some reason, for example current
|
||||
* directory not existing.
|
||||
*/
|
||||
if (retval != NULL)
|
||||
free(retval);
|
||||
BAIL_MACRO(ERR_NO_SUCH_FILE, NULL);
|
||||
} /* if */
|
||||
|
||||
return (retval);
|
||||
} /* __PHYSFS_platformCurrentDir */
|
||||
|
||||
/*
|
||||
* See where program (bin) resides in the $PATH specified by (envr).
|
||||
* returns a copy of the first element in envr that contains it, or NULL
|
||||
* if it doesn't exist or there were other problems. PHYSFS_SetError() is
|
||||
* called if we have a problem.
|
||||
*
|
||||
* (envr) will be scribbled over, and you are expected to free() the
|
||||
* return value when you're done with it.
|
||||
*/
|
||||
static char *findBinaryInPath(const char *bin, char *envr) {
|
||||
size_t alloc_size = 0;
|
||||
char *exe = NULL;
|
||||
char *start = envr;
|
||||
char *ptr;
|
||||
|
||||
BAIL_IF_MACRO(bin == NULL, ERR_INVALID_ARGUMENT, NULL);
|
||||
BAIL_IF_MACRO(envr == NULL, ERR_INVALID_ARGUMENT, NULL);
|
||||
|
||||
do {
|
||||
size_t size;
|
||||
ptr = strchr(start, ':'); /* find next $PATH separator. */
|
||||
if (ptr)
|
||||
*ptr = '\0';
|
||||
|
||||
size = strlen(start) + strlen(bin) + 2;
|
||||
if (size > alloc_size) {
|
||||
char *x = (char *)realloc(exe, size);
|
||||
if (x == NULL) {
|
||||
if (exe != NULL)
|
||||
free(exe);
|
||||
BAIL_MACRO(ERR_OUT_OF_MEMORY, NULL);
|
||||
} /* if */
|
||||
|
||||
alloc_size = size;
|
||||
exe = x;
|
||||
} /* if */
|
||||
|
||||
/* build full binary path... */
|
||||
strcpy(exe, start);
|
||||
if ((exe[0] == '\0') || (exe[strlen(exe) - 1] != '/'))
|
||||
strcat(exe, "/");
|
||||
strcat(exe, bin);
|
||||
|
||||
if (access(exe, X_OK) == 0) /* Exists as executable? We're done. */
|
||||
{
|
||||
strcpy(exe, start); /* i'm lazy. piss off. */
|
||||
return (exe);
|
||||
} /* if */
|
||||
|
||||
start = ptr + 1; /* start points to beginning of next element. */
|
||||
} while (ptr != NULL);
|
||||
|
||||
if (exe != NULL)
|
||||
free(exe);
|
||||
|
||||
return (NULL); /* doesn't exist in path. */
|
||||
} /* findBinaryInPath */
|
||||
|
||||
char *__PHYSFS_platformCopyEnvironmentVariable(const char *varname) {
|
||||
const char *envr = getenv(varname);
|
||||
char *retval = NULL;
|
||||
|
||||
if (envr != NULL) {
|
||||
retval = (char *)malloc(strlen(envr) + 1);
|
||||
if (retval != NULL)
|
||||
strcpy(retval, envr);
|
||||
} /* if */
|
||||
|
||||
return (retval);
|
||||
} /* __PHYSFS_platformCopyEnvironmentVariable */
|
||||
|
||||
static char *getUserNameByUID(void) {
|
||||
uid_t uid = getuid();
|
||||
struct passwd *pw;
|
||||
char *retval = NULL;
|
||||
|
||||
pw = getpwuid(uid);
|
||||
if ((pw != NULL) && (pw->pw_name != NULL)) {
|
||||
retval = (char *)malloc(strlen(pw->pw_name) + 1);
|
||||
if (retval != NULL)
|
||||
strcpy(retval, pw->pw_name);
|
||||
} /* if */
|
||||
|
||||
return (retval);
|
||||
} /* getUserNameByUID */
|
||||
|
||||
static char *getUserDirByUID(void) {
|
||||
uid_t uid = getuid();
|
||||
struct passwd *pw;
|
||||
char *retval = NULL;
|
||||
|
||||
pw = getpwuid(uid);
|
||||
if ((pw != NULL) && (pw->pw_dir != NULL)) {
|
||||
retval = (char *)malloc(strlen(pw->pw_dir) + 1);
|
||||
if (retval != NULL)
|
||||
strcpy(retval, pw->pw_dir);
|
||||
} /* if */
|
||||
|
||||
return (retval);
|
||||
} /* getUserDirByUID */
|
||||
|
||||
char *__PHYSFS_platformGetUserName(void) {
|
||||
char *retval = getUserNameByUID();
|
||||
if (retval == NULL)
|
||||
retval = __PHYSFS_platformCopyEnvironmentVariable("USER");
|
||||
return (retval);
|
||||
} /* __PHYSFS_platformGetUserName */
|
||||
|
||||
char *__PHYSFS_platformGetUserDir(void) {
|
||||
char *retval = __PHYSFS_platformCopyEnvironmentVariable("HOME");
|
||||
if (retval == NULL)
|
||||
retval = getUserDirByUID();
|
||||
return (retval);
|
||||
} /* __PHYSFS_platformGetUserDir */
|
||||
|
||||
static int appendDirSep(char **dir) {
|
||||
const char *dirsep = "/";
|
||||
char *ptr;
|
||||
|
||||
if (strcmp((*dir + strlen(*dir)) - strlen(dirsep), dirsep) == 0)
|
||||
return (1);
|
||||
|
||||
ptr = (char *)realloc(*dir, strlen(*dir) + strlen(dirsep) + 1);
|
||||
if (!ptr) {
|
||||
free(*dir);
|
||||
return (0);
|
||||
} /* if */
|
||||
|
||||
strcat(ptr, dirsep);
|
||||
*dir = ptr;
|
||||
return (1);
|
||||
} /* appendDirSep */
|
||||
|
||||
static char *unixCalcBaseDir(const char *argv0) {
|
||||
/* If there isn't a path on argv0, then look through the $PATH for it. */
|
||||
|
||||
char *retval;
|
||||
char *envr;
|
||||
|
||||
if (strchr(argv0, '/') != NULL) /* default behaviour can handle this. */
|
||||
return (NULL);
|
||||
|
||||
envr = __PHYSFS_platformCopyEnvironmentVariable("PATH");
|
||||
BAIL_IF_MACRO(!envr, NULL, NULL);
|
||||
retval = findBinaryInPath(argv0, envr);
|
||||
free(envr);
|
||||
return (retval);
|
||||
}
|
||||
|
||||
static char *calcBaseDir(const char *argv0) {
|
||||
const char *dirsep = "/";
|
||||
char *retval;
|
||||
char *ptr;
|
||||
|
||||
/*
|
||||
* See if the platform driver wants to handle this for us...
|
||||
*/
|
||||
retval = unixCalcBaseDir(argv0);
|
||||
if (retval != NULL)
|
||||
return (retval);
|
||||
|
||||
/*
|
||||
* Determine if there's a path on argv0. If there is, that's the base dir.
|
||||
*/
|
||||
ptr = strstr(argv0, dirsep);
|
||||
if (ptr != NULL) {
|
||||
char *p = ptr;
|
||||
size_t size;
|
||||
while (p != NULL) {
|
||||
ptr = p;
|
||||
p = strstr(p + 1, dirsep);
|
||||
} /* while */
|
||||
|
||||
size = (size_t)(ptr - argv0);
|
||||
retval = (char *)malloc(size + 1);
|
||||
if (retval == NULL)
|
||||
return NULL;
|
||||
memcpy(retval, argv0, size);
|
||||
retval[size] = '\0';
|
||||
return (retval);
|
||||
} /* if */
|
||||
|
||||
/*
|
||||
* Last ditch effort: it's the current working directory. (*shrug*)
|
||||
*/
|
||||
retval = __PHYSFS_platformCurrentDir();
|
||||
if (retval != NULL) {
|
||||
return (retval);
|
||||
}
|
||||
|
||||
/*
|
||||
* Ok, current directory doesn't exist, use the root directory.
|
||||
* Not a good alternative, but it only happens if the current
|
||||
* directory was deleted from under the program.
|
||||
*/
|
||||
retval = (char *)malloc(strlen(dirsep) + 1);
|
||||
strcpy(retval, dirsep);
|
||||
return (retval);
|
||||
}
|
||||
|
||||
static char *basepath = NULL;
|
||||
static char *prefpath = NULL;
|
||||
@ -413,64 +185,17 @@ const char *loki_getdatapath(void) { return basepath; }
|
||||
const char *loki_getprefpath(void) { return prefpath; }
|
||||
|
||||
void loki_initialize(int argc, char **argv, char *desc) {
|
||||
char resolved_path[MAXPATHLEN];
|
||||
char *ptr = __PHYSFS_platformGetUserDir();
|
||||
if (!ptr) {
|
||||
fprintf(stderr, "ERROR: environment variable HOME not set?!");
|
||||
exit(42);
|
||||
}
|
||||
|
||||
#if MACOSX
|
||||
const char *extra = "Library/Application Support/Descent 3";
|
||||
#else
|
||||
const char *extra = ".loki/descent3";
|
||||
#endif
|
||||
|
||||
prefpath = (char *)malloc(strlen(ptr) + strlen(extra) + 3);
|
||||
strcpy(prefpath, ptr);
|
||||
if (prefpath[strlen(prefpath) - 1] != '/')
|
||||
strcat(prefpath, "/");
|
||||
|
||||
free(ptr);
|
||||
|
||||
strcat(prefpath, extra);
|
||||
ptr = prefpath;
|
||||
while ((ptr = strchr(ptr, '/')) != NULL) {
|
||||
*ptr = '\0';
|
||||
mkdir(prefpath, S_IRWXU);
|
||||
*ptr = '/';
|
||||
ptr++;
|
||||
}
|
||||
mkdir(prefpath, S_IRWXU);
|
||||
|
||||
basepath = calcBaseDir(argv[0]);
|
||||
basepath = SDL_GetBasePath();
|
||||
if (basepath == NULL) {
|
||||
fprintf(stderr, "ERROR: Couldn't find game directory!\n");
|
||||
exit(43);
|
||||
}
|
||||
|
||||
if (realpath(prefpath, resolved_path)) {
|
||||
ptr = (char *)realloc(prefpath, strlen(resolved_path) + 1);
|
||||
if (ptr) {
|
||||
strcpy(ptr, resolved_path);
|
||||
prefpath = ptr;
|
||||
prefpath = SDL_GetPrefPath("Outrage Entertainment", "Descent 3");
|
||||
if (prefpath == NULL) {
|
||||
fprintf(stderr, "ERROR: Couldn't find preference directory!\n");
|
||||
exit(43);
|
||||
}
|
||||
}
|
||||
|
||||
if (realpath(basepath, resolved_path)) {
|
||||
ptr = (char *)realloc(basepath, strlen(resolved_path) + 1);
|
||||
if (ptr) {
|
||||
strcpy(ptr, resolved_path);
|
||||
basepath = ptr;
|
||||
}
|
||||
}
|
||||
|
||||
// Strip out Application Bundle...
|
||||
#if MACOSX
|
||||
{
|
||||
// !!! FIXME
|
||||
}
|
||||
#endif
|
||||
|
||||
// printf("base path: %s\n", basepath);
|
||||
// printf("pref path: %s\n", prefpath);
|
||||
|
@ -51,7 +51,7 @@ cmake --build --preset mac --config [Debug|Release]
|
||||
#### Building - Linux (Ubuntu)
|
||||
```sh
|
||||
sudo apt update
|
||||
sudo apt install -y --no-install-recommends ninja-build cmake g++ libsdl1.2-dev libsdl-image1.2-dev libncurses-dev zlib1g-dev libspdlog-dev
|
||||
sudo apt install -y --no-install-recommends ninja-build cmake g++ libsdl2-dev libncurses-dev zlib1g-dev libspdlog-dev
|
||||
cmake --preset linux -D ENABLE_LOGGER=[ON|OFF]
|
||||
cmake --build --preset linux --config [Debug|Release]
|
||||
```
|
||||
@ -59,7 +59,7 @@ cmake --build --preset linux --config [Debug|Release]
|
||||
#### Building - Linux (Fedora)
|
||||
```sh
|
||||
sudo dnf update --refresh
|
||||
sudo dnf install -y ninja-build cmake gcc-c++ SDL-devel SDL_image-devel ncurses-devel zlib-devel spdlog-devel
|
||||
sudo dnf install -y ninja-build cmake gcc-c++ SDL2-devel ncurses-devel zlib-devel spdlog-devel
|
||||
cmake --preset linux -D ENABLE_LOGGER=[ON|OFF]
|
||||
cmake --build --preset linux --config [Debug|Release]
|
||||
```
|
||||
|
@ -95,7 +95,6 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <SDL.h>
|
||||
#include "mem.h"
|
||||
#include "mono.h"
|
||||
#include "ddio.h"
|
||||
@ -242,8 +241,6 @@ void cdrom_set_system_shutdown(void) {
|
||||
system_cdroms::system_cdroms(void) { reinit(); }
|
||||
|
||||
void system_cdroms::reinit(void) {
|
||||
SDL_QuitSubSystem(SDL_INIT_CDROM);
|
||||
SDL_Init(SDL_INIT_CDROM);
|
||||
m_CreatedMountPoint = false;
|
||||
m_NumCDRoms = 0;
|
||||
m_DeviceToUse = -1;
|
||||
@ -253,10 +250,9 @@ void system_cdroms::reinit(void) {
|
||||
} // reinit
|
||||
|
||||
system_cdroms::~system_cdroms(void) {
|
||||
// SDL_QuitSubSystem(SDL_INIT_CDROM);
|
||||
}
|
||||
|
||||
int system_cdroms::GetNumCDRoms(void) { return (SDL_CDNumDrives()); }
|
||||
int system_cdroms::GetNumCDRoms(void) { return 0; }
|
||||
|
||||
// Returns the device name of the default drive
|
||||
const char *system_cdroms::GetDeviceName(void) { return CDName(m_DeviceToUse); }
|
||||
@ -264,7 +260,7 @@ const char *system_cdroms::GetDeviceName(void) { return CDName(m_DeviceToUse); }
|
||||
// Returns the volume name of the default drive
|
||||
const char *system_cdroms::GetVolumeName(void) { return GetVolume(m_DeviceToUse); }
|
||||
|
||||
const char *system_cdroms::CDName(int drive) { return (SDL_CDName(drive)); }
|
||||
const char *system_cdroms::CDName(int drive) { return NULL; }
|
||||
|
||||
const char *system_cdroms::GetVolume(int drive) {
|
||||
#if 1 // MACOSX
|
||||
@ -342,21 +338,7 @@ const char *system_cdroms::GetVolume(int drive) {
|
||||
bool system_cdroms::IsCdInDrive(void) { return IsCdInDrive(m_DeviceToUse); }
|
||||
|
||||
bool system_cdroms::IsCdInDrive(int drive) {
|
||||
// int cdfd,is_in=0;
|
||||
// struct cdrom_subchnl info;
|
||||
// struct stat stbuf;
|
||||
CDstatus cdStat;
|
||||
SDL_CD cdInfo;
|
||||
bool retVal = true;
|
||||
|
||||
if (drive < 0 || drive >= m_NumCDRoms)
|
||||
retVal = false;
|
||||
else {
|
||||
cdStat = SDL_CDStatus(&cdInfo);
|
||||
if ((cdStat == CD_TRAYEMPTY) || (cdStat == CD_ERROR))
|
||||
retVal = false;
|
||||
} // else
|
||||
return (retVal);
|
||||
return false;
|
||||
}
|
||||
|
||||
static int read_file_string(FILE *fd, char *buffer, int maxsize) {
|
||||
|
@ -199,34 +199,34 @@ inline ubyte sdlkeycode_to_keycode(unsigned int sdlkeycode) {
|
||||
case SDLK_KP_MULTIPLY:
|
||||
rc = KEY_PADMULTIPLY;
|
||||
break;
|
||||
case SDLK_KP0:
|
||||
case SDLK_KP_0:
|
||||
rc = KEY_PAD0;
|
||||
break;
|
||||
case SDLK_KP1:
|
||||
case SDLK_KP_1:
|
||||
rc = KEY_PAD1;
|
||||
break;
|
||||
case SDLK_KP2:
|
||||
case SDLK_KP_2:
|
||||
rc = KEY_PAD2;
|
||||
break;
|
||||
case SDLK_KP3:
|
||||
case SDLK_KP_3:
|
||||
rc = KEY_PAD3;
|
||||
break;
|
||||
case SDLK_KP4:
|
||||
case SDLK_KP_4:
|
||||
rc = KEY_PAD4;
|
||||
break;
|
||||
case SDLK_KP5:
|
||||
case SDLK_KP_5:
|
||||
rc = KEY_PAD5;
|
||||
break;
|
||||
case SDLK_KP6:
|
||||
case SDLK_KP_6:
|
||||
rc = KEY_PAD6;
|
||||
break;
|
||||
case SDLK_KP7:
|
||||
case SDLK_KP_7:
|
||||
rc = KEY_PAD7;
|
||||
break;
|
||||
case SDLK_KP8:
|
||||
case SDLK_KP_8:
|
||||
rc = KEY_PAD8;
|
||||
break;
|
||||
case SDLK_KP9:
|
||||
case SDLK_KP_9:
|
||||
rc = KEY_PAD9;
|
||||
break;
|
||||
case SDLK_SPACE:
|
||||
@ -277,11 +277,11 @@ inline ubyte sdlkeycode_to_keycode(unsigned int sdlkeycode) {
|
||||
rc = KEY_RCTRL;
|
||||
break;
|
||||
case SDLK_LALT:
|
||||
case SDLK_LMETA:
|
||||
case SDLK_LGUI:
|
||||
rc = KEY_LALT;
|
||||
break;
|
||||
case SDLK_RALT:
|
||||
case SDLK_RMETA:
|
||||
case SDLK_RGUI:
|
||||
rc = KEY_RALT;
|
||||
break;
|
||||
|
||||
@ -319,309 +319,19 @@ inline ubyte sdlkeycode_to_keycode(unsigned int sdlkeycode) {
|
||||
case SDLK_COMMA:
|
||||
rc = KEY_COMMA;
|
||||
break;
|
||||
case SDLK_NUMLOCK:
|
||||
case SDLK_NUMLOCKCLEAR:
|
||||
rc = KEY_NUMLOCK;
|
||||
break;
|
||||
case SDLK_PRINT:
|
||||
case SDLK_PRINTSCREEN:
|
||||
rc = KEY_PRINT_SCREEN;
|
||||
break;
|
||||
case SDLK_SCROLLOCK:
|
||||
case SDLK_SCROLLLOCK:
|
||||
rc = KEY_SCROLLOCK;
|
||||
break;
|
||||
case SDLK_CAPSLOCK:
|
||||
rc = KEY_CAPSLOCK;
|
||||
break;
|
||||
|
||||
// world keys. Ugh.
|
||||
case SDLK_WORLD_0:
|
||||
rc = KEY_WORLD0;
|
||||
break;
|
||||
case SDLK_WORLD_1:
|
||||
rc = KEY_WORLD1;
|
||||
break;
|
||||
case SDLK_WORLD_2:
|
||||
rc = KEY_WORLD2;
|
||||
break;
|
||||
case SDLK_WORLD_3:
|
||||
rc = KEY_WORLD3;
|
||||
break;
|
||||
case SDLK_WORLD_4:
|
||||
rc = KEY_WORLD4;
|
||||
break;
|
||||
case SDLK_WORLD_5:
|
||||
rc = KEY_WORLD5;
|
||||
break;
|
||||
case SDLK_WORLD_6:
|
||||
rc = KEY_WORLD6;
|
||||
break;
|
||||
case SDLK_WORLD_7:
|
||||
rc = KEY_WORLD7;
|
||||
break;
|
||||
case SDLK_WORLD_8:
|
||||
rc = KEY_WORLD8;
|
||||
break;
|
||||
case SDLK_WORLD_9:
|
||||
rc = KEY_WORLD9;
|
||||
break;
|
||||
case SDLK_WORLD_10:
|
||||
rc = KEY_WORLD10;
|
||||
break;
|
||||
case SDLK_WORLD_11:
|
||||
rc = KEY_WORLD11;
|
||||
break;
|
||||
case SDLK_WORLD_12:
|
||||
rc = KEY_WORLD12;
|
||||
break;
|
||||
case SDLK_WORLD_13:
|
||||
rc = KEY_WORLD13;
|
||||
break;
|
||||
case SDLK_WORLD_14:
|
||||
rc = KEY_WORLD14;
|
||||
break;
|
||||
case SDLK_WORLD_15:
|
||||
rc = KEY_WORLD15;
|
||||
break;
|
||||
case SDLK_WORLD_16:
|
||||
rc = KEY_WORLD16;
|
||||
break;
|
||||
case SDLK_WORLD_17:
|
||||
rc = KEY_WORLD17;
|
||||
break;
|
||||
case SDLK_WORLD_18:
|
||||
rc = KEY_WORLD18;
|
||||
break;
|
||||
case SDLK_WORLD_19:
|
||||
rc = KEY_WORLD19;
|
||||
break;
|
||||
case SDLK_WORLD_20:
|
||||
rc = KEY_WORLD20;
|
||||
break;
|
||||
case SDLK_WORLD_21:
|
||||
rc = KEY_WORLD21;
|
||||
break;
|
||||
case SDLK_WORLD_22:
|
||||
rc = KEY_WORLD22;
|
||||
break;
|
||||
case SDLK_WORLD_23:
|
||||
rc = KEY_WORLD23;
|
||||
break;
|
||||
case SDLK_WORLD_24:
|
||||
rc = KEY_WORLD24;
|
||||
break;
|
||||
case SDLK_WORLD_25:
|
||||
rc = KEY_WORLD25;
|
||||
break;
|
||||
case SDLK_WORLD_26:
|
||||
rc = KEY_WORLD26;
|
||||
break;
|
||||
case SDLK_WORLD_27:
|
||||
rc = KEY_WORLD27;
|
||||
break;
|
||||
case SDLK_WORLD_28:
|
||||
rc = KEY_WORLD28;
|
||||
break;
|
||||
case SDLK_WORLD_29:
|
||||
rc = KEY_WORLD29;
|
||||
break;
|
||||
case SDLK_WORLD_30:
|
||||
rc = KEY_WORLD30;
|
||||
break;
|
||||
case SDLK_WORLD_31:
|
||||
rc = KEY_WORLD31;
|
||||
break;
|
||||
case SDLK_WORLD_32:
|
||||
rc = KEY_WORLD32;
|
||||
break;
|
||||
case SDLK_WORLD_33:
|
||||
rc = KEY_WORLD33;
|
||||
break;
|
||||
case SDLK_WORLD_34:
|
||||
rc = KEY_WORLD34;
|
||||
break;
|
||||
case SDLK_WORLD_35:
|
||||
rc = KEY_WORLD35;
|
||||
break;
|
||||
case SDLK_WORLD_36:
|
||||
rc = KEY_WORLD36;
|
||||
break;
|
||||
case SDLK_WORLD_37:
|
||||
rc = KEY_WORLD37;
|
||||
break;
|
||||
case SDLK_WORLD_38:
|
||||
rc = KEY_WORLD38;
|
||||
break;
|
||||
case SDLK_WORLD_39:
|
||||
rc = KEY_WORLD39;
|
||||
break;
|
||||
case SDLK_WORLD_40:
|
||||
rc = KEY_WORLD40;
|
||||
break;
|
||||
case SDLK_WORLD_41:
|
||||
rc = KEY_WORLD41;
|
||||
break;
|
||||
case SDLK_WORLD_42:
|
||||
rc = KEY_WORLD42;
|
||||
break;
|
||||
case SDLK_WORLD_43:
|
||||
rc = KEY_WORLD43;
|
||||
break;
|
||||
case SDLK_WORLD_44:
|
||||
rc = KEY_WORLD44;
|
||||
break;
|
||||
case SDLK_WORLD_45:
|
||||
rc = KEY_WORLD45;
|
||||
break;
|
||||
case SDLK_WORLD_46:
|
||||
rc = KEY_WORLD46;
|
||||
break;
|
||||
case SDLK_WORLD_47:
|
||||
rc = KEY_WORLD47;
|
||||
break;
|
||||
case SDLK_WORLD_48:
|
||||
rc = KEY_WORLD48;
|
||||
break;
|
||||
case SDLK_WORLD_49:
|
||||
rc = KEY_WORLD49;
|
||||
break;
|
||||
case SDLK_WORLD_50:
|
||||
rc = KEY_WORLD50;
|
||||
break;
|
||||
case SDLK_WORLD_51:
|
||||
rc = KEY_WORLD51;
|
||||
break;
|
||||
case SDLK_WORLD_52:
|
||||
rc = KEY_WORLD52;
|
||||
break;
|
||||
case SDLK_WORLD_53:
|
||||
rc = KEY_WORLD53;
|
||||
break;
|
||||
case SDLK_WORLD_54:
|
||||
rc = KEY_WORLD54;
|
||||
break;
|
||||
case SDLK_WORLD_55:
|
||||
rc = KEY_WORLD55;
|
||||
break;
|
||||
case SDLK_WORLD_56:
|
||||
rc = KEY_WORLD56;
|
||||
break;
|
||||
case SDLK_WORLD_57:
|
||||
rc = KEY_WORLD57;
|
||||
break;
|
||||
case SDLK_WORLD_58:
|
||||
rc = KEY_WORLD58;
|
||||
break;
|
||||
case SDLK_WORLD_59:
|
||||
rc = KEY_WORLD59;
|
||||
break;
|
||||
case SDLK_WORLD_60:
|
||||
rc = KEY_WORLD60;
|
||||
break;
|
||||
case SDLK_WORLD_61:
|
||||
rc = KEY_WORLD61;
|
||||
break;
|
||||
case SDLK_WORLD_62:
|
||||
rc = KEY_WORLD62;
|
||||
break;
|
||||
case SDLK_WORLD_63:
|
||||
rc = KEY_WORLD63;
|
||||
break;
|
||||
case SDLK_WORLD_64:
|
||||
rc = KEY_WORLD64;
|
||||
break;
|
||||
case SDLK_WORLD_65:
|
||||
rc = KEY_WORLD65;
|
||||
break;
|
||||
case SDLK_WORLD_66:
|
||||
rc = KEY_WORLD66;
|
||||
break;
|
||||
case SDLK_WORLD_67:
|
||||
rc = KEY_WORLD67;
|
||||
break;
|
||||
case SDLK_WORLD_68:
|
||||
rc = KEY_WORLD68;
|
||||
break;
|
||||
case SDLK_WORLD_69:
|
||||
rc = KEY_WORLD69;
|
||||
break;
|
||||
case SDLK_WORLD_70:
|
||||
rc = KEY_WORLD70;
|
||||
break;
|
||||
case SDLK_WORLD_71:
|
||||
rc = KEY_WORLD71;
|
||||
break;
|
||||
case SDLK_WORLD_72:
|
||||
rc = KEY_WORLD72;
|
||||
break;
|
||||
case SDLK_WORLD_73:
|
||||
rc = KEY_WORLD73;
|
||||
break;
|
||||
case SDLK_WORLD_74:
|
||||
rc = KEY_WORLD74;
|
||||
break;
|
||||
case SDLK_WORLD_75:
|
||||
rc = KEY_WORLD75;
|
||||
break;
|
||||
case SDLK_WORLD_76:
|
||||
rc = KEY_WORLD76;
|
||||
break;
|
||||
case SDLK_WORLD_77:
|
||||
rc = KEY_WORLD77;
|
||||
break;
|
||||
case SDLK_WORLD_78:
|
||||
rc = KEY_WORLD78;
|
||||
break;
|
||||
case SDLK_WORLD_79:
|
||||
rc = KEY_WORLD79;
|
||||
break;
|
||||
case SDLK_WORLD_80:
|
||||
rc = KEY_WORLD80;
|
||||
break;
|
||||
case SDLK_WORLD_81:
|
||||
rc = KEY_WORLD81;
|
||||
break;
|
||||
case SDLK_WORLD_82:
|
||||
rc = KEY_WORLD82;
|
||||
break;
|
||||
case SDLK_WORLD_83:
|
||||
rc = KEY_WORLD83;
|
||||
break;
|
||||
case SDLK_WORLD_84:
|
||||
rc = KEY_WORLD84;
|
||||
break;
|
||||
case SDLK_WORLD_85:
|
||||
rc = KEY_WORLD85;
|
||||
break;
|
||||
case SDLK_WORLD_86:
|
||||
rc = KEY_WORLD86;
|
||||
break;
|
||||
case SDLK_WORLD_87:
|
||||
rc = KEY_WORLD87;
|
||||
break;
|
||||
case SDLK_WORLD_88:
|
||||
rc = KEY_WORLD88;
|
||||
break;
|
||||
case SDLK_WORLD_89:
|
||||
rc = KEY_WORLD89;
|
||||
break;
|
||||
case SDLK_WORLD_90:
|
||||
rc = KEY_WORLD90;
|
||||
break;
|
||||
case SDLK_WORLD_91:
|
||||
rc = KEY_WORLD91;
|
||||
break;
|
||||
case SDLK_WORLD_92:
|
||||
rc = KEY_WORLD92;
|
||||
break;
|
||||
case SDLK_WORLD_93:
|
||||
rc = KEY_WORLD93;
|
||||
break;
|
||||
case SDLK_WORLD_94:
|
||||
rc = KEY_WORLD94;
|
||||
break;
|
||||
case SDLK_WORLD_95:
|
||||
rc = KEY_WORLD95;
|
||||
break;
|
||||
|
||||
// convert 'a' - 'z' to 0-27, and then convert to ddio format.
|
||||
default:
|
||||
if (rc >= SDLK_a && rc <= SDLK_z) {
|
||||
@ -645,19 +355,14 @@ int sdlKeyFilter(const SDL_Event *event) {
|
||||
|
||||
switch (event->key.state) {
|
||||
case SDL_PRESSED:
|
||||
if (event->key.repeat) break; // ignore these, we only want to know if it's a first time pressed, not a key-repeat.
|
||||
kc = sdlkeycode_to_keycode(event->key.keysym.sym);
|
||||
if (event->key.keysym.mod & KMOD_CTRL) {
|
||||
switch (kc) {
|
||||
case KEY_G: // toggle grabbed input.
|
||||
if (ddio_mouseGrabbed) {
|
||||
SDL_WM_GrabInput(SDL_GRAB_OFF);
|
||||
ddio_mouseGrabbed = false;
|
||||
} // if
|
||||
else {
|
||||
SDL_WM_GrabInput(SDL_GRAB_ON);
|
||||
ddio_mouseGrabbed = true;
|
||||
} // else
|
||||
return (0);
|
||||
ddio_mouseGrabbed = !ddio_mouseGrabbed;
|
||||
SDL_SetRelativeMouseMode(ddio_mouseGrabbed ? SDL_TRUE : SDL_FALSE);
|
||||
return 0;
|
||||
|
||||
#ifdef __PERMIT_GL_LOGGING
|
||||
case KEY_INSERT:
|
||||
@ -681,8 +386,15 @@ int sdlKeyFilter(const SDL_Event *event) {
|
||||
|
||||
else if (event->key.keysym.mod & KMOD_ALT) {
|
||||
if ((kc == KEY_ENTER) || (kc == KEY_PADENTER)) {
|
||||
SDL_WM_ToggleFullScreen(SDL_GetVideoSurface());
|
||||
return (0);
|
||||
extern SDL_Window *GSDLWindow;
|
||||
Uint32 flags = SDL_GetWindowFlags(GSDLWindow);
|
||||
if (flags & SDL_WINDOW_FULLSCREEN) {
|
||||
flags &= ~SDL_WINDOW_FULLSCREEN_DESKTOP;
|
||||
} else {
|
||||
flags |= SDL_WINDOW_FULLSCREEN; // !!! FIXME: FULLSCREEN_DESKTOP
|
||||
}
|
||||
SDL_SetWindowFullscreen(GSDLWindow, flags);
|
||||
return(0);
|
||||
} // if
|
||||
} // else if
|
||||
|
||||
@ -711,9 +423,6 @@ bool ddio_sdl_InternalKeyInit(ddio_init_info *init_info) {
|
||||
LKeys[i].up_ticks = 0;
|
||||
LKeys[i].status = false;
|
||||
}
|
||||
|
||||
SDL_EventState(SDL_KEYDOWN, SDL_ENABLE);
|
||||
SDL_EventState(SDL_KEYUP, SDL_ENABLE);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -125,10 +125,6 @@ static int Mouse_mode = MOUSE_STANDARD_MODE;
|
||||
|
||||
bool ddio_MouseInit(void) {
|
||||
DDIO_mouse_init = true;
|
||||
|
||||
SDL_EventState(SDL_MOUSEBUTTONDOWN, SDL_ENABLE);
|
||||
SDL_EventState(SDL_MOUSEBUTTONUP, SDL_ENABLE);
|
||||
SDL_EventState(SDL_MOUSEMOTION, SDL_ENABLE);
|
||||
ddio_MouseReset();
|
||||
return true;
|
||||
}
|
||||
@ -211,7 +207,7 @@ int sdlMouseButtonDownFilter(SDL_Event const *event) {
|
||||
const SDL_MouseButtonEvent *ev = &event->button;
|
||||
t_mse_event mevt;
|
||||
|
||||
if (ev->button == 1) { //(evt.xbutton.state & Button1Mask) || (evt.xbutton.button == Button1)) {
|
||||
if (ev->button == 1) {
|
||||
DDIO_mouse_state.btn_mask |= MOUSE_LB;
|
||||
DIM_buttons.down_count[0]++;
|
||||
DIM_buttons.time_down[0] = timer_GetTime();
|
||||
@ -220,7 +216,7 @@ int sdlMouseButtonDownFilter(SDL_Event const *event) {
|
||||
mevt.state = true;
|
||||
MB_queue.send(mevt);
|
||||
// mprintf((0, "MOUSE Button 0: Down\n"));
|
||||
} else if (ev->button == 2) { //((evt.xbutton.state & Button2Mask) || (evt.xbutton.button == Button2)) {
|
||||
} else if (ev->button == 2) {
|
||||
DDIO_mouse_state.btn_mask |= MOUSE_RB;
|
||||
DIM_buttons.down_count[1]++;
|
||||
DIM_buttons.time_down[1] = timer_GetTime();
|
||||
@ -230,7 +226,6 @@ int sdlMouseButtonDownFilter(SDL_Event const *event) {
|
||||
MB_queue.send(mevt);
|
||||
// mprintf((0, "MOUSE Button 1: Down\n"));
|
||||
}
|
||||
// if ((evt.xbutton.state & Button3Mask) || (evt.xbutton.button == Button3)) {
|
||||
else if (ev->button == 3) {
|
||||
DDIO_mouse_state.btn_mask |= MOUSE_CB;
|
||||
DIM_buttons.down_count[2]++;
|
||||
@ -241,19 +236,10 @@ int sdlMouseButtonDownFilter(SDL_Event const *event) {
|
||||
MB_queue.send(mevt);
|
||||
// mprintf((0, "MOUSE Button 2: Down\n"));
|
||||
}
|
||||
// if ((evt.xbutton.state & Button4Mask) || (evt.xbutton.button == Button4)) {
|
||||
else if (ev->button == 4) { /* Mouse scroll up */
|
||||
DDIO_mouse_state.btn_mask |= MOUSE_B5;
|
||||
DIM_buttons.down_count[4]++;
|
||||
DIM_buttons.time_down[4] = timer_GetTime();
|
||||
DIM_buttons.is_down[4] = true;
|
||||
mevt.btn = 4;
|
||||
mevt.state = true;
|
||||
MB_queue.send(mevt);
|
||||
// mprintf((0, "MOUSE Button 4: Down\n"));
|
||||
}
|
||||
// if ((evt.xbutton.state & Button5Mask) || (evt.xbutton.button == Button5)) {
|
||||
else if (ev->button == 5) { /* Mouse scroll down */
|
||||
|
||||
// buttons 4 and 5 are reserved for the mouse wheel...that's how the engine works...adjust in here.
|
||||
|
||||
else if (ev->button == 4) {
|
||||
DDIO_mouse_state.btn_mask |= MOUSE_B6;
|
||||
DIM_buttons.down_count[5]++;
|
||||
DIM_buttons.time_down[5] = timer_GetTime();
|
||||
@ -263,6 +249,27 @@ int sdlMouseButtonDownFilter(SDL_Event const *event) {
|
||||
MB_queue.send(mevt);
|
||||
// mprintf((0, "MOUSE Button 5: Down\n"));
|
||||
}
|
||||
else if (ev->button == 5) {
|
||||
DDIO_mouse_state.btn_mask |= MOUSE_B7;
|
||||
DIM_buttons.down_count[6]++;
|
||||
DIM_buttons.time_down[6] = timer_GetTime();
|
||||
DIM_buttons.is_down[6] = true;
|
||||
mevt.btn = 6;
|
||||
mevt.state = true;
|
||||
MB_queue.send(mevt);
|
||||
// mprintf((0, "MOUSE Button 6: Down\n"));
|
||||
}
|
||||
else if (ev->button == 6) {
|
||||
DDIO_mouse_state.btn_mask |= MOUSE_B8;
|
||||
DIM_buttons.down_count[7]++;
|
||||
DIM_buttons.time_down[7] = timer_GetTime();
|
||||
DIM_buttons.is_down[7] = true;
|
||||
mevt.btn = 7;
|
||||
mevt.state = true;
|
||||
MB_queue.send(mevt);
|
||||
// mprintf((0, "MOUSE Button 7: Down\n"));
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -272,7 +279,6 @@ int sdlMouseButtonUpFilter(SDL_Event const *event) {
|
||||
const SDL_MouseButtonEvent *ev = &event->button;
|
||||
t_mse_event mevt;
|
||||
|
||||
// if ((evt.xbutton.state & Button1Mask) || (evt.xbutton.button == Button1)) {
|
||||
if (ev->button == 1) {
|
||||
DDIO_mouse_state.btn_mask &= (~MOUSE_LB);
|
||||
DIM_buttons.up_count[0]++;
|
||||
@ -283,7 +289,6 @@ int sdlMouseButtonUpFilter(SDL_Event const *event) {
|
||||
MB_queue.send(mevt);
|
||||
// mprintf((0, "MOUSE Button 0: Up\n"));
|
||||
}
|
||||
// if ((evt.xbutton.state & Button2Mask) || (evt.xbutton.button == Button2)) {
|
||||
else if (ev->button == 2) {
|
||||
DDIO_mouse_state.btn_mask &= (~MOUSE_RB);
|
||||
DIM_buttons.up_count[1]++;
|
||||
@ -294,7 +299,6 @@ int sdlMouseButtonUpFilter(SDL_Event const *event) {
|
||||
MB_queue.send(mevt);
|
||||
// mprintf((0, "MOUSE Button 1: Up\n"));
|
||||
}
|
||||
// if ((evt.xbutton.state & Button3Mask) || (evt.xbutton.button == Button3)) {
|
||||
else if (ev->button == 3) {
|
||||
DDIO_mouse_state.btn_mask &= (~MOUSE_CB);
|
||||
DIM_buttons.up_count[2]++;
|
||||
@ -304,20 +308,12 @@ int sdlMouseButtonUpFilter(SDL_Event const *event) {
|
||||
mevt.state = false;
|
||||
MB_queue.send(mevt);
|
||||
// mprintf((0, "MOUSE Button 2: Up\n"));
|
||||
|
||||
}
|
||||
// if ((evt.xbutton.state & Button4Mask) || (evt.xbutton.button == Button4)) {
|
||||
|
||||
// buttons 4 and 5 are reserved for the mouse wheel...that's how the engine works...adjust in here.
|
||||
|
||||
else if (ev->button == 4) {
|
||||
DDIO_mouse_state.btn_mask &= (~MOUSE_B5);
|
||||
DIM_buttons.up_count[4]++;
|
||||
DIM_buttons.is_down[4] = false;
|
||||
DIM_buttons.time_up[4] = timer_GetTime();
|
||||
mevt.btn = 4;
|
||||
mevt.state = false;
|
||||
MB_queue.send(mevt);
|
||||
// mprintf((0, "MOUSE Button 4: Up\n"));
|
||||
}
|
||||
// if ((evt.xbutton.state & Button5Mask) || (evt.xbutton.button == Button5)) {
|
||||
else if (ev->button == 5) {
|
||||
DDIO_mouse_state.btn_mask &= (~MOUSE_B6);
|
||||
DIM_buttons.up_count[5]++;
|
||||
DIM_buttons.is_down[5] = false;
|
||||
@ -327,10 +323,81 @@ int sdlMouseButtonUpFilter(SDL_Event const *event) {
|
||||
MB_queue.send(mevt);
|
||||
// mprintf((0, "MOUSE Button 5: Up\n"));
|
||||
}
|
||||
else if (ev->button == 5) {
|
||||
DDIO_mouse_state.btn_mask &= (~MOUSE_B7);
|
||||
DIM_buttons.up_count[6]++;
|
||||
DIM_buttons.is_down[6] = false;
|
||||
DIM_buttons.time_up[6] = timer_GetTime();
|
||||
mevt.btn = 6;
|
||||
mevt.state = false;
|
||||
MB_queue.send(mevt);
|
||||
// mprintf((0, "MOUSE Button 6: Up\n"));
|
||||
}
|
||||
else if (ev->button == 6) {
|
||||
DDIO_mouse_state.btn_mask &= (~MOUSE_B8);
|
||||
DIM_buttons.up_count[7]++;
|
||||
DIM_buttons.is_down[7] = false;
|
||||
DIM_buttons.time_up[7] = timer_GetTime();
|
||||
mevt.btn = 7;
|
||||
mevt.state = false;
|
||||
MB_queue.send(mevt);
|
||||
// mprintf((0, "MOUSE Button 7: Up\n"));
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
int sdlMouseWheelFilter(SDL_Event const *event) {
|
||||
ASSERT(event->type == SDL_MOUSEWHEEL);
|
||||
|
||||
const SDL_MouseWheelEvent *ev = &event->wheel;
|
||||
t_mse_event mevt;
|
||||
|
||||
// !!! FIXME: this ignores horizontal wheels for now, since Descent3 doesn't currently have a concept of them
|
||||
// !!! FIXME: (vertical mouse wheels are represented as mouse buttons 4 and 5, incorrectly, on all platforms).
|
||||
// !!! FIXME: this will require improvements to the engine before this changes here, though.
|
||||
|
||||
if (ev->y > 0) { /* Mouse scroll up */
|
||||
DDIO_mouse_state.btn_mask |= MOUSE_B5;
|
||||
DIM_buttons.down_count[4]++;
|
||||
DIM_buttons.time_down[4] = timer_GetTime();
|
||||
DIM_buttons.is_down[4] = true;
|
||||
mevt.btn = 4;
|
||||
mevt.state = true;
|
||||
MB_queue.send(mevt);
|
||||
|
||||
// send an immediate release event, as if the "button" was clicked. !!! FIXME: this also needs improvements in the engine.
|
||||
// don't remove from btn_mask
|
||||
DIM_buttons.up_count[4]++;
|
||||
DIM_buttons.is_down[4] = false;
|
||||
DIM_buttons.time_up[4] = timer_GetTime();
|
||||
mevt.btn = 4;
|
||||
mevt.state = false;
|
||||
MB_queue.send(mevt);
|
||||
// mprintf((0, "MOUSE Scrollwheel: Rolled Up\n"));
|
||||
} else if (ev->y < 0) { /* Mouse scroll down */
|
||||
DDIO_mouse_state.btn_mask |= MOUSE_B6;
|
||||
DIM_buttons.down_count[5]++;
|
||||
DIM_buttons.time_down[5] = timer_GetTime();
|
||||
DIM_buttons.is_down[5] = true;
|
||||
mevt.btn = 5;
|
||||
mevt.state = true;
|
||||
MB_queue.send(mevt);
|
||||
|
||||
// send an immediate release event, as if the "button" was clicked. !!! FIXME: this also needs improvements in the engine.
|
||||
// don't remove from btn_mask
|
||||
DIM_buttons.up_count[5]++;
|
||||
DIM_buttons.is_down[5] = false;
|
||||
DIM_buttons.time_up[5] = timer_GetTime();
|
||||
mevt.btn = 5;
|
||||
mevt.state = false;
|
||||
MB_queue.send(mevt);
|
||||
// mprintf((0, "MOUSE Scrollwheel: Rolled Down\n"));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sdlMouseMotionFilter(SDL_Event const *event) {
|
||||
/*
|
||||
int oldmx, oldmy;
|
||||
@ -458,6 +525,10 @@ int ddio_MouseGetState(int *x, int *y, int *dx, int *dy, int *z, int *dz) {
|
||||
|
||||
DDIO_mouse_state.dx = 0;
|
||||
DDIO_mouse_state.dy = 0;
|
||||
|
||||
// unset the mouse wheel "button" once it's been retrieved.
|
||||
DDIO_mouse_state.btn_mask &= ~(MOUSE_B5|MOUSE_B6);
|
||||
|
||||
return btn_mask;
|
||||
}
|
||||
|
||||
|
@ -106,10 +106,6 @@ bool joy_Init(bool remote) {
|
||||
// FIXME: report an error?
|
||||
return false;
|
||||
}
|
||||
SDL_EventState(SDL_JOYAXISMOTION, SDL_IGNORE);
|
||||
SDL_EventState(SDL_JOYHATMOTION, SDL_IGNORE);
|
||||
SDL_EventState(SDL_JOYBUTTONDOWN, SDL_IGNORE);
|
||||
SDL_EventState(SDL_JOYBUTTONUP, SDL_IGNORE);
|
||||
|
||||
// check if this OS supports joysticks
|
||||
if (!joyGetNumDevs() && !remote) {
|
||||
@ -155,7 +151,7 @@ static bool joy_InitStick(tJoystick joy, char *server_adr) {
|
||||
tJoyInfo caps;
|
||||
|
||||
memset(&caps, 0, (sizeof caps));
|
||||
strncpy(caps.name, SDL_JoystickName(joy), sizeof(caps.name) - 1);
|
||||
strncpy(caps.name, SDL_JoystickNameForIndex(joy), sizeof(caps.name) - 1);
|
||||
caps.num_btns = SDL_JoystickNumButtons(stick);
|
||||
int axes = SDL_JoystickNumAxes(stick);
|
||||
switch (axes) {
|
||||
|
@ -237,6 +237,7 @@ inline void SetDebugBreakHandlers(void (*stop)(), void (*resume)()) {
|
||||
Int3(); \
|
||||
} while (0)
|
||||
#elif defined(LINUX)
|
||||
#include "SDL.h"
|
||||
// For some reason Linux doesn't like the \ continuation character, so I have to uglify this
|
||||
#define DEBUG_BREAK() \
|
||||
do { \
|
||||
@ -246,16 +247,7 @@ inline void SetDebugBreakHandlers(void (*stop)(), void (*resume)()) {
|
||||
if (DebugBreak_callback_resume) \
|
||||
(*DebugBreak_callback_resume)(); \
|
||||
} while (0)
|
||||
#define ASSERT(x) \
|
||||
do { \
|
||||
if (!(unsigned long long)(x)) { \
|
||||
mprintf((0, "Assertion failed (%s) in %s line %d.\n", #x, __FILE__, __LINE__)); \
|
||||
if (Debug_break) \
|
||||
DEBUG_BREAK(); \
|
||||
else \
|
||||
AssertionFailed(#x, __FILE__, __LINE__); \
|
||||
} \
|
||||
} while (0)
|
||||
#define ASSERT(x) SDL_assert(x)
|
||||
#define Int3() \
|
||||
do { \
|
||||
mprintf((0, "Int3 at %s line %d.\n", __FILE__, __LINE__)); \
|
||||
|
@ -775,6 +775,8 @@ static void LinuxSoundMixBuffersIntoMain(int len) {
|
||||
}
|
||||
|
||||
static void LinuxSoundThreadHandler(void *unused, Uint8 *stream, int len) {
|
||||
SDL_memset(stream, '\0', len);
|
||||
|
||||
LnxBuffers[0]->buffer = stream;
|
||||
LnxBuffers[0]->buffer_len = len;
|
||||
LnxBuffers[0]->play_cursor = 0;
|
||||
|
@ -80,6 +80,11 @@
|
||||
#include <sys/types.h>
|
||||
#include <term.h>
|
||||
#include <termios.h>
|
||||
|
||||
#ifdef buttons // termios.h defines buttons, but SDL's headers use that symbol.
|
||||
#undef buttons
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
@ -148,8 +153,6 @@ void LnxAppShutdown(void) {
|
||||
if (LinuxAppFlags & OEAPP_CONSOLE) {
|
||||
con_Destroy();
|
||||
tcsetattr(0, TCSANOW, &Linux_initial_terminal_settings);
|
||||
} else {
|
||||
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
|
||||
}
|
||||
}
|
||||
|
||||
@ -163,8 +166,6 @@ oeLnxApplication::oeLnxApplication(unsigned flags) {
|
||||
con_Create(m_Flags);
|
||||
}
|
||||
|
||||
SDL_EnableKeyRepeat(0, 0);
|
||||
|
||||
LinuxAppFlags = m_Flags;
|
||||
|
||||
if (!LinuxAppSetAtExit) {
|
||||
@ -252,7 +253,6 @@ void oeLnxApplication::set_sizepos(int x, int y, int w, int h) {
|
||||
const char *oeLnxApplication::get_window_name(void) { return "Descent 3"; }
|
||||
|
||||
void oeLnxApplication::clear_window(void) {
|
||||
SDL_FillRect(SDL_GetVideoSurface(), NULL, SDL_MapRGB(SDL_GetVideoSurface()->format, 255, 0, 0));
|
||||
}
|
||||
|
||||
// initializes OS components.
|
||||
|
@ -65,7 +65,7 @@ int LnxDraw_InitVideo(LnxVideoDesc *ldesc) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int d3SDLEventFilter(const SDL_Event *event);
|
||||
int SDLCALL d3SDLEventFilter(void *userdata, SDL_Event *event);
|
||||
|
||||
/////////////////////////
|
||||
// LnxDraw_CreateWindow
|
||||
@ -78,8 +78,10 @@ int d3SDLEventFilter(const SDL_Event *event);
|
||||
// -2 : Display not opened
|
||||
// -3 : Out of memory
|
||||
int LnxDraw_CreateWindow(LnxWindowDesc *ldesc, LnxWindow **lphandle) {
|
||||
|
||||
#if 1
|
||||
SDL_Log("!!! FIXME no movie window %s:%d\n", __FILE__, __LINE__);
|
||||
return -1;
|
||||
#else
|
||||
if (!ldesc || !lphandle)
|
||||
return -1;
|
||||
*lphandle = NULL;
|
||||
@ -93,7 +95,7 @@ int LnxDraw_CreateWindow(LnxWindowDesc *ldesc, LnxWindow **lphandle) {
|
||||
fprintf(stderr, "SDL_GetError() reports \"%s\".\n", SDL_GetError());
|
||||
return (-2);
|
||||
} // if
|
||||
SDL_SetEventFilter(d3SDLEventFilter);
|
||||
SDL_SetEventFilter(d3SDLEventFilter, NULL);
|
||||
|
||||
SDL_Rect **modes = LinuxVideoMode.getModes();
|
||||
Uint32 sdlflags = LinuxVideoMode.getSDLFlags();
|
||||
@ -315,6 +317,7 @@ int LnxDraw_CreateWindow(LnxWindowDesc *ldesc, LnxWindow **lphandle) {
|
||||
}
|
||||
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
//////////////////////////
|
||||
@ -326,7 +329,10 @@ int LnxDraw_CreateWindow(LnxWindowDesc *ldesc, LnxWindow **lphandle) {
|
||||
// 0 : no error
|
||||
// -1 : invalid parameter
|
||||
int LnxDraw_DestroyWindow(LnxWindow *handle) {
|
||||
#if 1
|
||||
SDL_Log("!!! FIXME no movie window %s:%d\n", __FILE__, __LINE__);
|
||||
return -1;
|
||||
#else
|
||||
int i;
|
||||
LnxWindow *wnd = NULL;
|
||||
|
||||
@ -373,6 +379,7 @@ int LnxDraw_DestroyWindow(LnxWindow *handle) {
|
||||
free(wnd);
|
||||
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////
|
||||
@ -385,6 +392,10 @@ int LnxDraw_DestroyWindow(LnxWindow *handle) {
|
||||
// false : error
|
||||
bool LnxDraw_LockSurface(LnxWindow *wnd, unsigned x1, unsigned y1, unsigned x2, unsigned y2, unsigned char **ptr,
|
||||
int *pitch) {
|
||||
#if 1
|
||||
SDL_Log("!!! FIXME no movie window %s:%d\n", __FILE__, __LINE__);
|
||||
return false;
|
||||
#else
|
||||
return -1;
|
||||
if (!wnd || !ptr || !pitch)
|
||||
return false;
|
||||
@ -460,6 +471,7 @@ bool LnxDraw_LockSurface(LnxWindow *wnd, unsigned x1, unsigned y1, unsigned x2,
|
||||
|
||||
*ptr = ((unsigned char *)wnd->surface->pixels) + ((wnd->surface->format->BytesPerPixel * wnd->dwWidth) * linesDown);
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
//////////////////////////
|
||||
@ -468,7 +480,9 @@ bool LnxDraw_LockSurface(LnxWindow *wnd, unsigned x1, unsigned y1, unsigned x2,
|
||||
// Unlocks the window surface, blitting the buffer
|
||||
//
|
||||
void LnxDraw_UnlockSurface(LnxWindow *wnd, unsigned char *ptr) {
|
||||
return;
|
||||
#if 1
|
||||
SDL_Log("!!! FIXME no movie window %s:%d\n", __FILE__, __LINE__);
|
||||
#else
|
||||
if (!wnd->bLocked)
|
||||
return;
|
||||
bool still_have_shared = true;
|
||||
@ -514,6 +528,7 @@ void LnxDraw_UnlockSurface(LnxWindow *wnd, unsigned char *ptr) {
|
||||
SDL_SaveBMP(wnd->surface, filename);
|
||||
framenum++;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////
|
||||
|
@ -218,7 +218,7 @@ CFtpGet::CFtpGet(char *URL, char *localfile, char *Username, char *Password) {
|
||||
}
|
||||
|
||||
// if(df_pthread_create(&thread,NULL,FTPObjThread,this)!=0)
|
||||
thread = SDL_CreateThread(FTPObjThread, this);
|
||||
thread = SDL_CreateThread(FTPObjThread, "ftpget", this);
|
||||
if (thread == NULL) {
|
||||
m_State = FTP_STATE_INTERNAL_ERROR;
|
||||
return;
|
||||
|
@ -291,7 +291,7 @@ void ChttpGet::GetFile(char *URL, char *localfile) {
|
||||
}
|
||||
|
||||
// if(df_pthread_create(&thread,NULL,HTTPObjThread,this)!=0)
|
||||
thread = SDL_CreateThread(HTTPObjThread, this);
|
||||
thread = SDL_CreateThread(HTTPObjThread, "httpget", this);
|
||||
if (thread == NULL) {
|
||||
m_State = HTTP_STATE_INTERNAL_ERROR;
|
||||
return;
|
||||
@ -713,7 +713,7 @@ int http_Asyncgethostbyname(unsigned int *ip, int command, char *hostname) {
|
||||
}
|
||||
|
||||
// df_pthread_create(&thread,NULL,http_gethostbynameworker,newaslu);
|
||||
newaslu->threadId = SDL_CreateThread(http_gethostbynameworker, newaslu);
|
||||
newaslu->threadId = SDL_CreateThread(http_gethostbynameworker, "httpdns", newaslu);
|
||||
#endif
|
||||
return 1;
|
||||
} else if (command == NW_AGHBN_CANCEL) {
|
||||
|
@ -2158,7 +2158,7 @@ int nw_Asyncgethostbyname(unsigned int *ip, int command, char *hostname) {
|
||||
// rcg06192000 SDLified.
|
||||
// pthread_t thread;
|
||||
// dpthread_create(&thread, NULL, gethostbynameworker,newaslu);
|
||||
aslu.threadId = SDL_CreateThread(gethostbynameworker, &aslu);
|
||||
aslu.threadId = SDL_CreateThread(gethostbynameworker, "dnsworker", &aslu);
|
||||
}
|
||||
#else
|
||||
HOSTENT *he = gethostbyname(lastaslu->host);
|
||||
|
@ -108,6 +108,8 @@ static HDC hOpenGLDC = NULL;
|
||||
HGLRC ResourceContext;
|
||||
static WORD Saved_gamma_values[256 * 3];
|
||||
#elif defined(__LINUX__)
|
||||
SDL_Window *GSDLWindow = NULL;
|
||||
SDL_GLContext GSDLGLContext = NULL;
|
||||
char loadedLibrary[_MAX_PATH];
|
||||
#else
|
||||
#endif
|
||||
@ -216,7 +218,7 @@ int checkForGLErrors( const char *file, int line )
|
||||
counter++ ;
|
||||
}
|
||||
*/
|
||||
char *sdlp = SDL_GetError();
|
||||
const char *sdlp = SDL_GetError();
|
||||
if(sdlp && *sdlp)
|
||||
mprintf((0,"SDL: %s",sdlp));
|
||||
return 1;
|
||||
@ -566,7 +568,7 @@ void setMinimumAcceptableRenderTime(int ms) {
|
||||
extern bool linux_permit_gamma;
|
||||
extern renderer_preferred_state Render_preferred_state;
|
||||
extern bool ddio_mouseGrabbed;
|
||||
int d3SDLEventFilter(const SDL_Event *event);
|
||||
int SDLCALL d3SDLEventFilter(void *userdata, SDL_Event *event);
|
||||
|
||||
int opengl_Setup(oeApplication *app, int *width, int *height) {
|
||||
// rcg11192000 don't check for FPS.
|
||||
@ -595,15 +597,9 @@ int opengl_Setup(oeApplication *app, int *width, int *height) {
|
||||
rend_SetErrorMessage(buffer);
|
||||
return (0);
|
||||
} // if
|
||||
SDL_SetEventFilter(d3SDLEventFilter);
|
||||
SDL_SetEventFilter(d3SDLEventFilter, NULL);
|
||||
|
||||
bool fullscreen = false;
|
||||
char *env = getenv("MESA_GLX_FX");
|
||||
|
||||
if ((!env) || (*env == 'f')) // Full screen Mesa mode !!! needs more.
|
||||
{
|
||||
fullscreen = true;
|
||||
}
|
||||
bool fullscreen = true;
|
||||
|
||||
if (FindArgChar("-fullscreen", 'f')) {
|
||||
fullscreen = true;
|
||||
@ -611,15 +607,6 @@ int opengl_Setup(oeApplication *app, int *width, int *height) {
|
||||
fullscreen = false;
|
||||
}
|
||||
|
||||
#if 0 // this was for 3DFx Voodoo cards...probably don't need this anymore. --ryan 04/27/2024
|
||||
|
||||
if (env == NULL) {
|
||||
putenv((char *)(fullscreen ? "MESA_GLX_FX=f" : "MESA_GLX_FX=w"));
|
||||
}
|
||||
|
||||
putenv("FX_GLIDE_NO_SPLASH=1");
|
||||
#endif
|
||||
|
||||
if (!Already_loaded) {
|
||||
#define MAX_ARGS 30
|
||||
#define MAX_CHARS_PER_ARG 100
|
||||
@ -631,18 +618,10 @@ int opengl_Setup(oeApplication *app, int *width, int *height) {
|
||||
if (arg != 0) {
|
||||
strcpy(gl_library, GameArgs[arg + 1]);
|
||||
} else {
|
||||
#if defined(MACOSX)
|
||||
strcpy(gl_library, "/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib");
|
||||
#else
|
||||
strcpy(gl_library, "libGL.so");
|
||||
#endif
|
||||
gl_library[0] = 0;
|
||||
}
|
||||
|
||||
mprintf((0, "OpenGL: Attempting to use \"%s\" for OpenGL\n", gl_library));
|
||||
|
||||
#if 0 // this was for 3DFx Voodoo cards...probably don't need this anymore. --ryan 04/27/2024
|
||||
putenv("MESA_FX_NO_SIGNALS=ihatesegfaults");
|
||||
#endif
|
||||
mprintf((0, "OpenGL: Attempting to use \"%s\" for OpenGL\n", gl_library[0] ? gl_library : "[system default library]"));
|
||||
|
||||
// ryan's adds. 04/18/2000...SDL stuff on 04/25/2000
|
||||
bool success = true;
|
||||
@ -690,45 +669,45 @@ int opengl_Setup(oeApplication *app, int *width, int *height) {
|
||||
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
|
||||
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
|
||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||
int flags = SDL_OPENGL;
|
||||
Uint32 flags = SDL_WINDOW_OPENGL;
|
||||
|
||||
if (fullscreen) {
|
||||
flags |= SDL_FULLSCREEN;
|
||||
flags |= SDL_WINDOW_FULLSCREEN;
|
||||
}
|
||||
|
||||
// Should we shoot for 32-bpp if available? !!!
|
||||
SDL_Surface *surface = SDL_SetVideoMode(*width, *height, 32, flags);
|
||||
mprintf((0, "OpenGL: SDL GL surface is %sNULL.", (surface == NULL) ? "" : "NOT "));
|
||||
|
||||
GSDLWindow = SDL_CreateWindow("Descent 3", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, *width, *height, flags);
|
||||
if (!GSDLWindow) {
|
||||
mprintf((0, "OpenGL: SDL window creation failed: %s", SDL_GetError()));
|
||||
return 0;
|
||||
}
|
||||
|
||||
GSDLGLContext = SDL_GL_CreateContext(GSDLWindow);
|
||||
if (!GSDLGLContext) {
|
||||
mprintf((0, "OpenGL: OpenGL context creation failed: %s", SDL_GetError()));
|
||||
SDL_DestroyWindow(GSDLWindow);
|
||||
GSDLWindow = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!FindArg("-nomousecap")) {
|
||||
// ShowCursor(0) and input grabbing need to be done before setting
|
||||
// the video mode, or the Voodoo 3 gets a hardware cursor stuck
|
||||
// on the screen.
|
||||
// On modern systems this is not necessary and must be done after to take effect.
|
||||
SDL_ShowCursor(0);
|
||||
SDL_WM_GrabInput(SDL_GRAB_ON);
|
||||
ddio_mouseGrabbed = true;
|
||||
}
|
||||
|
||||
if (ddio_mouseGrabbed == false) {
|
||||
SDL_WM_GrabInput(SDL_GRAB_OFF);
|
||||
}
|
||||
|
||||
SDL_WM_SetCaption("Descent 3", "Descent3");
|
||||
SDL_SetRelativeMouseMode(ddio_mouseGrabbed ? SDL_TRUE : SDL_FALSE);
|
||||
|
||||
// rcg09182000 gamma fun.
|
||||
// rcg01112000 --nogamma fun.
|
||||
if (FindArgChar("-nogamma", 'M')) {
|
||||
linux_permit_gamma = false;
|
||||
} else {
|
||||
float f = Render_preferred_state.gamma;
|
||||
bool gammarc = SDL_SetGamma(f, f, f);
|
||||
linux_permit_gamma = (gammarc == 0);
|
||||
Uint16 ramp[256];
|
||||
SDL_CalculateGammaRamp(Render_preferred_state.gamma, ramp);
|
||||
linux_permit_gamma = (SDL_SetWindowGammaRamp(GSDLWindow, ramp, ramp, ramp) == 0);
|
||||
} // else
|
||||
|
||||
if (ParentApplication) {
|
||||
reinterpret_cast<oeLnxApplication *>(ParentApplication)->set_sizepos(0, 0, *width, *height);
|
||||
SDL_FillRect(SDL_GetVideoSurface(), NULL, SDL_MapRGB(SDL_GetVideoSurface()->format, 255, 0, 0));
|
||||
}
|
||||
|
||||
Already_loaded = 1;
|
||||
@ -1061,7 +1040,16 @@ void opengl_Close() {
|
||||
#endif
|
||||
}
|
||||
#elif defined(__LINUX__)
|
||||
// SDL_Quit() handles this for us.
|
||||
if (GSDLGLContext) {
|
||||
SDL_GL_MakeCurrent(NULL, NULL);
|
||||
SDL_GL_DeleteContext(GSDLGLContext);
|
||||
GSDLGLContext = NULL;
|
||||
}
|
||||
|
||||
if (GSDLWindow) {
|
||||
SDL_DestroyWindow(GSDLWindow);
|
||||
GSDLWindow = NULL;
|
||||
}
|
||||
#else
|
||||
|
||||
#endif
|
||||
@ -2323,6 +2311,8 @@ void rend_StartFrame(int x1, int y1, int x2, int y2, int clear_flags) {
|
||||
}
|
||||
|
||||
#ifdef __CHECK_FOR_TOO_SLOW_RENDERING__
|
||||
// !!! FIXME: delete this whole section (and definitely the Loki email and phone number!).
|
||||
#error do not compile this in. This was for software mesa problems in 2000.
|
||||
static void slownessAbort(void) {
|
||||
|
||||
#ifdef __LINUX__
|
||||
@ -2376,7 +2366,7 @@ void rend_Flip(void) {
|
||||
#if defined(WIN32)
|
||||
SwapBuffers((HDC)hOpenGLDC);
|
||||
#elif defined(__LINUX__)
|
||||
SDL_GL_SwapBuffers();
|
||||
SDL_GL_SwapWindow(GSDLWindow);
|
||||
#endif
|
||||
|
||||
#ifdef __PERMIT_GL_LOGGING
|
||||
|
@ -228,12 +228,12 @@ module *LoadOpenGLDLL(const char *dllname) {
|
||||
#ifdef __LINUX__
|
||||
char *tmp = getcwd(NULL, 0);
|
||||
chdir(__orig_pwd);
|
||||
int rc = SDL_GL_LoadLibrary(dllname);
|
||||
int rc = SDL_GL_LoadLibrary(dllname[0] ? dllname : NULL);
|
||||
chdir(tmp);
|
||||
free(tmp);
|
||||
if (rc < 0) {
|
||||
const char *sdlErr = SDL_GetError();
|
||||
mprintf((0, "OpenGL: Couldn't open library [%s].\n", dllname));
|
||||
mprintf((0, "OpenGL: Couldn't open library [%s].\n", dllname[0] ? dllname : "system default"));
|
||||
mprintf((0, "OpenGL: SDL error is [%s].", sdlErr));
|
||||
return NULL;
|
||||
}
|
||||
|
@ -115,6 +115,7 @@ CLnxVideoModes::~CLnxVideoModes() {
|
||||
// enumerate all the possible video modes
|
||||
bool CLnxVideoModes::Init(void) // Display *dpy,int screen)
|
||||
{
|
||||
#if 0 // with SDL2, we'll just use FULLSCREEN_DESKTOP and never change the physical vidmode
|
||||
if (m_Inited)
|
||||
return true;
|
||||
|
||||
@ -181,6 +182,7 @@ bool CLnxVideoModes::Init(void) // Display *dpy,int screen)
|
||||
} // for
|
||||
mprintf((0, "-------------------------\n"));
|
||||
} // else
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user