mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-02-16 17:11:03 +00:00
ref_gl.so builds and works (on Linux, with Makefile)
still dirty, seems to use some symbols from client directly, which will not work on Windows.
This commit is contained in:
parent
3a65b41d60
commit
f13e15e561
19 changed files with 1138 additions and 572 deletions
136
Makefile
136
Makefile
|
@ -302,12 +302,12 @@ endif
|
||||||
# ----------
|
# ----------
|
||||||
|
|
||||||
# Phony targets
|
# Phony targets
|
||||||
.PHONY : all client game icon server
|
.PHONY : all client game icon server ref_gl
|
||||||
|
|
||||||
# ----------
|
# ----------
|
||||||
|
|
||||||
# Builds everything
|
# Builds everything
|
||||||
all: config client server game
|
all: config client server game ref_gl
|
||||||
|
|
||||||
# Print config values
|
# Print config values
|
||||||
config:
|
config:
|
||||||
|
@ -344,6 +344,10 @@ endif
|
||||||
|
|
||||||
# Cleanup
|
# Cleanup
|
||||||
clean:
|
clean:
|
||||||
|
@echo "===> CLEAN"
|
||||||
|
${Q}rm -Rf build release/*
|
||||||
|
|
||||||
|
cleanall:
|
||||||
@echo "===> CLEAN"
|
@echo "===> CLEAN"
|
||||||
${Q}rm -Rf build release
|
${Q}rm -Rf build release
|
||||||
|
|
||||||
|
@ -384,7 +388,9 @@ release/quake2.exe : CFLAGS += -DSDL2
|
||||||
endif
|
endif
|
||||||
|
|
||||||
release/quake2.exe : LDFLAGS += -mwindows -lopengl32
|
release/quake2.exe : LDFLAGS += -mwindows -lopengl32
|
||||||
|
|
||||||
else # not Windows
|
else # not Windows
|
||||||
|
|
||||||
client:
|
client:
|
||||||
@echo "===> Building quake2"
|
@echo "===> Building quake2"
|
||||||
${Q}mkdir -p release
|
${Q}mkdir -p release
|
||||||
|
@ -393,7 +399,7 @@ client:
|
||||||
build/client/%.o: %.c
|
build/client/%.o: %.c
|
||||||
@echo "===> CC $<"
|
@echo "===> CC $<"
|
||||||
${Q}mkdir -p $(@D)
|
${Q}mkdir -p $(@D)
|
||||||
${Q}$(CC) -c $(CFLAGS) $(SDLCFLAGS) $(X11CFLAGS) $(INCLUDE) -o $@ $<
|
${Q}$(CC) -c $(CFLAGS) $(SDLCFLAGS) $(INCLUDE) -o $@ $<
|
||||||
|
|
||||||
ifeq ($(OSTYPE), Darwin)
|
ifeq ($(OSTYPE), Darwin)
|
||||||
build/client/%.o : %.m
|
build/client/%.o : %.m
|
||||||
|
@ -439,9 +445,9 @@ endif
|
||||||
ifeq ($(WITH_SDL2),yes)
|
ifeq ($(WITH_SDL2),yes)
|
||||||
release/quake2 : CFLAGS += -DSDL2
|
release/quake2 : CFLAGS += -DSDL2
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq ($(OSTYPE), Darwin)
|
ifneq ($(OSTYPE), Darwin)
|
||||||
release/quake2 : LDFLAGS += -lGL
|
release/ref_gl.so : LDFLAGS += -lGL
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(OSTYPE), FreeBSD)
|
ifeq ($(OSTYPE), FreeBSD)
|
||||||
|
@ -507,6 +513,53 @@ release/q2ded : LDFLAGS += -lz
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# ----------
|
||||||
|
|
||||||
|
# The renderer lib
|
||||||
|
|
||||||
|
ifeq ($(OSTYPE), Windows)
|
||||||
|
|
||||||
|
ref_gl:
|
||||||
|
@echo "===> Building ref_gl.dll"
|
||||||
|
$(MAKE) release/ref_gl.dll
|
||||||
|
|
||||||
|
ifeq ($(WITH_SDL2),yes)
|
||||||
|
release/ref_gl.dll : CFLAGS += -DSDL2
|
||||||
|
endif
|
||||||
|
|
||||||
|
else ifeq ($(OSTYPE), Darwin)
|
||||||
|
|
||||||
|
ref_gl:
|
||||||
|
@echo "===> Building ref_gl.dylib"
|
||||||
|
$(MAKE) release/ref_gl.dylib
|
||||||
|
|
||||||
|
|
||||||
|
ifeq ($(WITH_SDL2),yes)
|
||||||
|
release/ref_gl.dylib : CFLAGS += -DSDL2
|
||||||
|
endif
|
||||||
|
|
||||||
|
else # not Windows or Darwin
|
||||||
|
|
||||||
|
ref_gl:
|
||||||
|
@echo "===> Building ref_gl.so"
|
||||||
|
$(MAKE) release/ref_gl.so
|
||||||
|
|
||||||
|
|
||||||
|
release/ref_gl.so : CFLAGS += -fPIC
|
||||||
|
release/ref_gl.so : LDFLAGS += -shared
|
||||||
|
|
||||||
|
ifeq ($(WITH_SDL2),yes)
|
||||||
|
release/ref_gl.so : CFLAGS += -DSDL2
|
||||||
|
endif
|
||||||
|
|
||||||
|
endif # OS specific ref_gl shit
|
||||||
|
|
||||||
|
build/ref_gl/%.o: %.c
|
||||||
|
@echo "===> CC $<"
|
||||||
|
${Q}mkdir -p $(@D)
|
||||||
|
${Q}$(CC) -c $(CFLAGS) $(SDLCFLAGS) $(X11CFLAGS) $(INCLUDE) -o $@ $<
|
||||||
|
|
||||||
|
|
||||||
# ----------
|
# ----------
|
||||||
|
|
||||||
# The baseq2 game
|
# The baseq2 game
|
||||||
|
@ -610,7 +663,6 @@ CLIENT_OBJS_ := \
|
||||||
src/backends/generic/misc.o \
|
src/backends/generic/misc.o \
|
||||||
src/backends/generic/qal.o \
|
src/backends/generic/qal.o \
|
||||||
src/backends/generic/vid.o \
|
src/backends/generic/vid.o \
|
||||||
src/backends/generic/qgl.o \
|
|
||||||
src/backends/sdl/cd.o \
|
src/backends/sdl/cd.o \
|
||||||
src/backends/sdl/input.o \
|
src/backends/sdl/input.o \
|
||||||
src/backends/sdl/refresh.o \
|
src/backends/sdl/refresh.o \
|
||||||
|
@ -632,22 +684,6 @@ CLIENT_OBJS_ := \
|
||||||
src/client/cl_screen.o \
|
src/client/cl_screen.o \
|
||||||
src/client/cl_tempentities.o \
|
src/client/cl_tempentities.o \
|
||||||
src/client/cl_view.o \
|
src/client/cl_view.o \
|
||||||
src/client/refresh/r_draw.o \
|
|
||||||
src/client/refresh/r_image.o \
|
|
||||||
src/client/refresh/r_light.o \
|
|
||||||
src/client/refresh/r_lightmap.o \
|
|
||||||
src/client/refresh/r_main.o \
|
|
||||||
src/client/refresh/r_mesh.o \
|
|
||||||
src/client/refresh/r_misc.o \
|
|
||||||
src/client/refresh/r_model.o \
|
|
||||||
src/client/refresh/r_scrap.o \
|
|
||||||
src/client/refresh/r_surf.o \
|
|
||||||
src/client/refresh/r_warp.o \
|
|
||||||
src/client/refresh/files/md2.o \
|
|
||||||
src/client/refresh/files/pcx.o \
|
|
||||||
src/client/refresh/files/sp2.o \
|
|
||||||
src/client/refresh/files/stb.o \
|
|
||||||
src/client/refresh/files/wal.o \
|
|
||||||
src/client/menu/menu.o \
|
src/client/menu/menu.o \
|
||||||
src/client/menu/qmenu.o \
|
src/client/menu/qmenu.o \
|
||||||
src/client/menu/videomenu.o \
|
src/client/menu/videomenu.o \
|
||||||
|
@ -684,7 +720,7 @@ CLIENT_OBJS_ := \
|
||||||
src/server/sv_save.o \
|
src/server/sv_save.o \
|
||||||
src/server/sv_send.o \
|
src/server/sv_send.o \
|
||||||
src/server/sv_user.o \
|
src/server/sv_user.o \
|
||||||
src/server/sv_world.o
|
src/server/sv_world.o
|
||||||
|
|
||||||
ifeq ($(OSTYPE), Windows)
|
ifeq ($(OSTYPE), Windows)
|
||||||
CLIENT_OBJS_ += \
|
CLIENT_OBJS_ += \
|
||||||
|
@ -702,6 +738,41 @@ endif
|
||||||
|
|
||||||
# ----------
|
# ----------
|
||||||
|
|
||||||
|
# TODO: move qgl.c to refresh/gl/ (and probably the header as well)
|
||||||
|
|
||||||
|
REFGL_OBJS_ := \
|
||||||
|
src/backends/generic/qgl.o \
|
||||||
|
src/client/refresh/gl/r_draw.o \
|
||||||
|
src/client/refresh/gl/r_image.o \
|
||||||
|
src/client/refresh/gl/r_light.o \
|
||||||
|
src/client/refresh/gl/r_lightmap.o \
|
||||||
|
src/client/refresh/gl/r_main.o \
|
||||||
|
src/client/refresh/gl/r_mesh.o \
|
||||||
|
src/client/refresh/gl/r_misc.o \
|
||||||
|
src/client/refresh/gl/r_model.o \
|
||||||
|
src/client/refresh/gl/r_scrap.o \
|
||||||
|
src/client/refresh/gl/r_surf.o \
|
||||||
|
src/client/refresh/gl/r_warp.o \
|
||||||
|
src/client/refresh/gl/r_sdl.o \
|
||||||
|
src/client/refresh/files/md2.o \
|
||||||
|
src/client/refresh/files/pcx.o \
|
||||||
|
src/client/refresh/files/sp2.o \
|
||||||
|
src/client/refresh/files/stb.o \
|
||||||
|
src/client/refresh/files/wal.o \
|
||||||
|
src/common/shared/flash.o \
|
||||||
|
src/common/shared/rand.o \
|
||||||
|
src/common/shared/shared.o
|
||||||
|
|
||||||
|
ifeq ($(OSTYPE), Windows)
|
||||||
|
REFGL_OBJS_ += \
|
||||||
|
src/backends/windows/shared/mem.o
|
||||||
|
else # not Windows
|
||||||
|
REFGL_OBJS_ += \
|
||||||
|
src/backends/unix/shared/hunk.o
|
||||||
|
endif
|
||||||
|
|
||||||
|
# ----------
|
||||||
|
|
||||||
# Used by the server
|
# Used by the server
|
||||||
SERVER_OBJS_ := \
|
SERVER_OBJS_ := \
|
||||||
src/common/argproc.o \
|
src/common/argproc.o \
|
||||||
|
@ -753,6 +824,7 @@ endif
|
||||||
|
|
||||||
# Rewrite pathes to our object directory
|
# Rewrite pathes to our object directory
|
||||||
CLIENT_OBJS = $(patsubst %,build/client/%,$(CLIENT_OBJS_))
|
CLIENT_OBJS = $(patsubst %,build/client/%,$(CLIENT_OBJS_))
|
||||||
|
REFGL_OBJS = $(patsubst %,build/ref_gl/%,$(REFGL_OBJS_))
|
||||||
SERVER_OBJS = $(patsubst %,build/server/%,$(SERVER_OBJS_))
|
SERVER_OBJS = $(patsubst %,build/server/%,$(SERVER_OBJS_))
|
||||||
GAME_OBJS = $(patsubst %,build/baseq2/%,$(GAME_OBJS_))
|
GAME_OBJS = $(patsubst %,build/baseq2/%,$(GAME_OBJS_))
|
||||||
|
|
||||||
|
@ -760,6 +832,7 @@ GAME_OBJS = $(patsubst %,build/baseq2/%,$(GAME_OBJS_))
|
||||||
|
|
||||||
# Generate header dependencies
|
# Generate header dependencies
|
||||||
CLIENT_DEPS= $(CLIENT_OBJS:.o=.d)
|
CLIENT_DEPS= $(CLIENT_OBJS:.o=.d)
|
||||||
|
REFGL_DEPS= $(REFGL_OBJS:.o=.d)
|
||||||
SERVER_DEPS= $(SERVER_OBJS:.o=.d)
|
SERVER_DEPS= $(SERVER_OBJS:.o=.d)
|
||||||
GAME_DEPS= $(GAME_OBJS:.o=.d)
|
GAME_DEPS= $(GAME_OBJS:.o=.d)
|
||||||
|
|
||||||
|
@ -767,6 +840,7 @@ GAME_DEPS= $(GAME_OBJS:.o=.d)
|
||||||
|
|
||||||
# Suck header dependencies in
|
# Suck header dependencies in
|
||||||
-include $(CLIENT_DEPS)
|
-include $(CLIENT_DEPS)
|
||||||
|
-include $(REFGL_DEPS)
|
||||||
-include $(SERVER_DEPS)
|
-include $(SERVER_DEPS)
|
||||||
-include $(GAME_DEPS)
|
-include $(GAME_DEPS)
|
||||||
|
|
||||||
|
@ -796,6 +870,22 @@ release/q2ded : $(SERVER_OBJS)
|
||||||
${Q}$(CC) $(SERVER_OBJS) $(LDFLAGS) -o $@
|
${Q}$(CC) $(SERVER_OBJS) $(LDFLAGS) -o $@
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# release/ref_gl.so
|
||||||
|
ifeq ($(OSTYPE), Windows)
|
||||||
|
release/ref_gl.dll : $(REFGL_OBJS)
|
||||||
|
@echo "===> LD $@"
|
||||||
|
${Q}$(CC) $(REFGL_OBJS) $(LDFLAGS) $(SDLLDFLAGS) -o $@
|
||||||
|
$(Q)strip $@
|
||||||
|
else ifeq ($(OSTYPE), Darwin)
|
||||||
|
release/ref_gl.dylib : $(REFGL_OBJS)
|
||||||
|
@echo "===> LD $@"
|
||||||
|
${Q}$(CC) $(GAME_OBJS) $(LDFLAGS) $(SDLLDFLAGS) -o $@
|
||||||
|
else
|
||||||
|
release/ref_gl.so : $(REFGL_OBJS)
|
||||||
|
@echo "===> LD $@"
|
||||||
|
${Q}$(CC) $(REFGL_OBJS) $(LDFLAGS) $(SDLLDFLAGS) -o $@
|
||||||
|
endif
|
||||||
|
|
||||||
# release/baseq2/game.so
|
# release/baseq2/game.so
|
||||||
ifeq ($(OSTYPE), Windows)
|
ifeq ($(OSTYPE), Windows)
|
||||||
release/baseq2/game.dll : $(GAME_OBJS)
|
release/baseq2/game.dll : $(GAME_OBJS)
|
||||||
|
|
|
@ -41,6 +41,8 @@
|
||||||
#include "../../client/header/client.h"
|
#include "../../client/header/client.h"
|
||||||
#include "../../client/header/keyboard.h"
|
#include "../../client/header/keyboard.h"
|
||||||
|
|
||||||
|
qboolean VID_LoadRefresh(void);
|
||||||
|
|
||||||
typedef struct vidmode_s
|
typedef struct vidmode_s
|
||||||
{
|
{
|
||||||
const char *description;
|
const char *description;
|
||||||
|
@ -82,7 +84,6 @@ cvar_t *vid_fullscreen;
|
||||||
|
|
||||||
/* Global variables used internally by this module */
|
/* Global variables used internally by this module */
|
||||||
viddef_t viddef; /* global video state; used by other modules */
|
viddef_t viddef; /* global video state; used by other modules */
|
||||||
qboolean ref_active = false; /* Is the refresher being used? */
|
|
||||||
|
|
||||||
#define VID_NUM_MODES (sizeof(vid_modes) / sizeof(vid_modes[0]))
|
#define VID_NUM_MODES (sizeof(vid_modes) / sizeof(vid_modes[0]))
|
||||||
#define MAXPRINTMSG 4096
|
#define MAXPRINTMSG 4096
|
||||||
|
@ -152,33 +153,6 @@ VID_NewWindow(int width, int height)
|
||||||
viddef.height = height;
|
viddef.height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
qboolean
|
|
||||||
VID_LoadRefresh(void)
|
|
||||||
{
|
|
||||||
// If the refresher is already active
|
|
||||||
// we'll shut it down
|
|
||||||
VID_Shutdown();
|
|
||||||
|
|
||||||
// Log it!
|
|
||||||
Com_Printf("----- refresher initialization -----\n");
|
|
||||||
|
|
||||||
// Declare the refresher as active
|
|
||||||
ref_active = true;
|
|
||||||
|
|
||||||
// Initiate the refresher
|
|
||||||
if (R_Init(0, 0) == -1)
|
|
||||||
{
|
|
||||||
VID_Shutdown(); // Isn't that just too bad? :(
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Ensure that all key states are cleared */
|
|
||||||
Key_MarkAllUp();
|
|
||||||
|
|
||||||
Com_Printf("------------------------------------\n\n");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function gets called once just before drawing each frame, and
|
* This function gets called once just before drawing each frame, and
|
||||||
* it's sole purpose in life is to check to see if any of the video mode
|
* it's sole purpose in life is to check to see if any of the video mode
|
||||||
|
@ -217,15 +191,272 @@ VID_Init(void)
|
||||||
VID_CheckChanges();
|
VID_CheckChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Structure containing functions exported from refresh DLL
|
||||||
|
refexport_t re;
|
||||||
|
void *reflib_handle = NULL; // Handle to refresh DLL
|
||||||
|
qboolean ref_active = false; /* Is the refresher being used? */
|
||||||
|
|
||||||
|
void Key_MarkAllUp(void);
|
||||||
|
|
||||||
|
extern qboolean GLimp_InitGraphics(qboolean fullscreen, int *pwidth, int *pheight);
|
||||||
|
extern void VID_ShutdownWindow(void);
|
||||||
|
|
||||||
|
qboolean
|
||||||
|
VID_LoadRefresh(void)
|
||||||
|
{
|
||||||
|
refimport_t ri;
|
||||||
|
GetRefAPI_t GetRefAPI;
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
const char* lib_ext = "dylib";
|
||||||
|
#elif defined(_WIN32)
|
||||||
|
const char* lib_ext = "dll";
|
||||||
|
#else
|
||||||
|
const char* lib_ext = "so";
|
||||||
|
#endif
|
||||||
|
char reflib_path[MAX_OSPATH] = {0};
|
||||||
|
|
||||||
|
// If the refresher is already active
|
||||||
|
// we'll shut it down
|
||||||
|
VID_Shutdown();
|
||||||
|
|
||||||
|
// Log it!
|
||||||
|
Com_Printf("----- refresher initialization -----\n");
|
||||||
|
|
||||||
|
snprintf(reflib_path, sizeof(reflib_path), "./ref_gl.%s", lib_ext); // TODO: name from cvar
|
||||||
|
|
||||||
|
GetRefAPI = Sys_LoadLibrary(reflib_path, "GetRefAPI", &reflib_handle);
|
||||||
|
if(GetRefAPI == NULL)
|
||||||
|
{
|
||||||
|
Com_Error( ERR_FATAL, "Loading %s as renderer lib failed!", reflib_path );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ri.Cmd_AddCommand = Cmd_AddCommand;
|
||||||
|
ri.Cmd_RemoveCommand = Cmd_RemoveCommand;
|
||||||
|
ri.Cmd_Argc = Cmd_Argc;
|
||||||
|
ri.Cmd_Argv = Cmd_Argv;
|
||||||
|
ri.Cmd_ExecuteText = Cbuf_ExecuteText;
|
||||||
|
ri.Con_Printf = VID_Printf;
|
||||||
|
ri.Sys_Error = VID_Error;
|
||||||
|
ri.FS_LoadFile = FS_LoadFile;
|
||||||
|
ri.FS_FreeFile = FS_FreeFile;
|
||||||
|
ri.FS_Gamedir = FS_Gamedir;
|
||||||
|
ri.Cvar_Get = Cvar_Get;
|
||||||
|
ri.Cvar_Set = Cvar_Set;
|
||||||
|
ri.Cvar_SetValue = Cvar_SetValue;
|
||||||
|
ri.Vid_GetModeInfo = VID_GetModeInfo;
|
||||||
|
ri.Vid_MenuInit = VID_MenuInit;
|
||||||
|
ri.Vid_NewWindow = VID_NewWindow;
|
||||||
|
|
||||||
|
ri.Vid_ShutdownWindow = VID_ShutdownWindow;
|
||||||
|
ri.GLimp_InitGraphics = GLimp_InitGraphics;
|
||||||
|
|
||||||
|
re = GetRefAPI( ri );
|
||||||
|
|
||||||
|
// Declare the refresher as active
|
||||||
|
ref_active = true;
|
||||||
|
|
||||||
|
if (re.api_version != API_VERSION)
|
||||||
|
{
|
||||||
|
VID_Shutdown();
|
||||||
|
Com_Error (ERR_FATAL, "%s has incompatible api_version %d", reflib_path, re.api_version);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initiate the refresher
|
||||||
|
if (re.Init(0, 0) == -1)
|
||||||
|
{
|
||||||
|
VID_Shutdown(); // Isn't that just too bad? :(
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ensure that all key states are cleared */
|
||||||
|
Key_MarkAllUp();
|
||||||
|
|
||||||
|
Com_Printf("------------------------------------\n\n");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
VID_Shutdown(void)
|
VID_Shutdown(void)
|
||||||
{
|
{
|
||||||
if (ref_active)
|
if (ref_active)
|
||||||
{
|
{
|
||||||
/* Shut down the renderer */
|
/* Shut down the renderer */
|
||||||
R_Shutdown();
|
re.Shutdown();
|
||||||
|
Sys_FreeLibrary(reflib_handle);
|
||||||
|
reflib_handle = NULL;
|
||||||
|
memset(&re, 0, sizeof(re));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Declare the refresher as inactive
|
// Declare the refresher as inactive
|
||||||
ref_active = false;
|
ref_active = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ======== wrappers for functions from refresh lib ========
|
||||||
|
|
||||||
|
void
|
||||||
|
R_BeginRegistration(char *map)
|
||||||
|
{
|
||||||
|
if(ref_active)
|
||||||
|
{
|
||||||
|
re.BeginRegistration(map);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct model_s*
|
||||||
|
R_RegisterModel(char *name)
|
||||||
|
{
|
||||||
|
if(ref_active)
|
||||||
|
{
|
||||||
|
return re.RegisterModel(name);
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct image_s*
|
||||||
|
R_RegisterSkin(char *name)
|
||||||
|
{
|
||||||
|
if(ref_active)
|
||||||
|
{
|
||||||
|
return re.RegisterSkin(name);
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
R_SetSky(char *name, float rotate, vec3_t axis)
|
||||||
|
{
|
||||||
|
if(ref_active)
|
||||||
|
{
|
||||||
|
re.SetSky(name, rotate, axis);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
R_EndRegistration(void)
|
||||||
|
{
|
||||||
|
if(ref_active)
|
||||||
|
{
|
||||||
|
re.EndRegistration();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
R_RenderFrame(refdef_t *fd)
|
||||||
|
{
|
||||||
|
if(ref_active)
|
||||||
|
{
|
||||||
|
re.RenderFrame(fd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct image_s*
|
||||||
|
Draw_FindPic(char *name)
|
||||||
|
{
|
||||||
|
if(ref_active)
|
||||||
|
{
|
||||||
|
return re.DrawFindPic(name);
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Draw_GetPicSize(int *w, int *h, char *name)
|
||||||
|
{
|
||||||
|
if(ref_active)
|
||||||
|
{
|
||||||
|
re.DrawGetPicSize(w, h, name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Draw_StretchPic(int x, int y, int w, int h, char *name)
|
||||||
|
{
|
||||||
|
if(ref_active)
|
||||||
|
{
|
||||||
|
re.DrawStretchPic(x, y, w, h, name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Draw_PicScaled(int x, int y, char *pic, float factor)
|
||||||
|
{
|
||||||
|
if(ref_active)
|
||||||
|
{
|
||||||
|
re.DrawPicScaled(x, y, pic, factor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Draw_CharScaled(int x, int y, int num, float scale)
|
||||||
|
{
|
||||||
|
if(ref_active)
|
||||||
|
{
|
||||||
|
re.DrawCharScaled(x, y, num, scale);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Draw_TileClear(int x, int y, int w, int h, char *name)
|
||||||
|
{
|
||||||
|
if(ref_active)
|
||||||
|
{
|
||||||
|
re.DrawTileClear(x, y, w, h, name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Draw_Fill(int x, int y, int w, int h, int c)
|
||||||
|
{
|
||||||
|
if(ref_active)
|
||||||
|
{
|
||||||
|
re.DrawFill(x, y, w, h, c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Draw_FadeScreen(void)
|
||||||
|
{
|
||||||
|
if(ref_active)
|
||||||
|
{
|
||||||
|
re.DrawFadeScreen();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Draw_StretchRaw(int x, int y, int w, int h, int cols, int rows, byte *data)
|
||||||
|
{
|
||||||
|
if(ref_active)
|
||||||
|
{
|
||||||
|
re.DrawStretchRaw(x, y, w, h, cols, rows, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
R_SetPalette(const unsigned char *palette)
|
||||||
|
{
|
||||||
|
if(ref_active)
|
||||||
|
{
|
||||||
|
re.SetPalette(palette);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
R_BeginFrame(float camera_separation)
|
||||||
|
{
|
||||||
|
if(ref_active)
|
||||||
|
{
|
||||||
|
re.BeginFrame(camera_separation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
R_EndFrame(void)
|
||||||
|
{
|
||||||
|
if(ref_active)
|
||||||
|
{
|
||||||
|
re.EndFrame();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -35,11 +35,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../../client/refresh/header/local.h"
|
#include "../../client/refresh/header/local.h"
|
||||||
#if defined(__APPLE__)
|
|
||||||
#include <OpenGL/gl.h>
|
|
||||||
#else
|
|
||||||
#include <GL/gl.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef SDL2
|
#ifdef SDL2
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
|
@ -49,42 +45,24 @@
|
||||||
#include <SDL/SDL.h>
|
#include <SDL/SDL.h>
|
||||||
#endif //SDL2
|
#endif //SDL2
|
||||||
|
|
||||||
/* X.org stuff */
|
|
||||||
#ifdef X11GAMMA
|
|
||||||
#include <X11/Xos.h>
|
|
||||||
#include <X11/Xlib.h>
|
|
||||||
#include <X11/Xutil.h>
|
|
||||||
#include <X11/extensions/xf86vmode.h>
|
|
||||||
#include <X11/extensions/Xrandr.h>
|
|
||||||
|
|
||||||
#include <SDL_syswm.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||||
SDL_Window* window = NULL;
|
static SDL_Window* window = NULL;
|
||||||
SDL_GLContext context = NULL;
|
|
||||||
#else
|
#else
|
||||||
SDL_Surface* window = NULL;
|
static SDL_Surface* window = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
qboolean have_stencil = false;
|
|
||||||
qboolean vsync_active;
|
qboolean vsync_active;
|
||||||
|
|
||||||
#ifdef X11GAMMA
|
|
||||||
XRRCrtcGamma** gammaRamps = NULL;
|
|
||||||
int noGammaRamps = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||||
// some compatibility defines
|
// some compatibility defines
|
||||||
#define SDL_SRCCOLORKEY SDL_TRUE
|
#define SDL_SRCCOLORKEY SDL_TRUE
|
||||||
#define SDL_FULLSCREEN SDL_WINDOW_FULLSCREEN
|
#define SDL_FULLSCREEN SDL_WINDOW_FULLSCREEN
|
||||||
#define SDL_OPENGL SDL_WINDOW_OPENGL
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialzes the SDL OpenGL context
|
* Initializes the SDL video subsystem
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
GLimp_Init(void)
|
GLimp_Init(void)
|
||||||
|
@ -110,15 +88,6 @@ GLimp_Init(void)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Returns the adress of a GL function
|
|
||||||
*/
|
|
||||||
void *
|
|
||||||
GLimp_GetProcAddress (const char* proc)
|
|
||||||
{
|
|
||||||
return SDL_GL_GetProcAddress ( proc );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sets the window icon
|
* Sets the window icon
|
||||||
*/
|
*/
|
||||||
|
@ -208,127 +177,6 @@ SetSDLIcon()
|
||||||
}
|
}
|
||||||
#endif /* SDL 1.2 */
|
#endif /* SDL 1.2 */
|
||||||
|
|
||||||
/*
|
|
||||||
* from SDL2 SDL_CalculateGammaRamp, adjusted for arbitrary ramp sizes
|
|
||||||
* because xrandr seems to support ramp sizes != 256 (in theory at least)
|
|
||||||
*/
|
|
||||||
void CalculateGammaRamp(float gamma, Uint16* ramp, int len)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
/* Input validation */
|
|
||||||
if (gamma < 0.0f ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (ramp == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 0.0 gamma is all black */
|
|
||||||
if (gamma == 0.0f) {
|
|
||||||
for (i = 0; i < len; ++i) {
|
|
||||||
ramp[i] = 0;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
} else if (gamma == 1.0f) {
|
|
||||||
/* 1.0 gamma is identity */
|
|
||||||
for (i = 0; i < len; ++i) {
|
|
||||||
ramp[i] = (i << 8) | i;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
/* Calculate a real gamma ramp */
|
|
||||||
int value;
|
|
||||||
gamma = 1.0f / gamma;
|
|
||||||
for (i = 0; i < len; ++i) {
|
|
||||||
value = (int) (pow((double) i / (double) len, gamma) * 65535.0 + 0.5);
|
|
||||||
if (value > 65535) {
|
|
||||||
value = 65535;
|
|
||||||
}
|
|
||||||
ramp[i] = (Uint16) value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Sets the hardware gamma
|
|
||||||
*/
|
|
||||||
#ifdef X11GAMMA
|
|
||||||
void
|
|
||||||
UpdateHardwareGamma(void)
|
|
||||||
{
|
|
||||||
float gamma = (vid_gamma->value);
|
|
||||||
int i;
|
|
||||||
|
|
||||||
Display* dpy = NULL;
|
|
||||||
SDL_SysWMinfo info;
|
|
||||||
|
|
||||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
|
||||||
SDL_VERSION(&info.version);
|
|
||||||
if(!SDL_GetWindowWMInfo(window, &info))
|
|
||||||
#else
|
|
||||||
if(SDL_GetWMInfo(&info) != 1)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
VID_Printf(PRINT_ALL, "Couldn't get Window info from SDL\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
dpy = info.info.x11.display;
|
|
||||||
|
|
||||||
XRRScreenResources* res = XRRGetScreenResources(dpy, info.info.x11.window);
|
|
||||||
if(res == NULL)
|
|
||||||
{
|
|
||||||
VID_Printf(PRINT_ALL, "Unable to get xrandr screen resources.\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(i=0; i < res->ncrtc; ++i)
|
|
||||||
{
|
|
||||||
int len = XRRGetCrtcGammaSize(dpy, res->crtcs[i]);
|
|
||||||
size_t rampSize = len*sizeof(Uint16);
|
|
||||||
Uint16* ramp = malloc(rampSize); // TODO: check for NULL
|
|
||||||
if(ramp == NULL)
|
|
||||||
{
|
|
||||||
VID_Printf(PRINT_ALL, "Couldn't allocate &zd byte of memory for gamma ramp - OOM?!\n", rampSize);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
CalculateGammaRamp(gamma, ramp, len);
|
|
||||||
|
|
||||||
XRRCrtcGamma* gamma = XRRAllocGamma(len);
|
|
||||||
|
|
||||||
memcpy(gamma->red, ramp, rampSize);
|
|
||||||
memcpy(gamma->green, ramp, rampSize);
|
|
||||||
memcpy(gamma->blue, ramp, rampSize);
|
|
||||||
|
|
||||||
free(ramp);
|
|
||||||
|
|
||||||
XRRSetCrtcGamma(dpy, res->crtcs[i], gamma);
|
|
||||||
|
|
||||||
XRRFreeGamma(gamma);
|
|
||||||
}
|
|
||||||
|
|
||||||
XRRFreeScreenResources(res);
|
|
||||||
}
|
|
||||||
#else // no X11GAMMA
|
|
||||||
void
|
|
||||||
UpdateHardwareGamma(void)
|
|
||||||
{
|
|
||||||
float gamma = (vid_gamma->value);
|
|
||||||
|
|
||||||
Uint16 ramp[256];
|
|
||||||
CalculateGammaRamp(gamma, ramp, 256);
|
|
||||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
|
||||||
if(SDL_SetWindowGammaRamp(window, ramp, ramp, ramp) != 0) {
|
|
||||||
#else
|
|
||||||
if(SDL_SetGammaRamp(ramp, ramp, ramp) < 0) {
|
|
||||||
#endif
|
|
||||||
VID_Printf(PRINT_ALL, "Setting gamma failed: %s\n", SDL_GetError());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif // X11GAMMA
|
|
||||||
|
|
||||||
static qboolean IsFullscreen()
|
static qboolean IsFullscreen()
|
||||||
{
|
{
|
||||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||||
|
@ -338,30 +186,16 @@ static qboolean IsFullscreen()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static qboolean CreateSDLWindow(int flags)
|
static qboolean CreateSDLWindow(int flags, int w, int h)
|
||||||
{
|
{
|
||||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||||
int windowPos = SDL_WINDOWPOS_UNDEFINED;
|
int windowPos = SDL_WINDOWPOS_UNDEFINED;
|
||||||
// TODO: support fullscreen on different displays with SDL_WINDOWPOS_UNDEFINED_DISPLAY(displaynum)
|
// TODO: support fullscreen on different displays with SDL_WINDOWPOS_UNDEFINED_DISPLAY(displaynum)
|
||||||
window = SDL_CreateWindow("Yamagi Quake II", windowPos, windowPos,
|
window = SDL_CreateWindow("Yamagi Quake II", windowPos, windowPos, w, h, flags);
|
||||||
vid.width, vid.height, flags);
|
|
||||||
|
|
||||||
if(window == NULL)
|
return window != NULL;
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
context = SDL_GL_CreateContext(window);
|
|
||||||
if(context == NULL)
|
|
||||||
{
|
|
||||||
SDL_DestroyWindow(window);
|
|
||||||
window = NULL;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
#else
|
#else
|
||||||
window = SDL_SetVideoMode(vid.width, vid.height, 0, flags);
|
window = SDL_SetVideoMode(w, h, 0, flags);
|
||||||
SDL_EnableUNICODE(SDL_TRUE);
|
SDL_EnableUNICODE(SDL_TRUE);
|
||||||
return window != NULL;
|
return window != NULL;
|
||||||
#endif
|
#endif
|
||||||
|
@ -389,145 +223,20 @@ static qboolean GetWindowSize(int* w, int* h)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void InitGamma()
|
|
||||||
{
|
|
||||||
#ifdef X11GAMMA
|
|
||||||
int i=0;
|
|
||||||
SDL_SysWMinfo info;
|
|
||||||
Display* dpy = NULL;
|
|
||||||
|
|
||||||
if(gammaRamps != NULL) // already saved gamma
|
|
||||||
return;
|
|
||||||
|
|
||||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
|
||||||
SDL_VERSION(&info.version);
|
|
||||||
if(!SDL_GetWindowWMInfo(window, &info))
|
|
||||||
#else
|
|
||||||
if(SDL_GetWMInfo(&info) != 1)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
VID_Printf(PRINT_ALL, "Couldn't get Window info from SDL\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
dpy = info.info.x11.display;
|
|
||||||
|
|
||||||
XRRScreenResources* res = XRRGetScreenResources(dpy, info.info.x11.window);
|
|
||||||
if(res == NULL)
|
|
||||||
{
|
|
||||||
VID_Printf(PRINT_ALL, "Unable to get xrandr screen resources.\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
noGammaRamps = res->ncrtc;
|
|
||||||
gammaRamps = calloc(noGammaRamps, sizeof(XRRCrtcGamma*));
|
|
||||||
if(gammaRamps == NULL) {
|
|
||||||
VID_Printf(PRINT_ALL, "Couldn't allocate memory for %d gamma ramps - OOM?!\n", noGammaRamps);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(i=0; i < noGammaRamps; ++i)
|
|
||||||
{
|
|
||||||
int len = XRRGetCrtcGammaSize(dpy, res->crtcs[i]);
|
|
||||||
size_t rampSize = len*sizeof(Uint16);
|
|
||||||
|
|
||||||
XRRCrtcGamma* origGamma = XRRGetCrtcGamma(dpy, res->crtcs[i]);
|
|
||||||
|
|
||||||
XRRCrtcGamma* gammaCopy = XRRAllocGamma(len);
|
|
||||||
|
|
||||||
memcpy(gammaCopy->red, origGamma->red, rampSize);
|
|
||||||
memcpy(gammaCopy->green, origGamma->green, rampSize);
|
|
||||||
memcpy(gammaCopy->blue, origGamma->blue, rampSize);
|
|
||||||
|
|
||||||
gammaRamps[i] = gammaCopy;
|
|
||||||
}
|
|
||||||
|
|
||||||
XRRFreeScreenResources(res);
|
|
||||||
|
|
||||||
VID_Printf(PRINT_ALL, "Using hardware gamma via X11/xRandR.\n");
|
|
||||||
#elif __APPLE__
|
|
||||||
gl_state.hwgamma = false;
|
|
||||||
VID_Printf(PRINT_ALL, "Using software gamma (needs vid_restart after changes)\n");
|
|
||||||
return;
|
|
||||||
#else
|
|
||||||
VID_Printf(PRINT_ALL, "Using hardware gamma via SDL.\n");
|
|
||||||
#endif
|
|
||||||
gl_state.hwgamma = true;
|
|
||||||
vid_gamma->modified = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef X11GAMMA
|
|
||||||
static void RestoreGamma()
|
|
||||||
{
|
|
||||||
int i=0;
|
|
||||||
SDL_SysWMinfo info;
|
|
||||||
Display* dpy = NULL;
|
|
||||||
|
|
||||||
if(gammaRamps == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
|
||||||
SDL_VERSION(&info.version);
|
|
||||||
if(!SDL_GetWindowWMInfo(window, &info))
|
|
||||||
#else
|
|
||||||
if(SDL_GetWMInfo(&info) != 1)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
VID_Printf(PRINT_ALL, "Couldn't get Window info from SDL\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
dpy = info.info.x11.display;
|
|
||||||
|
|
||||||
XRRScreenResources* res = XRRGetScreenResources(dpy, info.info.x11.window);
|
|
||||||
if(res == NULL)
|
|
||||||
{
|
|
||||||
VID_Printf(PRINT_ALL, "Unable to get xrandr screen resources.\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(i=0; i < noGammaRamps; ++i)
|
|
||||||
{
|
|
||||||
// in case a display was unplugged or something, noGammaRamps may be > res->ncrtc
|
|
||||||
if(i < res->ncrtc)
|
|
||||||
{
|
|
||||||
int len = XRRGetCrtcGammaSize(dpy, res->crtcs[i]);
|
|
||||||
if(len != gammaRamps[i]->size) {
|
|
||||||
VID_Printf(PRINT_ALL, "WTF, gamma ramp size for display %d has changed from %d to %d!\n",
|
|
||||||
i, gammaRamps[i]->size, len);
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
XRRSetCrtcGamma(dpy, res->crtcs[i], gammaRamps[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// the ramp needs to be free()d either way
|
|
||||||
XRRFreeGamma(gammaRamps[i]);
|
|
||||||
gammaRamps[i] = NULL;
|
|
||||||
|
|
||||||
}
|
|
||||||
XRRFreeScreenResources(res);
|
|
||||||
free(gammaRamps);
|
|
||||||
gammaRamps = NULL;
|
|
||||||
|
|
||||||
VID_Printf(PRINT_ALL, "Restored original Gamma\n");
|
|
||||||
}
|
|
||||||
#endif // X11GAMMA
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initializes the OpenGL window
|
* Initializes the OpenGL window
|
||||||
*/
|
*/
|
||||||
static qboolean
|
qboolean
|
||||||
GLimp_InitGraphics(qboolean fullscreen)
|
GLimp_InitGraphics(qboolean fullscreen, int *pwidth, int *pheight)
|
||||||
{
|
{
|
||||||
int flags;
|
int flags;
|
||||||
int msaa_samples;
|
int curWidth, curHeight;
|
||||||
int stencil_bits;
|
|
||||||
int width, height;
|
|
||||||
char title[24];
|
char title[24];
|
||||||
|
int width = *pwidth;
|
||||||
|
int height = *pheight;
|
||||||
|
|
||||||
if (GetWindowSize(&width, &height) && (width == vid.width) && (height == vid.height))
|
if (GetWindowSize(&curWidth, &curHeight) && (curWidth == width) && (curHeight == height))
|
||||||
{
|
{
|
||||||
/* If we want fullscreen, but aren't */
|
/* If we want fullscreen, but aren't */
|
||||||
if (fullscreen != IsFullscreen())
|
if (fullscreen != IsFullscreen())
|
||||||
|
@ -552,45 +261,21 @@ GLimp_InitGraphics(qboolean fullscreen)
|
||||||
if (window)
|
if (window)
|
||||||
{
|
{
|
||||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||||
SDL_GL_DeleteContext(context);
|
|
||||||
|
re.ShutdownWindow(true);
|
||||||
|
|
||||||
SDL_DestroyWindow(window);
|
SDL_DestroyWindow(window);
|
||||||
#else
|
#else
|
||||||
SDL_FreeSurface(window);
|
SDL_FreeSurface(window);
|
||||||
#endif
|
#endif
|
||||||
|
window = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create the window */
|
/* Create the window */
|
||||||
VID_NewWindow(vid.width, vid.height);
|
VID_NewWindow(width, height);
|
||||||
|
|
||||||
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
|
// let renderer prepare things (set OpenGL attributes)
|
||||||
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
|
flags = re.PrepareForWindow();
|
||||||
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
|
|
||||||
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
|
|
||||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
|
||||||
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
|
|
||||||
|
|
||||||
if (gl_msaa_samples->value)
|
|
||||||
{
|
|
||||||
msaa_samples = gl_msaa_samples->value;
|
|
||||||
|
|
||||||
if (SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1) < 0)
|
|
||||||
{
|
|
||||||
Com_Printf("MSAA is unsupported: %s\n", SDL_GetError());
|
|
||||||
Cvar_SetValue ("gl_msaa_samples", 0);
|
|
||||||
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
|
|
||||||
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);
|
|
||||||
}
|
|
||||||
else if (SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, msaa_samples) < 0)
|
|
||||||
{
|
|
||||||
Com_Printf("MSAA %ix is unsupported: %s\n", msaa_samples, SDL_GetError());
|
|
||||||
Cvar_SetValue("gl_msaa_samples", 0);
|
|
||||||
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
|
|
||||||
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Initiate the flags */
|
|
||||||
flags = SDL_OPENGL;
|
|
||||||
|
|
||||||
if (fullscreen)
|
if (fullscreen)
|
||||||
{
|
{
|
||||||
|
@ -598,34 +283,31 @@ GLimp_InitGraphics(qboolean fullscreen)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !SDL_VERSION_ATLEAST(2, 0, 0)
|
#if !SDL_VERSION_ATLEAST(2, 0, 0)
|
||||||
/* For SDL1.2, these things must be done before creating the window */
|
/* Set window icon - For SDL1.2, this must be done before creating the window */
|
||||||
|
|
||||||
/* Set the icon */
|
|
||||||
SetSDLIcon();
|
SetSDLIcon();
|
||||||
|
|
||||||
/* Set vsync */
|
|
||||||
SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, gl_swapinterval->value ? 1 : 0);
|
|
||||||
vsync_active = gl_swapinterval->value ? true : false;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
if (!CreateSDLWindow(flags))
|
if (!CreateSDLWindow(flags, width, height))
|
||||||
{
|
{
|
||||||
|
#if 0 // DG: do we really need to do this? it makes things complicated and belongs into ref dll
|
||||||
if (gl_msaa_samples->value)
|
if (gl_msaa_samples->value)
|
||||||
{
|
{
|
||||||
VID_Printf(PRINT_ALL, "SDL SetVideoMode failed: %s\n",
|
VID_Printf(PRINT_ALL, "SDL SetVideoMode failed: %s\n",
|
||||||
SDL_GetError());
|
SDL_GetError());
|
||||||
VID_Printf(PRINT_ALL, "Reverting to %s gl_mode %i (%ix%i) without MSAA.\n",
|
VID_Printf(PRINT_ALL, "Reverting to %s gl_mode %i (%ix%i) without MSAA.\n",
|
||||||
(flags & SDL_FULLSCREEN) ? "fullscreen" : "windowed",
|
(flags & SDL_FULLSCREEN) ? "fullscreen" : "windowed",
|
||||||
(int)Cvar_VariableValue("gl_mode"), vid.width, vid.height);
|
(int)Cvar_VariableValue("gl_mode"), width, height);
|
||||||
|
|
||||||
/* Try to recover */
|
/* Try to recover */
|
||||||
Cvar_SetValue("gl_msaa_samples", 0);
|
Cvar_SetValue("gl_msaa_samples", 0);
|
||||||
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
|
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
|
||||||
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);
|
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);
|
||||||
}
|
}
|
||||||
else if (vid.width != 640 || vid.height != 480 || (flags & SDL_FULLSCREEN))
|
else
|
||||||
|
#endif // 0
|
||||||
|
if (width != 640 || height != 480 || (flags & SDL_FULLSCREEN))
|
||||||
{
|
{
|
||||||
VID_Printf(PRINT_ALL, "SDL SetVideoMode failed: %s\n",
|
VID_Printf(PRINT_ALL, "SDL SetVideoMode failed: %s\n",
|
||||||
SDL_GetError());
|
SDL_GetError());
|
||||||
|
@ -634,8 +316,9 @@ GLimp_InitGraphics(qboolean fullscreen)
|
||||||
/* Try to recover */
|
/* Try to recover */
|
||||||
Cvar_SetValue("gl_mode", 4);
|
Cvar_SetValue("gl_mode", 4);
|
||||||
Cvar_SetValue("vid_fullscreen", 0);
|
Cvar_SetValue("vid_fullscreen", 0);
|
||||||
vid.width = 640;
|
VID_NewWindow(width, height);
|
||||||
vid.height = 480;
|
*pwidth = width = 640;
|
||||||
|
*pheight = height = 480;
|
||||||
flags &= ~SDL_FULLSCREEN;
|
flags &= ~SDL_FULLSCREEN;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -649,43 +332,25 @@ GLimp_InitGraphics(qboolean fullscreen)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gl_msaa_samples->value)
|
|
||||||
|
if(!re.InitContext(window))
|
||||||
{
|
{
|
||||||
if (SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &msaa_samples) == 0)
|
// InitContext() should have logged an error
|
||||||
{
|
return false;
|
||||||
Cvar_SetValue("gl_msaa_samples", msaa_samples);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
// VSync is really set in the renderer dll, but we want vsync_active here
|
||||||
/* For SDL2, these things must be done after creating the window */
|
// so just get it from the Cvar here, even though it's a bit ugly
|
||||||
|
cvar_t* gl_swapinterval = Cvar_Get("gl_swapinterval", "1", CVAR_ARCHIVE);
|
||||||
/* Set the icon */
|
|
||||||
SetSDLIcon();
|
|
||||||
|
|
||||||
/* Set vsync - TODO: -1 could be set for "late swap tearing" */
|
|
||||||
SDL_GL_SetSwapInterval(gl_swapinterval->value ? 1 : 0);
|
|
||||||
vsync_active = gl_swapinterval->value ? true : false;
|
vsync_active = gl_swapinterval->value ? true : false;
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Initialize the stencil buffer */
|
|
||||||
if (!SDL_GL_GetAttribute(SDL_GL_STENCIL_SIZE, &stencil_bits))
|
|
||||||
{
|
|
||||||
VID_Printf(PRINT_ALL, "Got %d bits of stencil.\n", stencil_bits);
|
|
||||||
|
|
||||||
if (stencil_bits >= 1)
|
|
||||||
{
|
|
||||||
have_stencil = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Initialize hardware gamma */
|
|
||||||
InitGamma();
|
|
||||||
|
|
||||||
/* Window title */
|
/* Window title */
|
||||||
snprintf(title, sizeof(title), "Yamagi Quake II %s", YQ2VERSION);
|
snprintf(title, sizeof(title), "Yamagi Quake II %s", YQ2VERSION);
|
||||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||||
SDL_SetWindowTitle(window, title);
|
SDL_SetWindowTitle(window, title);
|
||||||
|
|
||||||
|
/* Also set the window icon - For SDL2, this must be done after creating the window */
|
||||||
|
SetSDLIcon();
|
||||||
#else
|
#else
|
||||||
SDL_WM_SetCaption(title, title);
|
SDL_WM_SetCaption(title, title);
|
||||||
#endif
|
#endif
|
||||||
|
@ -696,45 +361,6 @@ GLimp_InitGraphics(qboolean fullscreen)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Swaps the buffers to show the new frame
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
GLimp_EndFrame(void)
|
|
||||||
{
|
|
||||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
|
||||||
SDL_GL_SwapWindow(window);
|
|
||||||
#else
|
|
||||||
SDL_GL_SwapBuffers();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Changes the video mode
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
GLimp_SetMode(int *pwidth, int *pheight, int mode, qboolean fullscreen)
|
|
||||||
{
|
|
||||||
VID_Printf(PRINT_ALL, "setting mode %d:", mode);
|
|
||||||
|
|
||||||
/* mode -1 is not in the vid mode table - so we keep the values in pwidth
|
|
||||||
and pheight and don't even try to look up the mode info */
|
|
||||||
if ((mode != -1) && !VID_GetModeInfo(pwidth, pheight, mode))
|
|
||||||
{
|
|
||||||
VID_Printf(PRINT_ALL, " invalid mode\n");
|
|
||||||
return rserr_invalid_mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
VID_Printf(PRINT_ALL, " %d %d\n", *pwidth, *pheight);
|
|
||||||
|
|
||||||
if (!GLimp_InitGraphics(fullscreen))
|
|
||||||
{
|
|
||||||
return rserr_invalid_mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
return rserr_ok;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (Un)grab Input
|
* (Un)grab Input
|
||||||
*/
|
*/
|
||||||
|
@ -790,36 +416,14 @@ int GLimp_GetRefreshRate(void)
|
||||||
* Shuts the SDL render backend down
|
* Shuts the SDL render backend down
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
GLimp_Shutdown(void)
|
VID_ShutdownWindow(void)
|
||||||
{
|
{
|
||||||
/* Clear the backbuffer and make it
|
|
||||||
current. This may help some broken
|
|
||||||
video drivers like the AMD Catalyst
|
|
||||||
to avoid artifacts in unused screen
|
|
||||||
areas. */
|
|
||||||
if (SDL_WasInit(SDL_INIT_VIDEO))
|
|
||||||
{
|
|
||||||
glClearColor(0.0, 0.0, 0.0, 0.0);
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
||||||
GLimp_EndFrame();
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef X11GAMMA
|
|
||||||
RestoreGamma();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (window)
|
if (window)
|
||||||
{
|
{
|
||||||
/* cleanly ungrab input (needs window) */
|
/* cleanly ungrab input (needs window) */
|
||||||
GLimp_GrabInput(false);
|
GLimp_GrabInput(false);
|
||||||
|
|
||||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||||
if(context)
|
|
||||||
{
|
|
||||||
SDL_GL_DeleteContext(context);
|
|
||||||
context = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_DestroyWindow(window);
|
SDL_DestroyWindow(window);
|
||||||
#else
|
#else
|
||||||
SDL_FreeSurface(window);
|
SDL_FreeSurface(window);
|
||||||
|
@ -836,7 +440,4 @@ GLimp_Shutdown(void)
|
||||||
{
|
{
|
||||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||||
}
|
}
|
||||||
|
|
||||||
gl_state.hwgamma = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -658,7 +658,7 @@ SCR_TimeRefresh_f(void)
|
||||||
R_RenderFrame(&cl.refdef);
|
R_RenderFrame(&cl.refdef);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLimp_EndFrame();
|
R_EndFrame();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -669,7 +669,7 @@ SCR_TimeRefresh_f(void)
|
||||||
|
|
||||||
R_BeginFrame(0);
|
R_BeginFrame(0);
|
||||||
R_RenderFrame(&cl.refdef);
|
R_RenderFrame(&cl.refdef);
|
||||||
GLimp_EndFrame();
|
R_EndFrame();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1566,7 +1566,7 @@ SCR_UpdateScreen(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GLimp_EndFrame();
|
R_EndFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
static float
|
static float
|
||||||
|
|
|
@ -52,7 +52,6 @@
|
||||||
#define SHELL_WHITE_COLOR 0xD7
|
#define SHELL_WHITE_COLOR 0xD7
|
||||||
|
|
||||||
#define ENTITY_FLAGS 68
|
#define ENTITY_FLAGS 68
|
||||||
#define API_VERSION 3
|
|
||||||
|
|
||||||
typedef struct entity_s {
|
typedef struct entity_s {
|
||||||
struct model_s *model; /* opaque type outside refresh */
|
struct model_s *model; /* opaque type outside refresh */
|
||||||
|
@ -117,8 +116,127 @@ typedef struct {
|
||||||
particle_t *particles;
|
particle_t *particles;
|
||||||
} refdef_t;
|
} refdef_t;
|
||||||
|
|
||||||
// Soon to be deleted
|
// FIXME: bump API_VERSION?
|
||||||
//void R_GetRefAPI(void);
|
#define API_VERSION 4
|
||||||
|
#define EXPORT
|
||||||
|
#define IMPORT
|
||||||
|
|
||||||
|
//
|
||||||
|
// these are the functions exported by the refresh module
|
||||||
|
//
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
// if api_version is different, the dll cannot be used
|
||||||
|
int api_version;
|
||||||
|
|
||||||
|
// called when the library is loaded - FIXME: remove arguments, not used anyway
|
||||||
|
int (EXPORT *Init) ( void *hinstance, void *wndproc );
|
||||||
|
|
||||||
|
// called before the library is unloaded
|
||||||
|
void (EXPORT *Shutdown) (void);
|
||||||
|
|
||||||
|
// called by GLimp_InitGraphics() before creating window,
|
||||||
|
// returns flags for SDL window creation
|
||||||
|
int (EXPORT *PrepareForWindow)(void);
|
||||||
|
|
||||||
|
// called by GLimp_InitGraphics() *after* creating window,
|
||||||
|
// passing the SDL_Window* (void* so we don't spill SDL.h here)
|
||||||
|
// returns true (1) on success
|
||||||
|
int (EXPORT *InitContext)(void* window);
|
||||||
|
|
||||||
|
// shuts down rendering (OpenGL) context, calls
|
||||||
|
// VID_ShutdownWindow() to shut down window as well, if !contextOnly
|
||||||
|
void (EXPORT *ShutdownWindow)(qboolean contextOnly);
|
||||||
|
|
||||||
|
// All data that will be used in a level should be
|
||||||
|
// registered before rendering any frames to prevent disk hits,
|
||||||
|
// but they can still be registered at a later time
|
||||||
|
// if necessary.
|
||||||
|
//
|
||||||
|
// EndRegistration will free any remaining data that wasn't registered.
|
||||||
|
// Any model_s or skin_s pointers from before the BeginRegistration
|
||||||
|
// are no longer valid after EndRegistration.
|
||||||
|
//
|
||||||
|
// Skins and images need to be differentiated, because skins
|
||||||
|
// are flood filled to eliminate mip map edge errors, and pics have
|
||||||
|
// an implicit "pics/" prepended to the name. (a pic name that starts with a
|
||||||
|
// slash will not use the "pics/" prefix or the ".pcx" postfix)
|
||||||
|
void (EXPORT *BeginRegistration) (char *map);
|
||||||
|
struct model_s * (EXPORT *RegisterModel) (char *name);
|
||||||
|
struct image_s * (EXPORT *RegisterSkin) (char *name);
|
||||||
|
|
||||||
|
void (EXPORT *SetSky) (char *name, float rotate, vec3_t axis);
|
||||||
|
void (EXPORT *EndRegistration) (void);
|
||||||
|
|
||||||
|
void (EXPORT *RenderFrame) (refdef_t *fd);
|
||||||
|
|
||||||
|
struct image_s * (EXPORT *DrawFindPic)(char *name);
|
||||||
|
|
||||||
|
void (EXPORT *DrawGetPicSize) (int *w, int *h, char *name); // will return 0 0 if not found
|
||||||
|
//void (EXPORT *DrawPic) (int x, int y, char *name); - apparently not used anymore
|
||||||
|
void (EXPORT *DrawPicScaled) (int x, int y, char *pic, float factor);
|
||||||
|
void (EXPORT *DrawStretchPic) (int x, int y, int w, int h, char *name);
|
||||||
|
void (EXPORT *DrawChar) (int x, int y, int c);
|
||||||
|
void (EXPORT *DrawCharScaled)(int x, int y, int num, float scale);
|
||||||
|
void (EXPORT *DrawTileClear) (int x, int y, int w, int h, char *name);
|
||||||
|
void (EXPORT *DrawFill) (int x, int y, int w, int h, int c);
|
||||||
|
void (EXPORT *DrawFadeScreen) (void);
|
||||||
|
|
||||||
|
// Draw images for cinematic rendering (which can have a different palette). Note that calls
|
||||||
|
void (EXPORT *DrawStretchRaw) (int x, int y, int w, int h, int cols, int rows, byte *data);
|
||||||
|
|
||||||
|
/*
|
||||||
|
** video mode and refresh state management entry points
|
||||||
|
*/
|
||||||
|
void (EXPORT *SetPalette)( const unsigned char *palette); // NULL = game palette
|
||||||
|
void (EXPORT *BeginFrame)( float camera_separation );
|
||||||
|
void (EXPORT *EndFrame) (void);
|
||||||
|
|
||||||
|
//void (EXPORT *AppActivate)( qboolean activate );
|
||||||
|
} refexport_t;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
void (IMPORT *Sys_Error) (int err_level, char *str, ...) __attribute__ ((format (printf, 2, 3)));
|
||||||
|
|
||||||
|
void (IMPORT *Cmd_AddCommand) (char *name, void(*cmd)(void));
|
||||||
|
void (IMPORT *Cmd_RemoveCommand) (char *name);
|
||||||
|
int (IMPORT *Cmd_Argc) (void);
|
||||||
|
char *(IMPORT *Cmd_Argv) (int i);
|
||||||
|
void (IMPORT *Cmd_ExecuteText) (int exec_when, char *text);
|
||||||
|
|
||||||
|
void (IMPORT *Con_Printf) (int print_level, char *str, ...) __attribute__ ((format (printf, 2, 3)));
|
||||||
|
|
||||||
|
// files will be memory mapped read only
|
||||||
|
// the returned buffer may be part of a larger pak file,
|
||||||
|
// or a discrete file from anywhere in the quake search path
|
||||||
|
// a -1 return means the file does not exist
|
||||||
|
// NULL can be passed for buf to just determine existance
|
||||||
|
int (IMPORT *FS_LoadFile) (char *name, void **buf);
|
||||||
|
void (IMPORT *FS_FreeFile) (void *buf);
|
||||||
|
|
||||||
|
// gamedir will be the current directory that generated
|
||||||
|
// files should be stored to, ie: "f:\quake\id1"
|
||||||
|
char *(IMPORT *FS_Gamedir) (void);
|
||||||
|
|
||||||
|
cvar_t *(IMPORT *Cvar_Get) (char *name, char *value, int flags);
|
||||||
|
cvar_t *(IMPORT *Cvar_Set) (char *name, char *value);
|
||||||
|
void (IMPORT *Cvar_SetValue) (char *name, float value);
|
||||||
|
|
||||||
|
qboolean (IMPORT *Vid_GetModeInfo)(int *width, int *height, int mode);
|
||||||
|
void (IMPORT *Vid_MenuInit)( void );
|
||||||
|
void (IMPORT *Vid_NewWindow)( int width, int height );
|
||||||
|
|
||||||
|
void (IMPORT *Vid_ShutdownWindow)(void);
|
||||||
|
qboolean (IMPORT *GLimp_InitGraphics)(qboolean fullscreen, int *pwidth, int *pheight);
|
||||||
|
} refimport_t;
|
||||||
|
|
||||||
|
// this is the only function actually exported at the linker level
|
||||||
|
typedef refexport_t (EXPORT *GetRefAPI_t) (refimport_t);
|
||||||
|
|
||||||
|
// FIXME: #ifdef client/ref around this
|
||||||
|
extern refexport_t re;
|
||||||
|
extern refimport_t ri;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Refresh API
|
* Refresh API
|
||||||
|
@ -132,19 +250,19 @@ void R_EndRegistration(void);
|
||||||
struct image_s *Draw_FindPic(char *name);
|
struct image_s *Draw_FindPic(char *name);
|
||||||
void R_RenderFrame(refdef_t *fd);
|
void R_RenderFrame(refdef_t *fd);
|
||||||
void Draw_GetPicSize(int *w, int *h, char *name);
|
void Draw_GetPicSize(int *w, int *h, char *name);
|
||||||
void Draw_Pic(int x, int y, char *name);
|
|
||||||
void Draw_StretchPic(int x, int y, int w, int h, char *name);
|
void Draw_StretchPic(int x, int y, int w, int h, char *name);
|
||||||
void Draw_PicScaled(int x, int y, char *pic, float factor);
|
void Draw_PicScaled(int x, int y, char *pic, float factor);
|
||||||
void Draw_Char(int x, int y, int c);
|
|
||||||
void Draw_CharScaled(int x, int y, int num, float scale);
|
void Draw_CharScaled(int x, int y, int num, float scale);
|
||||||
void Draw_TileClear(int x, int y, int w, int h, char *name);
|
void Draw_TileClear(int x, int y, int w, int h, char *name);
|
||||||
void Draw_Fill(int x, int y, int w, int h, int c);
|
void Draw_Fill(int x, int y, int w, int h, int c);
|
||||||
void Draw_FadeScreen(void);
|
void Draw_FadeScreen(void);
|
||||||
void Draw_StretchRaw(int x, int y, int w, int h, int cols, int rows, byte *data);
|
void Draw_StretchRaw(int x, int y, int w, int h, int cols, int rows, byte *data);
|
||||||
int R_Init(void *hinstance, void *hWnd);
|
//int R_Init(void *hinstance, void *hWnd);
|
||||||
void R_Shutdown(void);
|
//void R_Shutdown(void);
|
||||||
void R_SetPalette(const unsigned char *palette);
|
void R_SetPalette(const unsigned char *palette);
|
||||||
void R_BeginFrame(float camera_separation);
|
void R_BeginFrame(float camera_separation);
|
||||||
void GLimp_EndFrame(void);
|
void R_EndFrame(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1251,7 +1251,7 @@ UpdateSoundQualityFunc(void *unused)
|
||||||
M_Popup();
|
M_Popup();
|
||||||
|
|
||||||
/* the text box won't show up unless we do a buffer swap */
|
/* the text box won't show up unless we do a buffer swap */
|
||||||
GLimp_EndFrame();
|
R_EndFrame();
|
||||||
|
|
||||||
CL_Snd_Restart_f();
|
CL_Snd_Restart_f();
|
||||||
}
|
}
|
||||||
|
@ -2566,7 +2566,7 @@ SearchLocalGames(void)
|
||||||
M_Popup();
|
M_Popup();
|
||||||
|
|
||||||
/* the text box won't show up unless we do a buffer swap */
|
/* the text box won't show up unless we do a buffer swap */
|
||||||
GLimp_EndFrame();
|
R_EndFrame();
|
||||||
|
|
||||||
/* send out info packets */
|
/* send out info packets */
|
||||||
CL_PingServers_f();
|
CL_PingServers_f();
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
* =======================================================================
|
* =======================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "header/local.h"
|
#include "../header/local.h"
|
||||||
|
|
||||||
image_t *draw_chars;
|
image_t *draw_chars;
|
||||||
|
|
||||||
|
@ -51,18 +51,7 @@ Draw_InitLocal(void)
|
||||||
* smoothly scrolled off.
|
* smoothly scrolled off.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
Draw_Char(int x, int y, int num)
|
RDraw_CharScaled(int x, int y, int num, float scale)
|
||||||
{
|
|
||||||
Draw_CharScaled(x, y, num, 1.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Draws one 8*8 graphics character with 0 being transparent.
|
|
||||||
* It can be clipped to the top of the screen to allow the console to be
|
|
||||||
* smoothly scrolled off.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
Draw_CharScaled(int x, int y, int num, float scale)
|
|
||||||
{
|
{
|
||||||
int row, col;
|
int row, col;
|
||||||
float frow, fcol, size, scaledSize;
|
float frow, fcol, size, scaledSize;
|
||||||
|
@ -116,7 +105,7 @@ Draw_CharScaled(int x, int y, int num, float scale)
|
||||||
}
|
}
|
||||||
|
|
||||||
image_t *
|
image_t *
|
||||||
Draw_FindPic(char *name)
|
RDraw_FindPic(char *name)
|
||||||
{
|
{
|
||||||
image_t *gl;
|
image_t *gl;
|
||||||
char fullname[MAX_QPATH];
|
char fullname[MAX_QPATH];
|
||||||
|
@ -135,11 +124,11 @@ Draw_FindPic(char *name)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Draw_GetPicSize(int *w, int *h, char *pic)
|
RDraw_GetPicSize(int *w, int *h, char *pic)
|
||||||
{
|
{
|
||||||
image_t *gl;
|
image_t *gl;
|
||||||
|
|
||||||
gl = Draw_FindPic(pic);
|
gl = RDraw_FindPic(pic);
|
||||||
|
|
||||||
if (!gl)
|
if (!gl)
|
||||||
{
|
{
|
||||||
|
@ -152,11 +141,11 @@ Draw_GetPicSize(int *w, int *h, char *pic)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Draw_StretchPic(int x, int y, int w, int h, char *pic)
|
RDraw_StretchPic(int x, int y, int w, int h, char *pic)
|
||||||
{
|
{
|
||||||
image_t *gl;
|
image_t *gl;
|
||||||
|
|
||||||
gl = Draw_FindPic(pic);
|
gl = RDraw_FindPic(pic);
|
||||||
|
|
||||||
if (!gl)
|
if (!gl)
|
||||||
{
|
{
|
||||||
|
@ -197,17 +186,11 @@ Draw_StretchPic(int x, int y, int w, int h, char *pic)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Draw_Pic(int x, int y, char *pic)
|
RDraw_PicScaled(int x, int y, char *pic, float factor)
|
||||||
{
|
|
||||||
Draw_PicScaled(x, y, pic, 1.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Draw_PicScaled(int x, int y, char *pic, float factor)
|
|
||||||
{
|
{
|
||||||
image_t *gl;
|
image_t *gl;
|
||||||
|
|
||||||
gl = Draw_FindPic(pic);
|
gl = RDraw_FindPic(pic);
|
||||||
|
|
||||||
if (!gl)
|
if (!gl)
|
||||||
{
|
{
|
||||||
|
@ -253,11 +236,11 @@ Draw_PicScaled(int x, int y, char *pic, float factor)
|
||||||
* refresh window.
|
* refresh window.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
Draw_TileClear(int x, int y, int w, int h, char *pic)
|
RDraw_TileClear(int x, int y, int w, int h, char *pic)
|
||||||
{
|
{
|
||||||
image_t *image;
|
image_t *image;
|
||||||
|
|
||||||
image = Draw_FindPic(pic);
|
image = RDraw_FindPic(pic);
|
||||||
|
|
||||||
if (!image)
|
if (!image)
|
||||||
{
|
{
|
||||||
|
@ -296,7 +279,7 @@ Draw_TileClear(int x, int y, int w, int h, char *pic)
|
||||||
* Fills a box of pixels with a single color
|
* Fills a box of pixels with a single color
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
Draw_Fill(int x, int y, int w, int h, int c)
|
RDraw_Fill(int x, int y, int w, int h, int c)
|
||||||
{
|
{
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
|
@ -334,7 +317,7 @@ Draw_Fill(int x, int y, int w, int h, int c)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Draw_FadeScreen(void)
|
RDraw_FadeScreen(void)
|
||||||
{
|
{
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
@ -360,7 +343,7 @@ Draw_FadeScreen(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Draw_StretchRaw(int x, int y, int w, int h, int cols, int rows, byte *data)
|
RDraw_StretchRaw(int x, int y, int w, int h, int cols, int rows, byte *data)
|
||||||
{
|
{
|
||||||
GLfloat tex[8];
|
GLfloat tex[8];
|
||||||
byte *source;
|
byte *source;
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
* =======================================================================
|
* =======================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "header/local.h"
|
#include "../header/local.h"
|
||||||
|
|
||||||
image_t gltextures[MAX_GLTEXTURES];
|
image_t gltextures[MAX_GLTEXTURES];
|
||||||
int numgltextures;
|
int numgltextures;
|
||||||
|
@ -1201,7 +1201,7 @@ R_FindImage(char *name, imagetype_t type)
|
||||||
}
|
}
|
||||||
|
|
||||||
struct image_s *
|
struct image_s *
|
||||||
R_RegisterSkin(char *name)
|
RI_RegisterSkin(char *name)
|
||||||
{
|
{
|
||||||
return R_FindImage(name, it_skin);
|
return R_FindImage(name, it_skin);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
* =======================================================================
|
* =======================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "header/local.h"
|
#include "../header/local.h"
|
||||||
|
|
||||||
#define DLIGHT_CUTOFF 64
|
#define DLIGHT_CUTOFF 64
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
* =======================================================================
|
* =======================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "header/local.h"
|
#include "../header/local.h"
|
||||||
|
|
||||||
extern gllightmapstate_t gl_lms;
|
extern gllightmapstate_t gl_lms;
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
* =======================================================================
|
* =======================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "header/local.h"
|
#include "../header/local.h"
|
||||||
|
|
||||||
#define NUM_BEAM_SEGS 6
|
#define NUM_BEAM_SEGS 6
|
||||||
|
|
||||||
|
@ -134,6 +134,9 @@ cvar_t *gl_stereo_separation;
|
||||||
cvar_t *gl_stereo_anaglyph_colors;
|
cvar_t *gl_stereo_anaglyph_colors;
|
||||||
cvar_t *gl_stereo_convergence;
|
cvar_t *gl_stereo_convergence;
|
||||||
|
|
||||||
|
|
||||||
|
refimport_t ri; // TODO: put this in some header ?
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns true if the box is completely outside the frustom
|
* Returns true if the box is completely outside the frustom
|
||||||
*/
|
*/
|
||||||
|
@ -1179,7 +1182,7 @@ R_SetLightLevel(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
R_RenderFrame(refdef_t *fd)
|
RI_RenderFrame(refdef_t *fd)
|
||||||
{
|
{
|
||||||
R_RenderView(fd);
|
R_RenderView(fd);
|
||||||
R_SetLightLevel();
|
R_SetLightLevel();
|
||||||
|
@ -1263,6 +1266,32 @@ R_Register(void)
|
||||||
Cmd_AddCommand("gl_strings", R_Strings);
|
Cmd_AddCommand("gl_strings", R_Strings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Changes the video mode
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
SetMode_impl(int *pwidth, int *pheight, int mode, qboolean fullscreen)
|
||||||
|
{
|
||||||
|
VID_Printf(PRINT_ALL, "setting mode %d:", mode);
|
||||||
|
|
||||||
|
/* mode -1 is not in the vid mode table - so we keep the values in pwidth
|
||||||
|
and pheight and don't even try to look up the mode info */
|
||||||
|
if ((mode != -1) && !VID_GetModeInfo(pwidth, pheight, mode))
|
||||||
|
{
|
||||||
|
VID_Printf(PRINT_ALL, " invalid mode\n");
|
||||||
|
return rserr_invalid_mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
VID_Printf(PRINT_ALL, " %d %d\n", *pwidth, *pheight);
|
||||||
|
|
||||||
|
if (!ri.GLimp_InitGraphics(fullscreen, pwidth, pheight))
|
||||||
|
{
|
||||||
|
return rserr_invalid_mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rserr_ok;
|
||||||
|
}
|
||||||
|
|
||||||
qboolean
|
qboolean
|
||||||
R_SetMode(void)
|
R_SetMode(void)
|
||||||
{
|
{
|
||||||
|
@ -1279,7 +1308,7 @@ R_SetMode(void)
|
||||||
vid.width = gl_customwidth->value;
|
vid.width = gl_customwidth->value;
|
||||||
vid.height = gl_customheight->value;
|
vid.height = gl_customheight->value;
|
||||||
|
|
||||||
if ((err = GLimp_SetMode(&vid.width, &vid.height, gl_mode->value,
|
if ((err = SetMode_impl(&vid.width, &vid.height, gl_mode->value,
|
||||||
fullscreen)) == rserr_ok)
|
fullscreen)) == rserr_ok)
|
||||||
{
|
{
|
||||||
if (gl_mode->value == -1)
|
if (gl_mode->value == -1)
|
||||||
|
@ -1299,7 +1328,7 @@ R_SetMode(void)
|
||||||
vid_fullscreen->modified = false;
|
vid_fullscreen->modified = false;
|
||||||
VID_Printf(PRINT_ALL, "ref_gl::R_SetMode() - fullscreen unavailable in this mode\n");
|
VID_Printf(PRINT_ALL, "ref_gl::R_SetMode() - fullscreen unavailable in this mode\n");
|
||||||
|
|
||||||
if ((err = GLimp_SetMode(&vid.width, &vid.height, gl_mode->value, false)) == rserr_ok)
|
if ((err = SetMode_impl(&vid.width, &vid.height, gl_mode->value, false)) == rserr_ok)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1312,7 +1341,7 @@ R_SetMode(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* try setting it back to something safe */
|
/* try setting it back to something safe */
|
||||||
if ((err = GLimp_SetMode(&vid.width, &vid.height, gl_state.prev_mode, false)) != rserr_ok)
|
if ((err = SetMode_impl(&vid.width, &vid.height, gl_state.prev_mode, false)) != rserr_ok)
|
||||||
{
|
{
|
||||||
VID_Printf(PRINT_ALL, "ref_gl::R_SetMode() - could not revert to safe mode\n");
|
VID_Printf(PRINT_ALL, "ref_gl::R_SetMode() - could not revert to safe mode\n");
|
||||||
return false;
|
return false;
|
||||||
|
@ -1323,7 +1352,7 @@ R_SetMode(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
R_Init(void *hinstance, void *hWnd)
|
RI_Init(void *hinstance, void *hWnd)
|
||||||
{
|
{
|
||||||
int j;
|
int j;
|
||||||
extern float r_turbsin[256];
|
extern float r_turbsin[256];
|
||||||
|
@ -1518,7 +1547,7 @@ R_Init(void *hinstance, void *hWnd)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
R_Shutdown(void)
|
RI_Shutdown(void)
|
||||||
{
|
{
|
||||||
Cmd_RemoveCommand("modellist");
|
Cmd_RemoveCommand("modellist");
|
||||||
Cmd_RemoveCommand("screenshot");
|
Cmd_RemoveCommand("screenshot");
|
||||||
|
@ -1530,7 +1559,7 @@ R_Shutdown(void)
|
||||||
R_ShutdownImages();
|
R_ShutdownImages();
|
||||||
|
|
||||||
/* shutdown OS specific OpenGL stuff like contexts, etc. */
|
/* shutdown OS specific OpenGL stuff like contexts, etc. */
|
||||||
GLimp_Shutdown();
|
RI_ShutdownWindow(false);
|
||||||
|
|
||||||
/* shutdown our QGL subsystem */
|
/* shutdown our QGL subsystem */
|
||||||
QGL_Shutdown();
|
QGL_Shutdown();
|
||||||
|
@ -1539,7 +1568,7 @@ R_Shutdown(void)
|
||||||
extern void UpdateHardwareGamma();
|
extern void UpdateHardwareGamma();
|
||||||
|
|
||||||
void
|
void
|
||||||
R_BeginFrame(float camera_separation)
|
RI_BeginFrame(float camera_separation)
|
||||||
{
|
{
|
||||||
gl_state.camera_separation = camera_separation;
|
gl_state.camera_separation = camera_separation;
|
||||||
|
|
||||||
|
@ -1666,7 +1695,7 @@ R_BeginFrame(float camera_separation)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
R_SetPalette(const unsigned char *palette)
|
RI_SetPalette(const unsigned char *palette)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -1790,3 +1819,72 @@ R_DrawBeam(entity_t *e)
|
||||||
glDepthMask(GL_TRUE);
|
glDepthMask(GL_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern int RI_PrepareForWindow(void);
|
||||||
|
extern int RI_InitContext(void* win);
|
||||||
|
|
||||||
|
extern void RI_BeginRegistration(char *model);
|
||||||
|
extern struct model_s * RI_RegisterModel(char *name);
|
||||||
|
extern struct image_s * RI_RegisterSkin(char *name);
|
||||||
|
|
||||||
|
extern void RI_SetSky(char *name, float rotate, vec3_t axis);
|
||||||
|
extern void RI_EndRegistration(void);
|
||||||
|
|
||||||
|
extern void RI_RenderFrame(refdef_t *fd);
|
||||||
|
|
||||||
|
extern image_t * RDraw_FindPic(char *name);
|
||||||
|
extern void RDraw_GetPicSize(int *w, int *h, char *pic);
|
||||||
|
extern void RDraw_PicScaled(int x, int y, char *pic, float factor);
|
||||||
|
extern void RDraw_StretchPic(int x, int y, int w, int h, char *pic);
|
||||||
|
extern void RDraw_CharScaled(int x, int y, int num, float scale);
|
||||||
|
extern void RDraw_TileClear(int x, int y, int w, int h, char *pic);
|
||||||
|
extern void RDraw_Fill(int x, int y, int w, int h, int c);
|
||||||
|
extern void RDraw_FadeScreen(void);
|
||||||
|
extern void RDraw_StretchRaw(int x, int y, int w, int h, int cols, int rows, byte *data);
|
||||||
|
|
||||||
|
extern void RI_SetPalette(const unsigned char *palette);
|
||||||
|
extern void RI_EndFrame(void);
|
||||||
|
|
||||||
|
refexport_t
|
||||||
|
GetRefAPI(refimport_t imp)
|
||||||
|
{
|
||||||
|
refexport_t re = {0};
|
||||||
|
|
||||||
|
ri = imp;
|
||||||
|
|
||||||
|
re.api_version = API_VERSION;
|
||||||
|
|
||||||
|
re.Init = RI_Init;
|
||||||
|
re.Shutdown = RI_Shutdown;
|
||||||
|
re.PrepareForWindow = RI_PrepareForWindow;
|
||||||
|
re.InitContext = RI_InitContext;
|
||||||
|
re.ShutdownWindow = RI_ShutdownWindow;
|
||||||
|
re.BeginRegistration = RI_BeginRegistration;
|
||||||
|
re.RegisterModel = RI_RegisterModel;
|
||||||
|
re.RegisterSkin = RI_RegisterSkin;
|
||||||
|
|
||||||
|
re.SetSky = RI_SetSky;
|
||||||
|
re.EndRegistration = RI_EndRegistration;
|
||||||
|
|
||||||
|
re.RenderFrame = RI_RenderFrame;
|
||||||
|
|
||||||
|
re.DrawFindPic = RDraw_FindPic;
|
||||||
|
|
||||||
|
re.DrawGetPicSize = RDraw_GetPicSize;
|
||||||
|
//re.DrawPic = Draw_Pic;
|
||||||
|
re.DrawPicScaled = RDraw_PicScaled;
|
||||||
|
re.DrawStretchPic = RDraw_StretchPic;
|
||||||
|
//re.DrawChar = Draw_Char;
|
||||||
|
re.DrawCharScaled = RDraw_CharScaled;
|
||||||
|
re.DrawTileClear = RDraw_TileClear;
|
||||||
|
re.DrawFill = RDraw_Fill;
|
||||||
|
re.DrawFadeScreen = RDraw_FadeScreen;
|
||||||
|
|
||||||
|
re.DrawStretchRaw = RDraw_StretchRaw;
|
||||||
|
|
||||||
|
re.SetPalette = RI_SetPalette;
|
||||||
|
re.BeginFrame = RI_BeginFrame;
|
||||||
|
re.EndFrame = RI_EndFrame;
|
||||||
|
|
||||||
|
return re;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,18 +24,18 @@
|
||||||
* =======================================================================
|
* =======================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "header/local.h"
|
#include "../header/local.h"
|
||||||
|
|
||||||
#define NUMVERTEXNORMALS 162
|
#define NUMVERTEXNORMALS 162
|
||||||
#define SHADEDOT_QUANT 16
|
#define SHADEDOT_QUANT 16
|
||||||
|
|
||||||
float r_avertexnormals[NUMVERTEXNORMALS][3] = {
|
float r_avertexnormals[NUMVERTEXNORMALS][3] = {
|
||||||
#include "constants/anorms.h"
|
#include "../constants/anorms.h"
|
||||||
};
|
};
|
||||||
|
|
||||||
/* precalculated dot products for quantized angles */
|
/* precalculated dot products for quantized angles */
|
||||||
float r_avertexnormal_dots[SHADEDOT_QUANT][256] =
|
float r_avertexnormal_dots[SHADEDOT_QUANT][256] =
|
||||||
#include "constants/anormtab.h"
|
#include "../constants/anormtab.h"
|
||||||
;
|
;
|
||||||
|
|
||||||
typedef float vec4_t[4];
|
typedef float vec4_t[4];
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
* =======================================================================
|
* =======================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "header/local.h"
|
#include "../header/local.h"
|
||||||
|
|
||||||
byte dottexture[8][8] = {
|
byte dottexture[8][8] = {
|
||||||
{0, 0, 0, 0, 0, 0, 0, 0},
|
{0, 0, 0, 0, 0, 0, 0, 0},
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
* =======================================================================
|
* =======================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "header/local.h"
|
#include "../header/local.h"
|
||||||
|
|
||||||
#define MAX_MOD_KNOWN 512
|
#define MAX_MOD_KNOWN 512
|
||||||
|
|
||||||
|
@ -980,7 +980,7 @@ Mod_FreeAll(void)
|
||||||
* Specifies the model that will be used as the world
|
* Specifies the model that will be used as the world
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
R_BeginRegistration(char *model)
|
RI_BeginRegistration(char *model)
|
||||||
{
|
{
|
||||||
char fullname[MAX_QPATH];
|
char fullname[MAX_QPATH];
|
||||||
cvar_t *flushmap;
|
cvar_t *flushmap;
|
||||||
|
@ -1006,7 +1006,7 @@ R_BeginRegistration(char *model)
|
||||||
}
|
}
|
||||||
|
|
||||||
struct model_s *
|
struct model_s *
|
||||||
R_RegisterModel(char *name)
|
RI_RegisterModel(char *name)
|
||||||
{
|
{
|
||||||
model_t *mod;
|
model_t *mod;
|
||||||
int i;
|
int i;
|
||||||
|
@ -1055,7 +1055,7 @@ R_RegisterModel(char *name)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
R_EndRegistration(void)
|
RI_EndRegistration(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
model_t *mod;
|
model_t *mod;
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
* =======================================================================
|
* =======================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "header/local.h"
|
#include "../header/local.h"
|
||||||
|
|
||||||
int scrap_allocated[MAX_SCRAPS][BLOCK_WIDTH];
|
int scrap_allocated[MAX_SCRAPS][BLOCK_WIDTH];
|
||||||
byte scrap_texels[MAX_SCRAPS][BLOCK_WIDTH * BLOCK_HEIGHT];
|
byte scrap_texels[MAX_SCRAPS][BLOCK_WIDTH * BLOCK_HEIGHT];
|
||||||
|
|
449
src/client/refresh/gl/r_sdl.c
Normal file
449
src/client/refresh/gl/r_sdl.c
Normal file
|
@ -0,0 +1,449 @@
|
||||||
|
// SDL-specific OpenGL shit formerly in refresh.c
|
||||||
|
|
||||||
|
#include "../header/local.h"
|
||||||
|
|
||||||
|
#ifdef SDL2
|
||||||
|
#include <SDL2/SDL.h>
|
||||||
|
#else // SDL1.2
|
||||||
|
#include <SDL/SDL.h>
|
||||||
|
#endif //SDL2
|
||||||
|
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
#include <OpenGL/gl.h>
|
||||||
|
#else
|
||||||
|
#include <GL/gl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* X.org stuff - put this here as more modern renderers wouldn't need it
|
||||||
|
* e.g. an OpenGL3 renderer could just apply gamma through a shader */
|
||||||
|
#ifdef X11GAMMA
|
||||||
|
#include <X11/Xos.h>
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <X11/Xutil.h>
|
||||||
|
#include <X11/extensions/xf86vmode.h>
|
||||||
|
#include <X11/extensions/Xrandr.h>
|
||||||
|
|
||||||
|
#include <SDL_syswm.h>
|
||||||
|
|
||||||
|
XRRCrtcGamma** gammaRamps = NULL;
|
||||||
|
int noGammaRamps = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||||
|
static SDL_Window* window = NULL;
|
||||||
|
static SDL_GLContext context = NULL;
|
||||||
|
#else
|
||||||
|
static SDL_Surface* window = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
qboolean have_stencil = false;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns the adress of a GL function
|
||||||
|
*/
|
||||||
|
void *
|
||||||
|
GLimp_GetProcAddress (const char* proc)
|
||||||
|
{
|
||||||
|
return SDL_GL_GetProcAddress ( proc );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* from SDL2 SDL_CalculateGammaRamp, adjusted for arbitrary ramp sizes
|
||||||
|
* because xrandr seems to support ramp sizes != 256 (in theory at least)
|
||||||
|
*/
|
||||||
|
void CalculateGammaRamp(float gamma, Uint16* ramp, int len)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* Input validation */
|
||||||
|
if (gamma < 0.0f ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ramp == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 0.0 gamma is all black */
|
||||||
|
if (gamma == 0.0f) {
|
||||||
|
for (i = 0; i < len; ++i) {
|
||||||
|
ramp[i] = 0;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
} else if (gamma == 1.0f) {
|
||||||
|
/* 1.0 gamma is identity */
|
||||||
|
for (i = 0; i < len; ++i) {
|
||||||
|
ramp[i] = (i << 8) | i;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
/* Calculate a real gamma ramp */
|
||||||
|
int value;
|
||||||
|
gamma = 1.0f / gamma;
|
||||||
|
for (i = 0; i < len; ++i) {
|
||||||
|
value = (int) (pow((double) i / (double) len, gamma) * 65535.0 + 0.5);
|
||||||
|
if (value > 65535) {
|
||||||
|
value = 65535;
|
||||||
|
}
|
||||||
|
ramp[i] = (Uint16) value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sets the hardware gamma
|
||||||
|
*/
|
||||||
|
#ifdef X11GAMMA
|
||||||
|
void
|
||||||
|
UpdateHardwareGamma(void)
|
||||||
|
{
|
||||||
|
float gamma = (vid_gamma->value);
|
||||||
|
int i;
|
||||||
|
|
||||||
|
Display* dpy = NULL;
|
||||||
|
SDL_SysWMinfo info;
|
||||||
|
|
||||||
|
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||||
|
SDL_VERSION(&info.version);
|
||||||
|
if(!SDL_GetWindowWMInfo(window, &info))
|
||||||
|
#else
|
||||||
|
if(SDL_GetWMInfo(&info) != 1)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
VID_Printf(PRINT_ALL, "Couldn't get Window info from SDL\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dpy = info.info.x11.display;
|
||||||
|
|
||||||
|
XRRScreenResources* res = XRRGetScreenResources(dpy, info.info.x11.window);
|
||||||
|
if(res == NULL)
|
||||||
|
{
|
||||||
|
VID_Printf(PRINT_ALL, "Unable to get xrandr screen resources.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(i=0; i < res->ncrtc; ++i)
|
||||||
|
{
|
||||||
|
int len = XRRGetCrtcGammaSize(dpy, res->crtcs[i]);
|
||||||
|
size_t rampSize = len*sizeof(Uint16);
|
||||||
|
Uint16* ramp = malloc(rampSize); // TODO: check for NULL
|
||||||
|
if(ramp == NULL)
|
||||||
|
{
|
||||||
|
VID_Printf(PRINT_ALL, "Couldn't allocate &zd byte of memory for gamma ramp - OOM?!\n", rampSize);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CalculateGammaRamp(gamma, ramp, len);
|
||||||
|
|
||||||
|
XRRCrtcGamma* gamma = XRRAllocGamma(len);
|
||||||
|
|
||||||
|
memcpy(gamma->red, ramp, rampSize);
|
||||||
|
memcpy(gamma->green, ramp, rampSize);
|
||||||
|
memcpy(gamma->blue, ramp, rampSize);
|
||||||
|
|
||||||
|
free(ramp);
|
||||||
|
|
||||||
|
XRRSetCrtcGamma(dpy, res->crtcs[i], gamma);
|
||||||
|
|
||||||
|
XRRFreeGamma(gamma);
|
||||||
|
}
|
||||||
|
|
||||||
|
XRRFreeScreenResources(res);
|
||||||
|
}
|
||||||
|
#else // no X11GAMMA
|
||||||
|
void
|
||||||
|
UpdateHardwareGamma(void)
|
||||||
|
{
|
||||||
|
float gamma = (vid_gamma->value);
|
||||||
|
|
||||||
|
Uint16 ramp[256];
|
||||||
|
CalculateGammaRamp(gamma, ramp, 256);
|
||||||
|
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||||
|
if(SDL_SetWindowGammaRamp(window, ramp, ramp, ramp) != 0) {
|
||||||
|
#else
|
||||||
|
if(SDL_SetGammaRamp(ramp, ramp, ramp) < 0) {
|
||||||
|
#endif
|
||||||
|
VID_Printf(PRINT_ALL, "Setting gamma failed: %s\n", SDL_GetError());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // X11GAMMA
|
||||||
|
|
||||||
|
static void InitGamma()
|
||||||
|
{
|
||||||
|
#ifdef X11GAMMA
|
||||||
|
int i=0;
|
||||||
|
SDL_SysWMinfo info;
|
||||||
|
Display* dpy = NULL;
|
||||||
|
|
||||||
|
if(gammaRamps != NULL) // already saved gamma
|
||||||
|
return;
|
||||||
|
|
||||||
|
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||||
|
SDL_VERSION(&info.version);
|
||||||
|
if(!SDL_GetWindowWMInfo(window, &info))
|
||||||
|
#else
|
||||||
|
if(SDL_GetWMInfo(&info) != 1)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
VID_Printf(PRINT_ALL, "Couldn't get Window info from SDL\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dpy = info.info.x11.display;
|
||||||
|
|
||||||
|
XRRScreenResources* res = XRRGetScreenResources(dpy, info.info.x11.window);
|
||||||
|
if(res == NULL)
|
||||||
|
{
|
||||||
|
VID_Printf(PRINT_ALL, "Unable to get xrandr screen resources.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
noGammaRamps = res->ncrtc;
|
||||||
|
gammaRamps = calloc(noGammaRamps, sizeof(XRRCrtcGamma*));
|
||||||
|
if(gammaRamps == NULL) {
|
||||||
|
VID_Printf(PRINT_ALL, "Couldn't allocate memory for %d gamma ramps - OOM?!\n", noGammaRamps);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(i=0; i < noGammaRamps; ++i)
|
||||||
|
{
|
||||||
|
int len = XRRGetCrtcGammaSize(dpy, res->crtcs[i]);
|
||||||
|
size_t rampSize = len*sizeof(Uint16);
|
||||||
|
|
||||||
|
XRRCrtcGamma* origGamma = XRRGetCrtcGamma(dpy, res->crtcs[i]);
|
||||||
|
|
||||||
|
XRRCrtcGamma* gammaCopy = XRRAllocGamma(len);
|
||||||
|
|
||||||
|
memcpy(gammaCopy->red, origGamma->red, rampSize);
|
||||||
|
memcpy(gammaCopy->green, origGamma->green, rampSize);
|
||||||
|
memcpy(gammaCopy->blue, origGamma->blue, rampSize);
|
||||||
|
|
||||||
|
gammaRamps[i] = gammaCopy;
|
||||||
|
}
|
||||||
|
|
||||||
|
XRRFreeScreenResources(res);
|
||||||
|
|
||||||
|
VID_Printf(PRINT_ALL, "Using hardware gamma via X11/xRandR.\n");
|
||||||
|
#elif __APPLE__
|
||||||
|
gl_state.hwgamma = false;
|
||||||
|
VID_Printf(PRINT_ALL, "Using software gamma (needs vid_restart after changes)\n");
|
||||||
|
return;
|
||||||
|
#else
|
||||||
|
VID_Printf(PRINT_ALL, "Using hardware gamma via SDL.\n");
|
||||||
|
#endif
|
||||||
|
gl_state.hwgamma = true;
|
||||||
|
vid_gamma->modified = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef X11GAMMA
|
||||||
|
static void RestoreGamma()
|
||||||
|
{
|
||||||
|
int i=0;
|
||||||
|
SDL_SysWMinfo info;
|
||||||
|
Display* dpy = NULL;
|
||||||
|
|
||||||
|
if(gammaRamps == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||||
|
SDL_VERSION(&info.version);
|
||||||
|
if(!SDL_GetWindowWMInfo(window, &info))
|
||||||
|
#else
|
||||||
|
if(SDL_GetWMInfo(&info) != 1)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
VID_Printf(PRINT_ALL, "Couldn't get Window info from SDL\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dpy = info.info.x11.display;
|
||||||
|
|
||||||
|
XRRScreenResources* res = XRRGetScreenResources(dpy, info.info.x11.window);
|
||||||
|
if(res == NULL)
|
||||||
|
{
|
||||||
|
VID_Printf(PRINT_ALL, "Unable to get xrandr screen resources.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(i=0; i < noGammaRamps; ++i)
|
||||||
|
{
|
||||||
|
// in case a display was unplugged or something, noGammaRamps may be > res->ncrtc
|
||||||
|
if(i < res->ncrtc)
|
||||||
|
{
|
||||||
|
int len = XRRGetCrtcGammaSize(dpy, res->crtcs[i]);
|
||||||
|
if(len != gammaRamps[i]->size) {
|
||||||
|
VID_Printf(PRINT_ALL, "WTF, gamma ramp size for display %d has changed from %d to %d!\n",
|
||||||
|
i, gammaRamps[i]->size, len);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
XRRSetCrtcGamma(dpy, res->crtcs[i], gammaRamps[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// the ramp needs to be free()d either way
|
||||||
|
XRRFreeGamma(gammaRamps[i]);
|
||||||
|
gammaRamps[i] = NULL;
|
||||||
|
|
||||||
|
}
|
||||||
|
XRRFreeScreenResources(res);
|
||||||
|
free(gammaRamps);
|
||||||
|
gammaRamps = NULL;
|
||||||
|
|
||||||
|
VID_Printf(PRINT_ALL, "Restored original Gamma\n");
|
||||||
|
}
|
||||||
|
#endif // X11GAMMA
|
||||||
|
|
||||||
|
|
||||||
|
// called by GLimp_InitGraphics() before creating window,
|
||||||
|
// returns flags for SDL window creation
|
||||||
|
int RI_PrepareForWindow(void)
|
||||||
|
{
|
||||||
|
unsigned int flags = 0;
|
||||||
|
int msaa_samples = 0;
|
||||||
|
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
|
||||||
|
|
||||||
|
#if !SDL_VERSION_ATLEAST(2, 0, 0)
|
||||||
|
/* Set vsync - For SDL1.2, this must be done before creating the window */
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, gl_swapinterval->value ? 1 : 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (gl_msaa_samples->value)
|
||||||
|
{
|
||||||
|
msaa_samples = gl_msaa_samples->value;
|
||||||
|
|
||||||
|
if (SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1) < 0)
|
||||||
|
{
|
||||||
|
Com_Printf("MSAA is unsupported: %s\n", SDL_GetError());
|
||||||
|
Cvar_SetValue ("gl_msaa_samples", 0);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);
|
||||||
|
}
|
||||||
|
else if (SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, msaa_samples) < 0)
|
||||||
|
{
|
||||||
|
Com_Printf("MSAA %ix is unsupported: %s\n", msaa_samples, SDL_GetError());
|
||||||
|
Cvar_SetValue("gl_msaa_samples", 0);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Initiate the flags */
|
||||||
|
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||||
|
flags = SDL_WINDOW_OPENGL;
|
||||||
|
#else // SDL 1.2
|
||||||
|
flags = SDL_OPENGL;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
int RI_InitContext(void* win)
|
||||||
|
{
|
||||||
|
int msaa_samples = 0, stencil_bits = 0;
|
||||||
|
|
||||||
|
if(win == NULL)
|
||||||
|
{
|
||||||
|
VID_Error(ERR_FATAL, "R_InitContext() must not be called with NULL argument!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
window = (SDL_Window*)win;
|
||||||
|
context = SDL_GL_CreateContext(window);
|
||||||
|
if(context == NULL)
|
||||||
|
{
|
||||||
|
VID_Printf(PRINT_ALL, "R_InitContext(): Creating OpenGL Context failed: %s\n", SDL_GetError());
|
||||||
|
window = NULL;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gl_msaa_samples->value)
|
||||||
|
{
|
||||||
|
if (SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &msaa_samples) == 0)
|
||||||
|
{
|
||||||
|
Cvar_SetValue("gl_msaa_samples", msaa_samples);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||||
|
/* For SDL2, this must be done after creating the window */
|
||||||
|
/* Set vsync - TODO: -1 could be set for "late swap tearing" */
|
||||||
|
SDL_GL_SetSwapInterval(gl_swapinterval->value ? 1 : 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Initialize the stencil buffer */
|
||||||
|
if (!SDL_GL_GetAttribute(SDL_GL_STENCIL_SIZE, &stencil_bits))
|
||||||
|
{
|
||||||
|
VID_Printf(PRINT_ALL, "Got %d bits of stencil.\n", stencil_bits);
|
||||||
|
|
||||||
|
if (stencil_bits >= 1)
|
||||||
|
{
|
||||||
|
have_stencil = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Initialize hardware gamma */
|
||||||
|
InitGamma();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Swaps the buffers to show the new frame
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
RI_EndFrame(void)
|
||||||
|
{
|
||||||
|
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||||
|
SDL_GL_SwapWindow(window);
|
||||||
|
#else
|
||||||
|
SDL_GL_SwapBuffers();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Shuts the SDL render backend down
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
RI_ShutdownWindow(qboolean contextOnly)
|
||||||
|
{
|
||||||
|
#ifdef X11GAMMA
|
||||||
|
RestoreGamma();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Clear the backbuffer and make it
|
||||||
|
current. This may help some broken
|
||||||
|
video drivers like the AMD Catalyst
|
||||||
|
to avoid artifacts in unused screen
|
||||||
|
areas. */
|
||||||
|
if (window)
|
||||||
|
{
|
||||||
|
glClearColor(0.0, 0.0, 0.0, 0.0);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
RI_EndFrame();
|
||||||
|
|
||||||
|
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||||
|
if(context)
|
||||||
|
{
|
||||||
|
SDL_GL_DeleteContext(context);
|
||||||
|
context = NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
window = NULL;
|
||||||
|
|
||||||
|
gl_state.hwgamma = false;
|
||||||
|
|
||||||
|
if(!contextOnly)
|
||||||
|
{
|
||||||
|
ri.Vid_ShutdownWindow();
|
||||||
|
}
|
||||||
|
}
|
|
@ -25,7 +25,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "header/local.h"
|
#include "../header/local.h"
|
||||||
|
|
||||||
int c_visible_lightmaps;
|
int c_visible_lightmaps;
|
||||||
int c_visible_textures;
|
int c_visible_textures;
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
* =======================================================================
|
* =======================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "header/local.h"
|
#include "../header/local.h"
|
||||||
|
|
||||||
#define TURBSCALE (256.0 / (2 * M_PI))
|
#define TURBSCALE (256.0 / (2 * M_PI))
|
||||||
#define SUBDIVIDE_SIZE 64
|
#define SUBDIVIDE_SIZE 64
|
||||||
|
@ -48,7 +48,7 @@ unsigned int index_tex = 0;
|
||||||
char *suf[6] = {"rt", "bk", "lf", "ft", "up", "dn"};
|
char *suf[6] = {"rt", "bk", "lf", "ft", "up", "dn"};
|
||||||
|
|
||||||
float r_turbsin[] = {
|
float r_turbsin[] = {
|
||||||
#include "constants/warpsin.h"
|
#include "../constants/warpsin.h"
|
||||||
};
|
};
|
||||||
|
|
||||||
vec3_t skyclip[6] = {
|
vec3_t skyclip[6] = {
|
||||||
|
@ -724,7 +724,7 @@ R_DrawSkyBox(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
R_SetSky(char *name, float rotate, vec3_t axis)
|
RI_SetSky(char *name, float rotate, vec3_t axis)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char pathname[MAX_QPATH];
|
char pathname[MAX_QPATH];
|
||||||
|
|
|
@ -412,14 +412,10 @@ extern glstate_t gl_state;
|
||||||
int GLimp_Init(void);
|
int GLimp_Init(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Shuts the SDL render backend down
|
* Shuts the render context and SDL window down
|
||||||
|
* (if contextOnly, the window will not be shutdown)
|
||||||
*/
|
*/
|
||||||
void GLimp_Shutdown(void);
|
void RI_ShutdownWindow(qboolean contextOnly);
|
||||||
|
|
||||||
/*
|
|
||||||
* Changes the video mode
|
|
||||||
*/
|
|
||||||
int GLimp_SetMode(int *pwidth, int *pheight, int mode, qboolean fullscreen);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns the address of the GL function proc,
|
* Returns the address of the GL function proc,
|
||||||
|
|
Loading…
Reference in a new issue