refexport_t::Init() now returns bool and has no args; minor things

the arguments were not used anyway, and returning true/false is clearer
than returning -1 (for error) or sth else (which has no deeper meaning
anyway).

Also:
* PrepareForWindow() can now return -1 if there's an error
* suppress some warnings in Makefile
* fix error for building ref_gl.dylib on OSX
This commit is contained in:
Daniel Gibson 2016-12-21 19:42:36 +01:00
parent 5938a665e8
commit aaa73236ec
5 changed files with 24 additions and 16 deletions

View file

@ -411,6 +411,8 @@ build/client/%.o : %.m
${Q}$(CC) $(OSX_ARCH) -x objective-c -c $< -o $@
endif
release/quake2 : CFLAGS += -Wno-unused-result
ifeq ($(WITH_CDA),yes)
release/quake2 : CFLAGS += -DCDA
endif
@ -508,7 +510,7 @@ build/server/%.o: %.c
${Q}mkdir -p $(@D)
${Q}$(CC) -c $(CFLAGS) $(INCLUDE) -o $@ $<
release/q2ded : CFLAGS += -DDEDICATED_ONLY
release/q2ded : CFLAGS += -DDEDICATED_ONLY -Wno-unused-result
ifeq ($(WITH_ZIP),yes)
release/q2ded : CFLAGS += -DZIP -DNOUNCRYPT
@ -608,7 +610,7 @@ build/baseq2/%.o: %.c
${Q}mkdir -p $(@D)
${Q}$(CC) -c $(CFLAGS) $(INCLUDE) -o $@ $<
release/baseq2/game.so : CFLAGS += -fPIC
release/baseq2/game.so : CFLAGS += -fPIC -Wno-unused-result
release/baseq2/game.so : LDFLAGS += -shared
endif
@ -886,7 +888,7 @@ release/ref_gl.dll : $(REFGL_OBJS)
else ifeq ($(OSTYPE), Darwin)
release/ref_gl.dylib : $(REFGL_OBJS)
@echo "===> LD $@"
${Q}$(CC) $(GAME_OBJS) $(LDFLAGS) $(SDLLDFLAGS) -o $@
${Q}$(CC) $(REFGL_OBJS) $(LDFLAGS) $(SDLLDFLAGS) -o $@
else
release/ref_gl.so : $(REFGL_OBJS)
@echo "===> LD $@"

View file

@ -235,10 +235,12 @@ VID_LoadRefresh(void)
}
// Initiate the refresher
if (re.Init(0, 0) == -1)
if (!re.Init())
{
VID_Shutdown(); // Isn't that just too bad? :(
return false;
Com_Printf("ERROR: Loading %s as rendering backend failed!\n", reflib_path);
Com_Printf("------------------------------------\n\n");
return false; // TODO: try again with default renderer?
}
/* Ensure that all key states are cleared */

View file

@ -275,6 +275,11 @@ GLimp_InitGraphics(qboolean fullscreen, int *pwidth, int *pheight)
// let renderer prepare things (set OpenGL attributes)
flags = re.PrepareForWindow();
if(flags == -1)
{
// hopefully PrepareForWindow() logged an error
return false;
}
if (fullscreen)
{
@ -293,9 +298,8 @@ GLimp_InitGraphics(qboolean fullscreen, int *pwidth, int *pheight)
#if 0 // DG: do we really need to do this? it makes things complicated and belongs into ref dll
if (gl_msaa_samples->value)
{
VID_Printf(PRINT_ALL, "SDL SetVideoMode failed: %s\n",
SDL_GetError());
VID_Printf(PRINT_ALL, "Reverting to %s gl_mode %i (%ix%i) without MSAA.\n",
Com_Printf( "SDL SetVideoMode failed: %s\n", SDL_GetError());
Com_Printf("Reverting to %s gl_mode %i (%ix%i) without MSAA.\n",
(flags & SDL_FULLSCREEN) ? "fullscreen" : "windowed",
(int)Cvar_VariableValue("gl_mode"), width, height);

View file

@ -129,14 +129,14 @@ 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 when the library is loaded
qboolean (EXPORT *Init) (void);
// called before the library is unloaded
void (EXPORT *Shutdown) (void);
// called by GLimp_InitGraphics() before creating window,
// returns flags for SDL window creation
// returns flags for SDL window creation, returns -1 on error
int (EXPORT *PrepareForWindow)(void);
// called by GLimp_InitGraphics() *after* creating window,

View file

@ -1351,8 +1351,8 @@ R_SetMode(void)
return true;
}
int
RI_Init(void *hinstance, void *hWnd)
qboolean
RI_Init()
{
int j;
extern float r_turbsin[256];
@ -1388,7 +1388,7 @@ RI_Init(void *hinstance, void *hWnd)
if (!ri.GLimp_Init())
{
QGL_Shutdown();
return -1;
return false;
}
/* set our "safe" mode */
@ -1400,7 +1400,7 @@ RI_Init(void *hinstance, void *hWnd)
{
QGL_Shutdown();
R_Printf(PRINT_ALL, "ref_gl::R_Init() - could not R_SetMode()\n");
return -1;
return false;
}
ri.Vid_MenuInit();
@ -1431,7 +1431,7 @@ RI_Init(void *hinstance, void *hWnd)
QGL_Shutdown();
R_Printf(PRINT_ALL, "Support for OpenGL 1.4 is not available\n");
return -1;
return false;
}
}