Add NOSCREENFBO compiler flag to be able to build without fbo support
This commit is contained in:
1 parent
6db73bfd63
commit
978cc57889
9 files changed
+59
-9
No files matched your search
@@ -216,6 +216,8 @@ set(SRB2_CONFIG_HWRENDER ON CACHE BOOL
|
||||
"Enable hardware rendering through OpenGL.")
|
||||
set(SRB2_CONFIG_STATIC_OPENGL OFF CACHE BOOL
|
||||
"Use statically linked OpenGL. NOT RECOMMENDED.")
|
||||
set(SRB2_CONFIG_USE_FBO_OGL ON CACHE BOOL
|
||||
"Enable OpenGL FBO Downsampling support.")
|
||||
|
||||
### use internal libraries?
|
||||
if(${CMAKE_SYSTEM} MATCHES "Windows") ###set on Windows only
|
||||
@@ -510,6 +512,10 @@ if(${SRB2_CONFIG_HWRENDER} AND ${SRB2_CONFIG_STATIC_OPENGL})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(${SRB2_CONFIG_USE_FBO_OGL})
|
||||
set(SRB2_USE_FBO_OGL ON)
|
||||
add_definitions(-DUSE_FBO_OGL)
|
||||
endif()
|
||||
|
||||
# Targets
|
||||
|
||||
|
||||
@@ -199,6 +199,10 @@ ifndef NOOPENMPT
|
||||
HAVE_OPENMPT=1
|
||||
endif
|
||||
|
||||
ifndef NOSCREENFBO
|
||||
USE_FBO_OGL=1
|
||||
endif
|
||||
|
||||
ifdef MINGW
|
||||
include win32/Makefile.cfg
|
||||
endif #ifdef MINGW
|
||||
@@ -372,6 +376,10 @@ ifdef STATIC
|
||||
LIBS:=-static $(LIBS)
|
||||
endif
|
||||
|
||||
ifdef USE_FBO_OGL
|
||||
OPTS+=-DUSE_FBO_OGL
|
||||
endif
|
||||
|
||||
ifdef HAVE_MINIUPNPC
|
||||
ifdef NONET
|
||||
HAVE_MINIUPNPC=''
|
||||
|
||||
@@ -287,7 +287,9 @@ typedef struct FSurfaceInfo FSurfaceInfo;
|
||||
|
||||
enum hwdsetspecialstate
|
||||
{
|
||||
#ifdef USE_FBO_OGL
|
||||
HWD_SET_FRAMEBUFFER,
|
||||
#endif
|
||||
HWD_SET_SHADERS,
|
||||
|
||||
HWD_SET_TEXTUREFILTERMODE,
|
||||
|
||||
+11
-1
@@ -69,7 +69,9 @@ static boolean gr_palette_rendering_state = false;
|
||||
// Commands and console variables
|
||||
// ==========================================================================
|
||||
|
||||
#ifdef USE_FBO_OGL
|
||||
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);
|
||||
@@ -97,7 +99,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 USE_FBO_OGL
|
||||
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};
|
||||
|
||||
@@ -213,6 +217,7 @@ static void CV_grpalettedepth_OnChange(void)
|
||||
HWR_SetPalette(pLocalPalette);
|
||||
}
|
||||
|
||||
#ifdef USE_FBO_OGL
|
||||
static void CV_grframebuffer_OnChange(void)
|
||||
{
|
||||
ONLY_IF_GL_LOADED
|
||||
@@ -220,6 +225,7 @@ static void CV_grframebuffer_OnChange(void)
|
||||
I_DownSample();
|
||||
RefreshSDLSurface();
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
// Sets the shader state.
|
||||
@@ -5976,7 +5982,9 @@ void HWR_TogglePaletteRendering(void)
|
||||
//added by Hurdler: console varibale that are saved
|
||||
void HWR_AddCommands(void)
|
||||
{
|
||||
#ifdef USE_FBO_OGL
|
||||
CV_RegisterVar(&cv_grframebuffer);
|
||||
#endif
|
||||
CV_RegisterVar(&cv_grfiltermode);
|
||||
CV_RegisterVar(&cv_granisotropicmode);
|
||||
CV_RegisterVar(&cv_grsolvetjoin);
|
||||
@@ -6039,8 +6047,10 @@ void HWR_Startup(void)
|
||||
HWR_LoadAllCustomShaders();
|
||||
|
||||
HWR_TogglePaletteRendering();
|
||||
|
||||
|
||||
#ifdef USE_FBO_OGL
|
||||
HWD.pfnSetSpecialState(HWD_SET_FRAMEBUFFER, cv_grframebuffer.value);
|
||||
#endif
|
||||
|
||||
if (msaa)
|
||||
{
|
||||
|
||||
@@ -152,7 +152,9 @@ void HWR_SetShaderState(void);
|
||||
|
||||
// Console variables
|
||||
extern consvar_t cv_grshaders;
|
||||
#ifdef USE_FBO_OGL
|
||||
extern consvar_t cv_grframebuffer;
|
||||
#endif
|
||||
extern consvar_t cv_grfofcut;
|
||||
extern consvar_t cv_fofzfightfix;
|
||||
extern consvar_t cv_splitwallfix;
|
||||
|
||||
@@ -119,10 +119,12 @@ static GLfloat modelMatrix[16];
|
||||
GLfloat projMatrix[16];
|
||||
static GLint viewport[4];
|
||||
|
||||
#ifdef USE_FBO_OGL
|
||||
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
|
||||
@@ -433,6 +435,7 @@ static PFNglCopyTexImage2D pglCopyTexImage2D;
|
||||
typedef void (APIENTRY * PFNglCopyTexSubImage2D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
|
||||
static PFNglCopyTexSubImage2D pglCopyTexSubImage2D;
|
||||
|
||||
#ifdef USE_FBO_OGL
|
||||
/* 3.0 functions for framebuffers and renderbuffers */
|
||||
typedef void (APIENTRY * PFNglGenFramebuffers) (GLsizei n, GLuint *ids);
|
||||
static PFNglGenFramebuffers pglGenFramebuffers;
|
||||
@@ -454,6 +457,8 @@ typedef void (APIENTRY * PFNglRenderbufferStorage) (GLenum target, GLenum intern
|
||||
static PFNglRenderbufferStorage pglRenderbufferStorage;
|
||||
typedef void (APIENTRY * PFNglFramebufferRenderbuffer) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLenum renderbuffer);
|
||||
static PFNglFramebufferRenderbuffer pglFramebufferRenderbuffer;
|
||||
#endif // USE_FBO_OGL
|
||||
|
||||
#endif //!STATIC_OPENGL
|
||||
|
||||
/* 1.2 functions for 3D textures */
|
||||
@@ -739,6 +744,7 @@ void SetupGLFunc4(void)
|
||||
pglUniform3fv = GetGLFunc("glUniform3fv");
|
||||
pglGetUniformLocation = GetGLFunc("glGetUniformLocation");
|
||||
|
||||
#ifdef USE_FBO_OGL
|
||||
if (GLFramebuffer_IsFuncAvailible())
|
||||
{
|
||||
pglGenFramebuffers = GetGLFunc("glGenFramebuffers");
|
||||
@@ -752,14 +758,17 @@ void SetupGLFunc4(void)
|
||||
pglRenderbufferStorage = GetGLFunc("glRenderbufferStorage");
|
||||
pglFramebufferRenderbuffer = GetGLFunc("glFramebufferRenderbuffer");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef USE_FBO_OGL
|
||||
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)
|
||||
{
|
||||
@@ -1020,6 +1029,7 @@ EXPORT void HWRAPI(DeleteTexture) (GLMipmap_t *pTexInfo)
|
||||
pTexInfo->downloaded = 0;
|
||||
}
|
||||
|
||||
#ifdef USE_FBO_OGL
|
||||
void GLFramebuffer_Generate(void)
|
||||
{
|
||||
if (!GLFramebuffer_IsFuncAvailible())
|
||||
@@ -1129,6 +1139,7 @@ void GLFramebuffer_Disable(void)
|
||||
pglBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
pglBindRenderbuffer(GL_RENDERBUFFER, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
// -----------------+
|
||||
// Flush : flush OpenGL textures
|
||||
@@ -2305,12 +2316,14 @@ EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value)
|
||||
case HWD_SET_SHADERS:
|
||||
gl_allowshaders = Value;
|
||||
break;
|
||||
#ifdef USE_FBO_OGL
|
||||
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,7 +104,7 @@ static PFNglEnableClientState pglEnableClientState;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef GL_VERSION_3_0
|
||||
#ifdef USE_FBO_OGL
|
||||
void GLFramebuffer_Generate(void);
|
||||
void GLFramebuffer_Delete(void);
|
||||
|
||||
|
||||
+6
-6
@@ -215,7 +215,7 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen);
|
||||
//static void Impl_SetWindowName(const char *title);
|
||||
static void Impl_SetWindowIcon(void);
|
||||
|
||||
#ifdef HWRENDER
|
||||
#ifdef USE_FBO_OGL
|
||||
boolean downsample = false;
|
||||
void RefreshSDLSurface(void)
|
||||
{
|
||||
@@ -745,7 +745,7 @@ static INT32 SDLJoyAxis(const Sint16 axis, evtype_t which)
|
||||
return raxis;
|
||||
}
|
||||
|
||||
#ifdef HWRENDER
|
||||
#ifdef USE_FBO_OGL
|
||||
void I_DownSample(void)
|
||||
{
|
||||
if (!cv_grframebuffer.value || !(rendermode == render_opengl))
|
||||
@@ -777,7 +777,7 @@ 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 USE_FBO_OGL
|
||||
static SDL_bool windowmoved = SDL_FALSE;
|
||||
#endif
|
||||
|
||||
@@ -799,7 +799,7 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
|
||||
break;
|
||||
case SDL_WINDOWEVENT_MAXIMIZED:
|
||||
break;
|
||||
#ifdef HWRENDER
|
||||
#ifdef USE_FBO_OGL
|
||||
case SDL_WINDOWEVENT_MOVED:
|
||||
windowmoved = SDL_TRUE;
|
||||
break;
|
||||
@@ -843,7 +843,7 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HWRENDER
|
||||
#ifdef USE_FBO_OGL
|
||||
if (windowmoved && rendermode == render_opengl)
|
||||
{
|
||||
I_DownSample();
|
||||
@@ -1927,7 +1927,7 @@ INT32 VID_SetMode(INT32 modeNum)
|
||||
}
|
||||
//Impl_SetWindowName("SRB2Kart "VERSIONSTRING);
|
||||
|
||||
#ifdef HWRENDER
|
||||
#ifdef USE_FBO_OGL
|
||||
if (rendermode == render_opengl)
|
||||
I_DownSample();
|
||||
#endif
|
||||
|
||||
+10
-1
@@ -166,8 +166,9 @@ boolean OglSdlSurface(INT32 w, INT32 h)
|
||||
SetupGLFunc4();
|
||||
|
||||
granisotropicmode_cons_t[1].value = maximumAnisotropy;
|
||||
|
||||
#ifdef USE_FBO_OGL
|
||||
I_DownSample();
|
||||
#endif
|
||||
}
|
||||
first_init = true;
|
||||
|
||||
@@ -177,7 +178,9 @@ boolean OglSdlSurface(INT32 w, INT32 h)
|
||||
if (screen_width != w || screen_height != h)
|
||||
{
|
||||
FlushScreenTextures();
|
||||
#ifdef USE_FBO_OGL
|
||||
GLFramebuffer_DeleteAttachments();
|
||||
#endif
|
||||
}
|
||||
|
||||
screen_width = (GLint)w;
|
||||
@@ -187,11 +190,13 @@ boolean OglSdlSurface(INT32 w, INT32 h)
|
||||
SetStates();
|
||||
pglClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT);
|
||||
|
||||
#ifdef USE_FBO_OGL
|
||||
RenderToFramebuffer = FrameBufferEnabled;
|
||||
GLFramebuffer_Disable();
|
||||
|
||||
if (RenderToFramebuffer && downsample)
|
||||
GLFramebuffer_Enable();
|
||||
#endif
|
||||
|
||||
HWR_Startup();
|
||||
textureformatGL = cbpp > 16 ? GL_RGBA : GL_RGB5_A1;
|
||||
@@ -219,13 +224,17 @@ void OglSdlFinishUpdate(boolean waitvbl)
|
||||
SDL_GetWindowSize(window, &sdlw, &sdlh);
|
||||
HWR_MakeScreenFinalTexture();
|
||||
|
||||
#ifdef USE_FBO_OGL
|
||||
GLFramebuffer_Disable();
|
||||
RenderToFramebuffer = FrameBufferEnabled;
|
||||
#endif
|
||||
|
||||
HWR_DrawScreenFinalTexture(sdlw, sdlh);
|
||||
|
||||
#ifdef USE_FBO_OGL
|
||||
if (RenderToFramebuffer && downsample)
|
||||
GLFramebuffer_Enable();
|
||||
#endif
|
||||
|
||||
SDL_GL_SwapWindow(window);
|
||||
|
||||
|
||||
Reference in new issue
Block a user