2016-09-14 18:01:13 +00:00
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Copyright(C) 2005-2016 Christoph Oelckers
|
|
|
|
// All rights reserved.
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with this program. If not, see http://www.gnu.org/licenses/
|
|
|
|
//
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
//
|
2013-06-23 07:49:34 +00:00
|
|
|
/*
|
|
|
|
** gl1_renderer.cpp
|
|
|
|
** Renderer interface
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "gl/system/gl_system.h"
|
|
|
|
#include "files.h"
|
|
|
|
#include "m_swap.h"
|
|
|
|
#include "v_video.h"
|
|
|
|
#include "r_data/r_translate.h"
|
|
|
|
#include "m_png.h"
|
|
|
|
#include "m_crc32.h"
|
|
|
|
#include "w_wad.h"
|
|
|
|
//#include "gl/gl_intern.h"
|
|
|
|
#include "gl/gl_functions.h"
|
|
|
|
#include "vectors.h"
|
2016-07-26 19:27:02 +00:00
|
|
|
#include "doomstat.h"
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2013-09-03 16:29:39 +00:00
|
|
|
#include "gl/system/gl_interface.h"
|
2013-06-23 07:49:34 +00:00
|
|
|
#include "gl/system/gl_framebuffer.h"
|
2014-05-20 22:36:04 +00:00
|
|
|
#include "gl/system/gl_cvars.h"
|
2016-08-17 21:18:47 +00:00
|
|
|
#include "gl/system/gl_debug.h"
|
2013-06-23 07:49:34 +00:00
|
|
|
#include "gl/renderer/gl_renderer.h"
|
|
|
|
#include "gl/renderer/gl_lightdata.h"
|
|
|
|
#include "gl/renderer/gl_renderstate.h"
|
2016-07-26 19:27:02 +00:00
|
|
|
#include "gl/renderer/gl_renderbuffers.h"
|
2016-08-08 10:13:09 +00:00
|
|
|
#include "gl/renderer/gl_2ddrawer.h"
|
2013-06-23 07:49:34 +00:00
|
|
|
#include "gl/data/gl_data.h"
|
|
|
|
#include "gl/data/gl_vertexbuffer.h"
|
|
|
|
#include "gl/scene/gl_drawinfo.h"
|
|
|
|
#include "gl/shaders/gl_shader.h"
|
2016-07-27 19:50:30 +00:00
|
|
|
#include "gl/shaders/gl_bloomshader.h"
|
|
|
|
#include "gl/shaders/gl_blurshader.h"
|
2016-07-28 22:36:43 +00:00
|
|
|
#include "gl/shaders/gl_tonemapshader.h"
|
2016-09-01 15:14:51 +00:00
|
|
|
#include "gl/shaders/gl_colormapshader.h"
|
2016-08-02 15:32:21 +00:00
|
|
|
#include "gl/shaders/gl_lensshader.h"
|
2016-09-25 09:25:01 +00:00
|
|
|
#include "gl/shaders/gl_fxaashader.h"
|
2016-07-26 19:27:02 +00:00
|
|
|
#include "gl/shaders/gl_presentshader.h"
|
2016-10-02 16:24:37 +00:00
|
|
|
#include "gl/shaders/gl_present3dRowshader.h"
|
2016-09-11 17:42:41 +00:00
|
|
|
#include "gl/stereo3d/gl_stereo3d.h"
|
2013-06-23 07:49:34 +00:00
|
|
|
#include "gl/textures/gl_texture.h"
|
|
|
|
#include "gl/textures/gl_translate.h"
|
|
|
|
#include "gl/textures/gl_material.h"
|
2014-08-22 21:50:38 +00:00
|
|
|
#include "gl/textures/gl_samplers.h"
|
2013-06-23 07:49:34 +00:00
|
|
|
#include "gl/utility/gl_clock.h"
|
|
|
|
#include "gl/utility/gl_templates.h"
|
|
|
|
#include "gl/models/gl_models.h"
|
2014-08-01 18:59:39 +00:00
|
|
|
#include "gl/dynlights/gl_lightbuffer.h"
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-07-26 19:27:02 +00:00
|
|
|
EXTERN_CVAR(Int, screenblocks)
|
|
|
|
|
2016-08-12 05:28:29 +00:00
|
|
|
CVAR(Bool, gl_scale_viewport, true, 0);
|
|
|
|
|
2013-06-23 07:49:34 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// Renderer interface
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Initialize
|
|
|
|
//
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2013-08-18 13:41:52 +00:00
|
|
|
FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb)
|
|
|
|
{
|
|
|
|
framebuffer = fb;
|
2016-09-01 15:14:51 +00:00
|
|
|
mClipPortal = nullptr;
|
|
|
|
mCurrentPortal = nullptr;
|
2013-08-18 13:41:52 +00:00
|
|
|
mMirrorCount = 0;
|
|
|
|
mPlaneMirrorCount = 0;
|
|
|
|
mLightCount = 0;
|
2016-03-21 01:57:02 +00:00
|
|
|
mAngles = FRotator(0.f, 0.f, 0.f);
|
2013-08-18 13:41:52 +00:00
|
|
|
mViewVector = FVector2(0,0);
|
2016-09-01 15:14:51 +00:00
|
|
|
mVBO = nullptr;
|
|
|
|
mSkyVBO = nullptr;
|
2013-08-18 13:41:52 +00:00
|
|
|
gl_spriteindex = 0;
|
2016-09-01 15:14:51 +00:00
|
|
|
mShaderManager = nullptr;
|
|
|
|
gllight = glpart2 = glpart = mirrortexture = nullptr;
|
|
|
|
mLights = nullptr;
|
2016-08-08 10:13:09 +00:00
|
|
|
m2DDrawer = nullptr;
|
2016-08-25 17:58:50 +00:00
|
|
|
mTonemapPalette = nullptr;
|
2016-09-01 15:14:51 +00:00
|
|
|
mBuffers = nullptr;
|
|
|
|
mPresentShader = nullptr;
|
2016-10-02 16:24:37 +00:00
|
|
|
mPresent3dRowShader = nullptr;
|
2016-09-01 15:14:51 +00:00
|
|
|
mBloomExtractShader = nullptr;
|
|
|
|
mBloomCombineShader = nullptr;
|
2016-09-18 13:57:22 +00:00
|
|
|
mExposureExtractShader = nullptr;
|
|
|
|
mExposureAverageShader = nullptr;
|
|
|
|
mExposureCombineShader = nullptr;
|
2016-09-01 15:14:51 +00:00
|
|
|
mBlurShader = nullptr;
|
|
|
|
mTonemapShader = nullptr;
|
|
|
|
mTonemapPalette = nullptr;
|
|
|
|
mColormapShader = nullptr;
|
|
|
|
mLensShader = nullptr;
|
2016-09-25 09:25:01 +00:00
|
|
|
mFXAAShader = nullptr;
|
|
|
|
mFXAALumaShader = nullptr;
|
2013-08-18 13:41:52 +00:00
|
|
|
}
|
|
|
|
|
2014-10-24 09:43:25 +00:00
|
|
|
void gl_LoadModels();
|
2015-04-12 17:42:03 +00:00
|
|
|
void gl_FlushModels();
|
2014-10-24 09:43:25 +00:00
|
|
|
|
2016-08-08 12:24:48 +00:00
|
|
|
void FGLRenderer::Initialize(int width, int height)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-07-26 19:27:02 +00:00
|
|
|
mBuffers = new FGLRenderBuffers();
|
2016-07-27 19:50:30 +00:00
|
|
|
mBloomExtractShader = new FBloomExtractShader();
|
|
|
|
mBloomCombineShader = new FBloomCombineShader();
|
2016-09-18 13:57:22 +00:00
|
|
|
mExposureExtractShader = new FExposureExtractShader();
|
|
|
|
mExposureAverageShader = new FExposureAverageShader();
|
|
|
|
mExposureCombineShader = new FExposureCombineShader();
|
2016-07-27 19:50:30 +00:00
|
|
|
mBlurShader = new FBlurShader();
|
2016-07-28 22:36:43 +00:00
|
|
|
mTonemapShader = new FTonemapShader();
|
2016-09-01 15:14:51 +00:00
|
|
|
mColormapShader = new FColormapShader();
|
2016-08-23 07:18:18 +00:00
|
|
|
mTonemapPalette = nullptr;
|
2016-08-02 15:32:21 +00:00
|
|
|
mLensShader = new FLensShader();
|
2016-09-25 09:25:01 +00:00
|
|
|
mFXAAShader = new FFXAAShader;
|
|
|
|
mFXAALumaShader = new FFXAALumaShader;
|
2016-07-26 19:27:02 +00:00
|
|
|
mPresentShader = new FPresentShader();
|
2016-10-02 16:24:37 +00:00
|
|
|
mPresent3dRowShader = new FPresent3DRowShader();
|
2016-08-08 10:13:09 +00:00
|
|
|
m2DDrawer = new F2DDrawer;
|
2016-07-26 19:27:02 +00:00
|
|
|
|
2016-09-01 09:52:52 +00:00
|
|
|
// needed for the core profile, because someone decided it was a good idea to remove the default VAO.
|
|
|
|
if (!gl.legacyMode)
|
2016-04-26 14:26:34 +00:00
|
|
|
{
|
|
|
|
glGenVertexArrays(1, &mVAOID);
|
|
|
|
glBindVertexArray(mVAOID);
|
2016-08-17 21:18:47 +00:00
|
|
|
FGLDebug::LabelObject(GL_VERTEX_ARRAY, mVAOID, "FGLRenderer.mVAOID");
|
2016-04-26 14:26:34 +00:00
|
|
|
}
|
|
|
|
else mVAOID = 0;
|
|
|
|
|
2016-05-04 20:14:39 +00:00
|
|
|
gllight = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/gllight.png"), FTexture::TEX_MiscPatch);
|
2013-06-23 07:49:34 +00:00
|
|
|
glpart2 = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/glpart2.png"), FTexture::TEX_MiscPatch);
|
|
|
|
glpart = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/glpart.png"), FTexture::TEX_MiscPatch);
|
|
|
|
mirrortexture = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/mirror.png"), FTexture::TEX_MiscPatch);
|
|
|
|
|
2016-08-08 12:24:48 +00:00
|
|
|
mVBO = new FFlatVertexBuffer(width, height);
|
2014-06-13 23:24:28 +00:00
|
|
|
mSkyVBO = new FSkyVertexBuffer;
|
2016-09-01 09:52:52 +00:00
|
|
|
if (!gl.legacyMode) mLights = new FLightBuffer();
|
2016-04-26 11:50:05 +00:00
|
|
|
else mLights = NULL;
|
2014-05-20 22:36:04 +00:00
|
|
|
gl_RenderState.SetVertexBuffer(mVBO);
|
2013-06-23 07:49:34 +00:00
|
|
|
mFBID = 0;
|
2016-04-30 13:29:22 +00:00
|
|
|
mOldFBID = 0;
|
2016-04-26 14:26:34 +00:00
|
|
|
|
2013-06-23 07:49:34 +00:00
|
|
|
SetupLevel();
|
|
|
|
mShaderManager = new FShaderManager;
|
2014-08-22 21:50:38 +00:00
|
|
|
mSamplerManager = new FSamplerManager;
|
2014-10-24 09:43:25 +00:00
|
|
|
gl_LoadModels();
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
FGLRenderer::~FGLRenderer()
|
|
|
|
{
|
2015-04-12 17:42:03 +00:00
|
|
|
gl_FlushModels();
|
2013-06-23 07:49:34 +00:00
|
|
|
gl_DeleteAllAttachedLights();
|
|
|
|
FMaterial::FlushAll();
|
2016-08-08 10:13:09 +00:00
|
|
|
if (m2DDrawer != nullptr) delete m2DDrawer;
|
2013-06-23 07:49:34 +00:00
|
|
|
if (mShaderManager != NULL) delete mShaderManager;
|
2014-08-22 21:50:38 +00:00
|
|
|
if (mSamplerManager != NULL) delete mSamplerManager;
|
2013-06-23 07:49:34 +00:00
|
|
|
if (mVBO != NULL) delete mVBO;
|
2014-06-13 23:24:28 +00:00
|
|
|
if (mSkyVBO != NULL) delete mSkyVBO;
|
2014-08-01 18:59:39 +00:00
|
|
|
if (mLights != NULL) delete mLights;
|
2013-06-23 07:49:34 +00:00
|
|
|
if (glpart2) delete glpart2;
|
|
|
|
if (glpart) delete glpart;
|
|
|
|
if (mirrortexture) delete mirrortexture;
|
2013-09-03 16:29:39 +00:00
|
|
|
if (mFBID != 0) glDeleteFramebuffers(1, &mFBID);
|
2016-04-26 14:26:34 +00:00
|
|
|
if (mVAOID != 0)
|
|
|
|
{
|
|
|
|
glBindVertexArray(0);
|
|
|
|
glDeleteVertexArrays(1, &mVAOID);
|
|
|
|
}
|
2016-07-26 19:27:02 +00:00
|
|
|
if (mBuffers) delete mBuffers;
|
|
|
|
if (mPresentShader) delete mPresentShader;
|
2016-10-02 16:24:37 +00:00
|
|
|
if (mPresent3dRowShader) delete mPresent3dRowShader;
|
2016-07-27 19:50:30 +00:00
|
|
|
if (mBloomExtractShader) delete mBloomExtractShader;
|
|
|
|
if (mBloomCombineShader) delete mBloomCombineShader;
|
2016-09-18 13:57:22 +00:00
|
|
|
if (mExposureExtractShader) delete mExposureExtractShader;
|
|
|
|
if (mExposureAverageShader) delete mExposureAverageShader;
|
|
|
|
if (mExposureCombineShader) delete mExposureCombineShader;
|
2016-07-27 19:50:30 +00:00
|
|
|
if (mBlurShader) delete mBlurShader;
|
2016-07-28 22:36:43 +00:00
|
|
|
if (mTonemapShader) delete mTonemapShader;
|
2016-08-23 07:18:18 +00:00
|
|
|
if (mTonemapPalette) delete mTonemapPalette;
|
2016-09-01 15:14:51 +00:00
|
|
|
if (mColormapShader) delete mColormapShader;
|
2016-08-02 15:32:21 +00:00
|
|
|
if (mLensShader) delete mLensShader;
|
2016-09-25 09:25:01 +00:00
|
|
|
delete mFXAAShader;
|
|
|
|
delete mFXAALumaShader;
|
2016-07-26 19:27:02 +00:00
|
|
|
}
|
2016-04-26 14:26:34 +00:00
|
|
|
|
2016-07-26 19:27:02 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// Calculates the viewport values needed for 2D and 3D operations
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void FGLRenderer::SetOutputViewport(GL_IRECT *bounds)
|
|
|
|
{
|
|
|
|
if (bounds)
|
|
|
|
{
|
2016-08-12 05:28:29 +00:00
|
|
|
mSceneViewport = *bounds;
|
2016-07-31 11:23:49 +00:00
|
|
|
mScreenViewport = *bounds;
|
2016-08-12 05:28:29 +00:00
|
|
|
mOutputLetterbox = *bounds;
|
2016-07-26 19:27:02 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Special handling so the view with a visible status bar displays properly
|
2016-08-12 05:28:29 +00:00
|
|
|
int height, width;
|
2016-07-26 19:27:02 +00:00
|
|
|
if (screenblocks >= 10)
|
|
|
|
{
|
|
|
|
height = framebuffer->GetHeight();
|
|
|
|
width = framebuffer->GetWidth();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
height = (screenblocks*framebuffer->GetHeight() / 10) & ~7;
|
|
|
|
width = (screenblocks*framebuffer->GetWidth() / 10);
|
|
|
|
}
|
|
|
|
|
2016-08-12 05:28:29 +00:00
|
|
|
// Back buffer letterbox for the final output
|
|
|
|
int clientWidth = framebuffer->GetClientWidth();
|
|
|
|
int clientHeight = framebuffer->GetClientHeight();
|
2016-09-04 01:15:50 +00:00
|
|
|
if (clientWidth == 0 || clientHeight == 0)
|
|
|
|
{
|
|
|
|
// When window is minimized there may not be any client area.
|
|
|
|
// Pretend to the rest of the render code that we just have a very small window.
|
|
|
|
clientWidth = 160;
|
|
|
|
clientHeight = 120;
|
|
|
|
}
|
2016-08-12 05:28:29 +00:00
|
|
|
int screenWidth = framebuffer->GetWidth();
|
|
|
|
int screenHeight = framebuffer->GetHeight();
|
|
|
|
float scale = MIN(clientWidth / (float)screenWidth, clientHeight / (float)screenHeight);
|
|
|
|
mOutputLetterbox.width = (int)round(screenWidth * scale);
|
|
|
|
mOutputLetterbox.height = (int)round(screenHeight * scale);
|
|
|
|
mOutputLetterbox.left = (clientWidth - mOutputLetterbox.width) / 2;
|
|
|
|
mOutputLetterbox.top = (clientHeight - mOutputLetterbox.height) / 2;
|
2016-07-26 19:27:02 +00:00
|
|
|
|
2016-07-31 11:23:49 +00:00
|
|
|
// The entire renderable area, including the 2D HUD
|
|
|
|
mScreenViewport.left = 0;
|
|
|
|
mScreenViewport.top = 0;
|
2016-08-12 05:28:29 +00:00
|
|
|
mScreenViewport.width = screenWidth;
|
|
|
|
mScreenViewport.height = screenHeight;
|
|
|
|
|
|
|
|
// Viewport for the 3D scene
|
|
|
|
mSceneViewport.left = viewwindowx;
|
|
|
|
mSceneViewport.top = screenHeight - (height + viewwindowy - ((height - viewheight) / 2));
|
|
|
|
mSceneViewport.width = viewwidth;
|
|
|
|
mSceneViewport.height = height;
|
|
|
|
|
|
|
|
// Scale viewports to fit letterbox
|
|
|
|
if (gl_scale_viewport || !FGLRenderBuffers::IsEnabled())
|
|
|
|
{
|
|
|
|
mScreenViewport.width = mOutputLetterbox.width;
|
|
|
|
mScreenViewport.height = mOutputLetterbox.height;
|
|
|
|
mSceneViewport.left = (int)round(mSceneViewport.left * scale);
|
|
|
|
mSceneViewport.top = (int)round(mSceneViewport.top * scale);
|
|
|
|
mSceneViewport.width = (int)round(mSceneViewport.width * scale);
|
|
|
|
mSceneViewport.height = (int)round(mSceneViewport.height * scale);
|
|
|
|
|
|
|
|
// Without render buffers we have to render directly to the letterbox
|
|
|
|
if (!FGLRenderBuffers::IsEnabled())
|
|
|
|
{
|
|
|
|
mScreenViewport.left += mOutputLetterbox.left;
|
|
|
|
mScreenViewport.top += mOutputLetterbox.top;
|
|
|
|
mSceneViewport.left += mOutputLetterbox.left;
|
|
|
|
mSceneViewport.top += mOutputLetterbox.top;
|
|
|
|
}
|
|
|
|
}
|
2016-09-11 17:42:41 +00:00
|
|
|
|
|
|
|
s3d::Stereo3DMode::getCurrentMode().AdjustViewports();
|
2016-08-12 05:28:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// Calculates the OpenGL window coordinates for a zdoom screen position
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
int FGLRenderer::ScreenToWindowX(int x)
|
|
|
|
{
|
|
|
|
return mScreenViewport.left + (int)round(x * mScreenViewport.width / (float)framebuffer->GetWidth());
|
|
|
|
}
|
|
|
|
|
|
|
|
int FGLRenderer::ScreenToWindowY(int y)
|
|
|
|
{
|
|
|
|
return mScreenViewport.top + mScreenViewport.height - (int)round(y * mScreenViewport.height / (float)framebuffer->GetHeight());
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void FGLRenderer::SetupLevel()
|
|
|
|
{
|
|
|
|
mVBO->CreateVBO();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FGLRenderer::Begin2D()
|
|
|
|
{
|
2016-08-28 16:07:44 +00:00
|
|
|
if (mBuffers->Setup(mScreenViewport.width, mScreenViewport.height, mSceneViewport.width, mSceneViewport.height))
|
2016-07-26 19:27:02 +00:00
|
|
|
{
|
2016-07-28 22:36:43 +00:00
|
|
|
if (mDrawingScene2D)
|
|
|
|
mBuffers->BindSceneFB();
|
|
|
|
else
|
2016-08-04 15:16:49 +00:00
|
|
|
mBuffers->BindCurrentFB();
|
2016-07-26 19:27:02 +00:00
|
|
|
}
|
2016-07-31 11:23:49 +00:00
|
|
|
glViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height);
|
2016-08-12 05:28:29 +00:00
|
|
|
glScissor(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height);
|
2016-07-26 19:27:02 +00:00
|
|
|
|
2013-06-23 07:49:34 +00:00
|
|
|
gl_RenderState.EnableFog(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void FGLRenderer::ProcessLowerMiniseg(seg_t *seg, sector_t * frontsector, sector_t * backsector)
|
|
|
|
{
|
|
|
|
GLWall wall;
|
|
|
|
wall.ProcessLowerMiniseg(seg, frontsector, backsector);
|
|
|
|
rendered_lines++;
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2016-04-18 21:52:15 +00:00
|
|
|
void FGLRenderer::ProcessSprite(AActor *thing, sector_t *sector, bool thruportal)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
|
|
|
GLSprite glsprite;
|
2016-04-18 21:52:15 +00:00
|
|
|
glsprite.Process(thing, sector, thruportal);
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void FGLRenderer::ProcessParticle(particle_t *part, sector_t *sector)
|
|
|
|
{
|
|
|
|
GLSprite glsprite;
|
|
|
|
glsprite.ProcessParticle(part, sector);//, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void FGLRenderer::ProcessSector(sector_t *fakesector)
|
|
|
|
{
|
|
|
|
GLFlat glflat;
|
|
|
|
glflat.ProcessSector(fakesector);
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void FGLRenderer::FlushTextures()
|
|
|
|
{
|
|
|
|
FMaterial::FlushAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
bool FGLRenderer::StartOffscreen()
|
|
|
|
{
|
2016-08-17 21:18:47 +00:00
|
|
|
bool firstBind = (mFBID == 0);
|
|
|
|
if (mFBID == 0)
|
|
|
|
glGenFramebuffers(1, &mFBID);
|
2016-04-30 15:09:57 +00:00
|
|
|
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &mOldFBID);
|
2014-06-21 13:50:32 +00:00
|
|
|
glBindFramebuffer(GL_FRAMEBUFFER, mFBID);
|
2016-08-17 21:18:47 +00:00
|
|
|
if (firstBind)
|
|
|
|
FGLDebug::LabelObject(GL_FRAMEBUFFER, mFBID, "OffscreenFB");
|
2014-06-21 13:50:32 +00:00
|
|
|
return true;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void FGLRenderer::EndOffscreen()
|
|
|
|
{
|
2016-04-30 13:29:22 +00:00
|
|
|
glBindFramebuffer(GL_FRAMEBUFFER, mOldFBID);
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
unsigned char *FGLRenderer::GetTextureBuffer(FTexture *tex, int &w, int &h)
|
|
|
|
{
|
2014-08-22 21:50:38 +00:00
|
|
|
FMaterial * gltex = FMaterial::ValidateTexture(tex, false);
|
2013-06-23 07:49:34 +00:00
|
|
|
if (gltex)
|
|
|
|
{
|
2014-05-11 17:44:19 +00:00
|
|
|
return gltex->CreateTexBuffer(0, w, h);
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|