fix ifdefs
This commit is contained in:
1 parent
f0158dd915
commit
5e8e2f4b3a
8 files changed
+76
-18
No files matched your search
@@ -287,7 +287,9 @@ typedef struct FSurfaceInfo FSurfaceInfo;
|
||||
|
||||
enum hwdsetspecialstate
|
||||
{
|
||||
#ifdef GL_VERSION_3_0
|
||||
HWD_SET_FRAMEBUFFER,
|
||||
#endif
|
||||
HWD_SET_SHADERS,
|
||||
|
||||
HWD_SET_TEXTUREFILTERMODE,
|
||||
|
||||
+19
-9
@@ -70,7 +70,9 @@ static boolean gr_palette_rendering_state = false;
|
||||
// Commands and console variables
|
||||
// ==========================================================================
|
||||
|
||||
#ifdef GL_VERSION_3_0
|
||||
static void CV_grframebuffer_OnChange(void);
|
||||
#endif
|
||||
static void CV_filtermode_ONChange(void);
|
||||
static void CV_anisotropic_ONChange(void);
|
||||
static void CV_screentextures_ONChange(void);
|
||||
@@ -98,7 +100,9 @@ consvar_t cv_grsolvetjoin = {"gr_solvetjoin", "On", 0, CV_OnOff, NULL, 0, NULL,
|
||||
|
||||
consvar_t cv_grbatching = {"gr_batching", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
#ifdef GL_VERSION_3_0
|
||||
consvar_t cv_grframebuffer = {"gr_framebuffer", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, CV_grframebuffer_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||
#endif
|
||||
|
||||
consvar_t cv_grfofcut = {"gr_fofcut", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
@@ -166,14 +170,6 @@ consvar_t cv_grhorizonlines = {"gr_horizonlines", "On", CV_SAVE, CV_OnOff, NULL,
|
||||
|
||||
#define ONLY_IF_GL_LOADED if (vid.glstate != VID_GL_LIBRARY_LOADED) return;
|
||||
|
||||
static void CV_grframebuffer_OnChange(void)
|
||||
{
|
||||
ONLY_IF_GL_LOADED
|
||||
HWD.pfnSetSpecialState(HWD_SET_FRAMEBUFFER, cv_grframebuffer.value);
|
||||
I_DownSample();
|
||||
RefreshSDLSurface();
|
||||
}
|
||||
|
||||
static void CV_filtermode_ONChange(void)
|
||||
{
|
||||
ONLY_IF_GL_LOADED
|
||||
@@ -220,6 +216,16 @@ static void CV_grpalettedepth_OnChange(void)
|
||||
HWR_SetPalette(pLocalPalette);
|
||||
}
|
||||
|
||||
#ifdef GL_VERSION_3_0
|
||||
static void CV_grframebuffer_OnChange(void)
|
||||
{
|
||||
ONLY_IF_GL_LOADED
|
||||
HWD.pfnSetSpecialState(HWD_SET_FRAMEBUFFER, cv_grframebuffer.value);
|
||||
I_DownSample();
|
||||
RefreshSDLSurface();
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
// Sets the shader state.
|
||||
//
|
||||
@@ -5948,7 +5954,9 @@ void HWR_TogglePaletteRendering(void)
|
||||
//added by Hurdler: console varibale that are saved
|
||||
void HWR_AddCommands(void)
|
||||
{
|
||||
#ifdef GL_VERSION_3_0
|
||||
CV_RegisterVar(&cv_grframebuffer);
|
||||
#endif
|
||||
CV_RegisterVar(&cv_grfiltermode);
|
||||
CV_RegisterVar(&cv_granisotropicmode);
|
||||
CV_RegisterVar(&cv_grsolvetjoin);
|
||||
@@ -6011,8 +6019,10 @@ void HWR_Startup(void)
|
||||
HWR_LoadAllCustomShaders();
|
||||
|
||||
HWR_TogglePaletteRendering();
|
||||
|
||||
|
||||
#ifdef GL_VERSION_3_0
|
||||
HWD.pfnSetSpecialState(HWD_SET_FRAMEBUFFER, cv_grframebuffer.value);
|
||||
#endif
|
||||
|
||||
if (msaa)
|
||||
{
|
||||
|
||||
@@ -150,7 +150,9 @@ void HWR_SetShaderState(void);
|
||||
|
||||
// Console variables
|
||||
extern consvar_t cv_grshaders;
|
||||
#ifdef GL_VERSION_3_0
|
||||
extern consvar_t cv_grframebuffer;
|
||||
#endif
|
||||
extern consvar_t cv_grfofcut;
|
||||
extern consvar_t cv_fofzfightfix;
|
||||
extern consvar_t cv_splitwallfix;
|
||||
|
||||
@@ -119,11 +119,12 @@ static GLfloat modelMatrix[16];
|
||||
GLfloat projMatrix[16];
|
||||
static GLint viewport[4];
|
||||
|
||||
#ifdef GL_VERSION_3_0
|
||||
static boolean GLFramebuffer_IsFuncAvailible(void);
|
||||
|
||||
|
||||
GLuint FramebufferObject, FramebufferTexture, RenderbufferObject;
|
||||
GLboolean FrameBufferEnabled = GL_FALSE, RenderToFramebuffer = GL_FALSE;
|
||||
#endif
|
||||
|
||||
// Sryder: NextTexAvail is broken for these because palette changes or changes to the texture filter or antialiasing
|
||||
// flush all of the stored textures, leaving them unavailable at times such as between levels
|
||||
@@ -456,6 +457,7 @@ static PFNglRenderbufferStorage pglRenderbufferStorage;
|
||||
typedef void (APIENTRY * PFNglFramebufferRenderbuffer) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLenum renderbuffer);
|
||||
static PFNglFramebufferRenderbuffer pglFramebufferRenderbuffer;
|
||||
#endif
|
||||
#endif //!STATIC_OPENGL
|
||||
|
||||
/* 1.2 functions for 3D textures */
|
||||
typedef void (APIENTRY * PFNglTexImage3D) (GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
|
||||
@@ -740,6 +742,7 @@ void SetupGLFunc4(void)
|
||||
pglUniform3fv = GetGLFunc("glUniform3fv");
|
||||
pglGetUniformLocation = GetGLFunc("glGetUniformLocation");
|
||||
|
||||
#ifdef GL_VERSION_3_0
|
||||
if (GLFramebuffer_IsFuncAvailible())
|
||||
{
|
||||
pglGenFramebuffers = GetGLFunc("glGenFramebuffers");
|
||||
@@ -755,12 +758,14 @@ void SetupGLFunc4(void)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef GL_VERSION_3_0
|
||||
static boolean GLFramebuffer_IsFuncAvailible(void)
|
||||
{
|
||||
return((isExtAvailable("GL_ARB_framebuffer_no_attachments",gl_extensions)) &&
|
||||
(isExtAvailable("GL_ARB_framebuffer_object",gl_extensions)) &&
|
||||
(isExtAvailable("GL_ARB_framebuffer_sRGB",gl_extensions)));
|
||||
}
|
||||
#endif
|
||||
|
||||
EXPORT boolean HWRAPI(InitShaders) (void)
|
||||
{
|
||||
@@ -1097,6 +1102,7 @@ void GLFramebuffer_Disable(void)
|
||||
pglBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
pglBindRenderbuffer(GL_RENDERBUFFER, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
// -----------------+
|
||||
// DeleteTexture : Deletes a texture from the GPU and frees its data
|
||||
@@ -2308,14 +2314,14 @@ EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value)
|
||||
case HWD_SET_SHADERS:
|
||||
gl_allowshaders = Value;
|
||||
break;
|
||||
|
||||
#ifdef GL_VERSION_3_0
|
||||
case HWD_SET_FRAMEBUFFER:
|
||||
FrameBufferEnabled = Value ? GL_TRUE : GL_FALSE;
|
||||
|
||||
if (!GLFramebuffer_IsFuncAvailible())
|
||||
FrameBufferEnabled = GL_FALSE;
|
||||
break;
|
||||
|
||||
#endif
|
||||
case HWD_SET_TEXTUREFILTERMODE:
|
||||
switch (Value)
|
||||
{
|
||||
|
||||
@@ -104,6 +104,7 @@ static PFNglEnableClientState pglEnableClientState;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef GL_VERSION_3_0
|
||||
void GLFramebuffer_Generate(void);
|
||||
void GLFramebuffer_Delete(void);
|
||||
|
||||
@@ -115,6 +116,7 @@ void GLFramebuffer_Disable(void);
|
||||
|
||||
extern GLuint FramebufferObject, FramebufferTexture, RenderbufferObject;
|
||||
extern GLboolean FrameBufferEnabled, RenderToFramebuffer;
|
||||
#endif
|
||||
|
||||
// ==========================================================================
|
||||
// GLOBAL
|
||||
|
||||
@@ -141,7 +141,12 @@ void RefreshSDLSurface(void);
|
||||
|
||||
boolean I_UseNativeKeyboard(void);
|
||||
|
||||
#ifdef HWRENDER
|
||||
#ifdef GL_VERSION_3_0
|
||||
void RefreshSDLSurface(void);
|
||||
void I_DownSample(void);
|
||||
extern boolean downsample;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+23
-2
@@ -215,14 +215,15 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen);
|
||||
//static void Impl_SetWindowName(const char *title);
|
||||
static void Impl_SetWindowIcon(void);
|
||||
|
||||
boolean downsample = false;
|
||||
|
||||
#ifdef HWRENDER
|
||||
#ifdef GL_VERSION_3_0
|
||||
boolean downsample = false;
|
||||
void RefreshSDLSurface(void)
|
||||
{
|
||||
OglSdlSurface(vid.width, vid.height);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen)
|
||||
{
|
||||
@@ -745,6 +746,8 @@ static INT32 SDLJoyAxis(const Sint16 axis, evtype_t which)
|
||||
return raxis;
|
||||
}
|
||||
|
||||
#ifdef HWRENDER
|
||||
#ifdef GL_VERSION_3_0
|
||||
void I_DownSample(void)
|
||||
{
|
||||
if (!cv_grframebuffer.value)
|
||||
@@ -769,13 +772,19 @@ void I_DownSample(void)
|
||||
else
|
||||
downsample = false; // couldnt get display info so turn the thing off
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
|
||||
{
|
||||
static SDL_bool firsttimeonmouse = SDL_TRUE;
|
||||
static SDL_bool mousefocus = SDL_TRUE;
|
||||
static SDL_bool kbfocus = SDL_TRUE;
|
||||
#ifdef HWRENDER
|
||||
#ifdef GL_VERSION_3_0
|
||||
static SDL_bool windowmoved = SDL_FALSE;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
switch (evt.event)
|
||||
{
|
||||
@@ -795,9 +804,13 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
|
||||
break;
|
||||
case SDL_WINDOWEVENT_MAXIMIZED:
|
||||
break;
|
||||
#ifdef HWRENDER
|
||||
#ifdef GL_VERSION_3_0
|
||||
case SDL_WINDOWEVENT_MOVED:
|
||||
windowmoved = SDL_TRUE;
|
||||
break;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
if (mousefocus && kbfocus)
|
||||
@@ -837,10 +850,14 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HWRENDER
|
||||
#ifdef GL_VERSION_3_0
|
||||
if (windowmoved)
|
||||
{
|
||||
I_DownSample();
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
static void Impl_HandleKeyboardEvent(SDL_KeyboardEvent evt, Uint32 type)
|
||||
@@ -1919,7 +1936,11 @@ INT32 VID_SetMode(INT32 modeNum)
|
||||
}
|
||||
//Impl_SetWindowName("SRB2Kart "VERSIONSTRING);
|
||||
|
||||
#ifdef HWRENDER
|
||||
#ifdef GL_VERSION_3_0
|
||||
I_DownSample();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
SDLSetMode(vid.width, vid.height, USE_FULLSCREEN);
|
||||
Impl_VideoSetupBuffer();
|
||||
|
||||
+14
-4
@@ -171,8 +171,10 @@ boolean OglSdlSurface(INT32 w, INT32 h)
|
||||
supportMipMap = true;
|
||||
|
||||
granisotropicmode_cons_t[1].value = maximumAnisotropy;
|
||||
|
||||
|
||||
#ifdef GL_VERSION_3_0
|
||||
I_DownSample();
|
||||
#endif
|
||||
}
|
||||
first_init = true;
|
||||
|
||||
@@ -190,7 +192,9 @@ boolean OglSdlSurface(INT32 w, INT32 h)
|
||||
if (screen_width != w || screen_height != h)
|
||||
{
|
||||
FlushScreenTextures();
|
||||
#ifdef GL_VERSION_3_0
|
||||
GLFramebuffer_DeleteAttachments();
|
||||
#endif
|
||||
}
|
||||
|
||||
screen_width = (GLint)w;
|
||||
@@ -199,12 +203,14 @@ boolean OglSdlSurface(INT32 w, INT32 h)
|
||||
SetModelView(w, h);
|
||||
SetStates();
|
||||
pglClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT);
|
||||
|
||||
|
||||
#ifdef GL_VERSION_3_0
|
||||
RenderToFramebuffer = FrameBufferEnabled;
|
||||
GLFramebuffer_Disable();
|
||||
|
||||
if (RenderToFramebuffer && downsample)
|
||||
GLFramebuffer_Enable();
|
||||
#endif
|
||||
|
||||
HWR_Startup();
|
||||
textureformatGL = cbpp > 16 ? GL_RGBA : GL_RGB5_A1;
|
||||
@@ -239,14 +245,18 @@ void OglSdlFinishUpdate(boolean waitvbl)
|
||||
|
||||
SDL_GetWindowSize(window, &sdlw, &sdlh);
|
||||
HWR_MakeScreenFinalTexture();
|
||||
|
||||
|
||||
#ifdef GL_VERSION_3_0
|
||||
GLFramebuffer_Disable();
|
||||
RenderToFramebuffer = FrameBufferEnabled;
|
||||
#endif
|
||||
|
||||
HWR_DrawScreenFinalTexture(sdlw, sdlh);
|
||||
|
||||
|
||||
#ifdef GL_VERSION_3_0
|
||||
if (RenderToFramebuffer && downsample)
|
||||
GLFramebuffer_Enable();
|
||||
#endif
|
||||
|
||||
SDL_GL_SwapWindow(window);
|
||||
|
||||
|
||||
Reference in new issue
Block a user