mirror of
https://github.com/ZDoom/gzdoom-last-svn.git
synced 2025-06-04 19:20:53 +00:00
- getting closer...
git-svn-id: http://mancubus.net/svn/hosted/gzdoom/trunk@487 b0f79afe-0144-0410-b225-9a4edf0717df
This commit is contained in:
parent
8d782b2986
commit
c8d1b4ce47
18 changed files with 295 additions and 415 deletions
|
@ -6488,25 +6488,13 @@
|
||||||
<Filter
|
<Filter
|
||||||
Name="GL Renderer"
|
Name="GL Renderer"
|
||||||
>
|
>
|
||||||
<File
|
|
||||||
RelativePath=".\src\gl\gl_framebuffer.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\gl\gl_light.cpp"
|
RelativePath=".\src\gl\gl_light.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\src\gl\gl_menu.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<Filter
|
<Filter
|
||||||
Name="GL Header"
|
Name="GL Header"
|
||||||
>
|
>
|
||||||
<File
|
|
||||||
RelativePath=".\src\gl\gl_framebuffer.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\gl\gl_functions.h"
|
RelativePath=".\src\gl\gl_functions.h"
|
||||||
>
|
>
|
||||||
|
@ -6529,14 +6517,26 @@
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="API"
|
Name="System"
|
||||||
>
|
>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\gl\r_render\r_opengl.cpp"
|
RelativePath=".\src\gl\system\gl_framebuffer.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\gl\r_render\r_render.h"
|
RelativePath=".\src\gl\system\gl_framebuffer.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\gl\system\gl_interface.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\gl\system\gl_interface.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\gl\system\gl_menu.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
@ -6613,10 +6613,6 @@
|
||||||
RelativePath=".\src\gl\common\glc_light.cpp"
|
RelativePath=".\src\gl\common\glc_light.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\src\gl\common\glc_renderer.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\gl\common\glc_wipe.cpp"
|
RelativePath=".\src\gl\common\glc_wipe.cpp"
|
||||||
>
|
>
|
||||||
|
|
|
@ -74,6 +74,25 @@ void gl_CalculateCPUSpeed ()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ResetProfilingData()
|
||||||
|
{
|
||||||
|
All.Reset();
|
||||||
|
All.Clock();
|
||||||
|
PortalAll.Reset();
|
||||||
|
RenderAll.Reset();
|
||||||
|
ProcessAll.Reset();
|
||||||
|
RenderWall.Reset();
|
||||||
|
SetupWall.Reset();
|
||||||
|
ClipWall.Reset();
|
||||||
|
RenderFlat.Reset();
|
||||||
|
SetupFlat.Reset();
|
||||||
|
RenderSprite.Reset();
|
||||||
|
SetupSprite.Reset();
|
||||||
|
|
||||||
|
flatvertices=flatprimitives=vertexcount=0;
|
||||||
|
render_texsplit=render_vertexsplit=rendered_lines=rendered_flats=rendered_sprites=rendered_decals = 0;
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Rendering statistics
|
// Rendering statistics
|
||||||
|
@ -111,4 +130,20 @@ ADD_STAT(lightstats)
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern int DirtyCount;
|
||||||
|
|
||||||
|
ADD_STAT(dirty)
|
||||||
|
{
|
||||||
|
static FString buff;
|
||||||
|
static int lasttime=0;
|
||||||
|
int t=I_MSTime();
|
||||||
|
if (t-lasttime>1000)
|
||||||
|
{
|
||||||
|
buff.Format("Dirty=%2.8f (%d)\n", Dirty.TimeMS(), DirtyCount);
|
||||||
|
lasttime=t;
|
||||||
|
}
|
||||||
|
Dirty.Reset();
|
||||||
|
DirtyCount = 0;
|
||||||
|
return buff;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,5 +106,7 @@ extern int rendered_lines,rendered_flats,rendered_sprites,rendered_decals,render
|
||||||
|
|
||||||
extern int vertexcount, flatvertices, flatprimitives;
|
extern int vertexcount, flatvertices, flatprimitives;
|
||||||
|
|
||||||
|
void ResetProfilingData();
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -40,7 +40,7 @@
|
||||||
|
|
||||||
|
|
||||||
#include "gl/gl_include.h"
|
#include "gl/gl_include.h"
|
||||||
#include "gl/common/glc_data.h"
|
#include "gl/data/gl_data.h"
|
||||||
#include "c_dispatch.h"
|
#include "c_dispatch.h"
|
||||||
#include "p_local.h"
|
#include "p_local.h"
|
||||||
|
|
||||||
|
|
|
@ -1,308 +0,0 @@
|
||||||
/*
|
|
||||||
** glc_renderer.cpp
|
|
||||||
** Common renderer routines
|
|
||||||
**
|
|
||||||
**---------------------------------------------------------------------------
|
|
||||||
** Copyright 2008 Christoph Oelckers
|
|
||||||
** All rights reserved.
|
|
||||||
**
|
|
||||||
** Redistribution and use in source and binary forms, with or without
|
|
||||||
** modification, are permitted provided that the following conditions
|
|
||||||
** are met:
|
|
||||||
**
|
|
||||||
** 1. Redistributions of source code must retain the above copyright
|
|
||||||
** notice, this list of conditions and the following disclaimer.
|
|
||||||
** 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
** notice, this list of conditions and the following disclaimer in the
|
|
||||||
** documentation and/or other materials provided with the distribution.
|
|
||||||
** 3. The name of the author may not be used to endorse or promote products
|
|
||||||
** derived from this software without specific prior written permission.
|
|
||||||
** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be
|
|
||||||
** covered by the terms of the GNU Lesser General Public License as published
|
|
||||||
** by the Free Software Foundation; either version 2.1 of the License, or (at
|
|
||||||
** your option) any later version.
|
|
||||||
** 5. Full disclosure of the entire project's source code, except for third
|
|
||||||
** party libraries is mandatory. (NOTE: This clause is non-negotiable!)
|
|
||||||
**
|
|
||||||
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
||||||
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
||||||
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
**---------------------------------------------------------------------------
|
|
||||||
**
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "gl/gl_include.h"
|
|
||||||
#include "gl/gl_framebuffer.h"
|
|
||||||
#include "gl/gl_functions.h"
|
|
||||||
#include "r_local.h"
|
|
||||||
#include "i_system.h"
|
|
||||||
#include "r_main.h"
|
|
||||||
#include "g_level.h"
|
|
||||||
#include "templates.h"
|
|
||||||
#include "r_interpolate.h"
|
|
||||||
#include "gl/common/glc_renderer.h"
|
|
||||||
#include "gl/common/glc_clock.h"
|
|
||||||
#include "gl/common/glc_dynlight.h"
|
|
||||||
#include "gl/common/glc_convert.h"
|
|
||||||
#include "gl/old_renderer/gl1_shader.h"
|
|
||||||
|
|
||||||
#include "gl/data/gl_data.h"
|
|
||||||
#include "gl/data/gl_vertexbuffer.h"
|
|
||||||
#include "gl/scene/gl_clipper.h"
|
|
||||||
#include "gl/scene/gl_drawinfo.h"
|
|
||||||
#include "gl/textures/gl_material.h"
|
|
||||||
|
|
||||||
CVAR(Int,gl_nearclip,5,CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
|
||||||
|
|
||||||
EXTERN_CVAR (Int, screenblocks)
|
|
||||||
EXTERN_CVAR (Bool, cl_capfps)
|
|
||||||
EXTERN_CVAR (Bool, r_deathcamera)
|
|
||||||
|
|
||||||
void R_SetupFrame (AActor * camera);
|
|
||||||
extern int viewpitch;
|
|
||||||
|
|
||||||
area_t in_area;
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Initialize
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void FGLRenderer::Initialize()
|
|
||||||
{
|
|
||||||
mVBO = new FVertexBuffer;
|
|
||||||
GlobalDrawInfo = new FDrawInfo;
|
|
||||||
gl_InitShaders();
|
|
||||||
gl_InitFog();
|
|
||||||
}
|
|
||||||
|
|
||||||
FGLRenderer::~FGLRenderer()
|
|
||||||
{
|
|
||||||
FMaterial::FlushAll();
|
|
||||||
gl_ClearShaders();
|
|
||||||
if (GlobalDrawInfo != NULL) delete GlobalDrawInfo;
|
|
||||||
if (mVBO != NULL) delete mVBO;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// R_FrustumAngle
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
angle_t FGLRenderer::FrustumAngle()
|
|
||||||
{
|
|
||||||
float tilt= fabs(mAngles.Pitch);
|
|
||||||
|
|
||||||
// If the pitch is larger than this you can look all around at a FOV of 90°
|
|
||||||
if (tilt>46.0f) return 0xffffffff;
|
|
||||||
|
|
||||||
// ok, this is a gross hack that barely works...
|
|
||||||
// but at least it doesn't overestimate too much...
|
|
||||||
double floatangle=2.0+(45.0+((tilt/1.9)))*mCurrentFoV*48.0/BaseRatioSizes[WidescreenRatio][3]/90.0;
|
|
||||||
angle_t a1 = ANGLE_1*toint(floatangle);
|
|
||||||
if (a1>=ANGLE_180) return 0xffffffff;
|
|
||||||
return a1;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Sets the area the camera is in
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void FGLRenderer::SetViewArea()
|
|
||||||
{
|
|
||||||
// The render_sector is better suited to represent the current position in GL
|
|
||||||
viewsector = R_PointInSubsector(viewx, viewy)->render_sector;
|
|
||||||
|
|
||||||
// keep the view within the render sector's floor and ceiling
|
|
||||||
fixed_t theZ = viewsector->ceilingplane.ZatPoint (viewx, viewy) - 4*FRACUNIT;
|
|
||||||
if (viewz > theZ)
|
|
||||||
{
|
|
||||||
viewz = theZ;
|
|
||||||
}
|
|
||||||
|
|
||||||
theZ = viewsector->floorplane.ZatPoint (viewx, viewy) + 4*FRACUNIT;
|
|
||||||
if (viewz < theZ)
|
|
||||||
{
|
|
||||||
viewz = theZ;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the heightsec state from the render sector, not the current one!
|
|
||||||
if (viewsector->heightsec && !(viewsector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC))
|
|
||||||
{
|
|
||||||
in_area = viewz<=viewsector->heightsec->floorplane.ZatPoint(viewx,viewy) ? area_below :
|
|
||||||
(viewz>viewsector->heightsec->ceilingplane.ZatPoint(viewx,viewy) &&
|
|
||||||
!(viewsector->heightsec->MoreFlags&SECF_FAKEFLOORONLY)) ? area_above:area_normal;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
in_area=area_default; // depends on exposed lower sectors
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Renders one viewpoint in a scene
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, float fov, float ratio, float fovratio, bool mainview)
|
|
||||||
{
|
|
||||||
TThinkerIterator<ADynamicLight> it(STAT_DLIGHT);
|
|
||||||
|
|
||||||
// Check if there's some lights. If not some code can be skipped.
|
|
||||||
mLightCount = (it.Next()!=NULL);
|
|
||||||
|
|
||||||
sector_t * retval;
|
|
||||||
R_SetupFrame (camera);
|
|
||||||
SetViewArea();
|
|
||||||
mAngles.Pitch = clamp<float>((float)((double)(int)(viewpitch))/ANGLE_1, -90, 90);
|
|
||||||
|
|
||||||
// Scroll the sky
|
|
||||||
mSky1Pos = (float)fmod(gl_frameMS * level.skyspeed1, 1024.f) * 90.f/256.f;
|
|
||||||
mSky2Pos = (float)fmod(gl_frameMS * level.skyspeed2, 1024.f) * 90.f/256.f;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (camera->player && camera->player-players==consoleplayer &&
|
|
||||||
((camera->player->cheats & CF_CHASECAM) || (r_deathcamera && camera->health <= 0)) && camera==camera->player->mo)
|
|
||||||
{
|
|
||||||
mViewActor=NULL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mViewActor=camera;
|
|
||||||
}
|
|
||||||
|
|
||||||
retval = viewsector;
|
|
||||||
|
|
||||||
SetViewport(bounds);
|
|
||||||
mCurrentFoV = fov;
|
|
||||||
SetProjection(fov, ratio, fovratio); // switch to perspective mode and set up clipper
|
|
||||||
SetCameraPos(viewx, viewy, viewz, viewangle);
|
|
||||||
SetViewMatrix(false, false);
|
|
||||||
|
|
||||||
clipper.Clear();
|
|
||||||
angle_t a1 = GLRenderer->FrustumAngle();
|
|
||||||
clipper.SafeAddClipRange(viewangle+a1, viewangle-a1);
|
|
||||||
|
|
||||||
ProcessScene();
|
|
||||||
|
|
||||||
gl_frameCount++; // This counter must be increased right before the interpolations are restored.
|
|
||||||
interpolator.RestoreInterpolations ();
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//===========================================================================
|
|
||||||
|
|
||||||
void FGLRenderer::SetupLevel()
|
|
||||||
{
|
|
||||||
mAngles.Pitch = 0.0f;
|
|
||||||
mVBO->CreateVBO();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// renders the view
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void FGLRenderer::RenderView (player_t* player)
|
|
||||||
{
|
|
||||||
AActor *&LastCamera = static_cast<OpenGLFrameBuffer*>(screen)->LastCamera;
|
|
||||||
|
|
||||||
if (player->camera != LastCamera)
|
|
||||||
{
|
|
||||||
// If the camera changed don't interpolate
|
|
||||||
// Otherwise there will be some not so nice effects.
|
|
||||||
R_ResetViewInterpolation();
|
|
||||||
LastCamera=player->camera;
|
|
||||||
}
|
|
||||||
|
|
||||||
mVBO->BindVBO();
|
|
||||||
|
|
||||||
// reset statistics counters
|
|
||||||
All.Reset();
|
|
||||||
All.Clock();
|
|
||||||
PortalAll.Reset();
|
|
||||||
RenderAll.Reset();
|
|
||||||
ProcessAll.Reset();
|
|
||||||
RenderWall.Reset();
|
|
||||||
SetupWall.Reset();
|
|
||||||
ClipWall.Reset();
|
|
||||||
RenderFlat.Reset();
|
|
||||||
SetupFlat.Reset();
|
|
||||||
RenderSprite.Reset();
|
|
||||||
SetupSprite.Reset();
|
|
||||||
|
|
||||||
flatvertices=flatprimitives=vertexcount=0;
|
|
||||||
render_texsplit=render_vertexsplit=rendered_lines=rendered_flats=rendered_sprites=rendered_decals = 0;
|
|
||||||
|
|
||||||
// Get this before everything else
|
|
||||||
if (cl_capfps || r_NoInterpolate) r_TicFrac = FRACUNIT;
|
|
||||||
else r_TicFrac = I_GetTimeFrac (&r_FrameTime);
|
|
||||||
gl_frameMS = I_MSTime();
|
|
||||||
|
|
||||||
R_FindParticleSubsectors ();
|
|
||||||
|
|
||||||
// prepare all camera textures that have been used in the last frame
|
|
||||||
FCanvasTextureInfo::UpdateAll();
|
|
||||||
|
|
||||||
|
|
||||||
// I stopped using BaseRatioSizes here because the information there wasn't well presented.
|
|
||||||
#define RMUL (1.6f/1.333333f)
|
|
||||||
static float ratios[]={RMUL*1.333333f, RMUL*1.777777f, RMUL*1.6f, RMUL*1.333333f, RMUL*1.2f};
|
|
||||||
|
|
||||||
// now render the main view
|
|
||||||
float fovratio;
|
|
||||||
float ratio = ratios[WidescreenRatio];
|
|
||||||
if (!(WidescreenRatio&4))
|
|
||||||
{
|
|
||||||
fovratio = 1.6f;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fovratio = ratio;
|
|
||||||
}
|
|
||||||
|
|
||||||
SetFixedColormap (player);
|
|
||||||
|
|
||||||
sector_t * viewsector = RenderViewpoint(player->camera, NULL, FieldOfView * 360.0f / FINEANGLES, ratio, fovratio, true);
|
|
||||||
EndDrawScene(viewsector);
|
|
||||||
|
|
||||||
All.Unclock();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
extern int DirtyCount;
|
|
||||||
|
|
||||||
ADD_STAT(dirty)
|
|
||||||
{
|
|
||||||
static FString buff;
|
|
||||||
static int lasttime=0;
|
|
||||||
int t=I_MSTime();
|
|
||||||
if (t-lasttime>1000)
|
|
||||||
{
|
|
||||||
buff.Format("Dirty=%2.8f (%d)\n", Dirty.TimeMS(), DirtyCount);
|
|
||||||
lasttime=t;
|
|
||||||
}
|
|
||||||
Dirty.Reset();
|
|
||||||
DirtyCount = 0;
|
|
||||||
return buff;
|
|
||||||
}
|
|
||||||
|
|
|
@ -48,10 +48,10 @@
|
||||||
#include "v_palette.h"
|
#include "v_palette.h"
|
||||||
#include "templates.h"
|
#include "templates.h"
|
||||||
#include "vectors.h"
|
#include "vectors.h"
|
||||||
#include "gl/gl_framebuffer.h"
|
|
||||||
#include "gl/common/glc_renderer.h"
|
#include "gl/common/glc_renderer.h"
|
||||||
#include "gl/common/glc_templates.h"
|
#include "gl/common/glc_templates.h"
|
||||||
|
|
||||||
|
#include "gl/system/gl_framebuffer.h"
|
||||||
#include "gl/textures/gl_translate.h"
|
#include "gl/textures/gl_translate.h"
|
||||||
#include "gl/textures/gl_material.h"
|
#include "gl/textures/gl_material.h"
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ inline T max( T a, T b) { return (((a)>(b)) ? (a) : (b)); }
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#endif
|
#endif
|
||||||
#include "r_render/r_render.h"
|
#include "gl/system/gl_interface.h"
|
||||||
|
|
||||||
extern RenderContext gl;
|
extern RenderContext gl;
|
||||||
|
|
||||||
|
|
|
@ -53,11 +53,12 @@
|
||||||
#include "gl/old_renderer/gl1_renderer.h"
|
#include "gl/old_renderer/gl1_renderer.h"
|
||||||
#include "gl/gl_functions.h"
|
#include "gl/gl_functions.h"
|
||||||
#include "gl/old_renderer/gl1_shader.h"
|
#include "gl/old_renderer/gl1_shader.h"
|
||||||
#include "gl/gl_framebuffer.h"
|
|
||||||
#include "vectors.h"
|
#include "vectors.h"
|
||||||
#include "gl/old_renderer/gl1_renderer.h"
|
#include "gl/old_renderer/gl1_renderer.h"
|
||||||
|
|
||||||
|
#include "gl/system/gl_framebuffer.h"
|
||||||
#include "gl/data/gl_data.h"
|
#include "gl/data/gl_data.h"
|
||||||
|
#include "gl/data/gl_vertexbuffer.h"
|
||||||
#include "gl/scene/gl_drawinfo.h"
|
#include "gl/scene/gl_drawinfo.h"
|
||||||
#include "gl/textures/gl_texture.h"
|
#include "gl/textures/gl_texture.h"
|
||||||
#include "gl/textures/gl_translate.h"
|
#include "gl/textures/gl_translate.h"
|
||||||
|
@ -72,6 +73,41 @@
|
||||||
|
|
||||||
EXTERN_CVAR(Bool, gl_render_segs)
|
EXTERN_CVAR(Bool, gl_render_segs)
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Initialize
|
||||||
|
//
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void FGLRenderer::Initialize()
|
||||||
|
{
|
||||||
|
mVBO = new FVertexBuffer;
|
||||||
|
GlobalDrawInfo = new FDrawInfo;
|
||||||
|
gl_InitShaders();
|
||||||
|
gl_InitFog();
|
||||||
|
}
|
||||||
|
|
||||||
|
FGLRenderer::~FGLRenderer()
|
||||||
|
{
|
||||||
|
FMaterial::FlushAll();
|
||||||
|
gl_ClearShaders();
|
||||||
|
if (GlobalDrawInfo != NULL) delete GlobalDrawInfo;
|
||||||
|
if (mVBO != NULL) delete mVBO;
|
||||||
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
|
void FGLRenderer::SetupLevel()
|
||||||
|
{
|
||||||
|
mAngles.Pitch = 0.0f;
|
||||||
|
mVBO->CreateVBO();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void FGLRenderer::SetPaused()
|
void FGLRenderer::SetPaused()
|
||||||
{
|
{
|
||||||
gl_DisableShader();
|
gl_DisableShader();
|
||||||
|
|
|
@ -44,7 +44,6 @@
|
||||||
#include "vectors.h"
|
#include "vectors.h"
|
||||||
#include "doomstat.h"
|
#include "doomstat.h"
|
||||||
#include "gl/gl_struct.h"
|
#include "gl/gl_struct.h"
|
||||||
#include "gl/gl_framebuffer.h"
|
|
||||||
#include "gl/common/glc_clock.h"
|
#include "gl/common/glc_clock.h"
|
||||||
#include "gl/old_renderer/gl1_renderer.h"
|
#include "gl/old_renderer/gl1_renderer.h"
|
||||||
#include "gl/common/glc_glow.h"
|
#include "gl/common/glc_glow.h"
|
||||||
|
@ -55,6 +54,7 @@
|
||||||
#include "gl/old_renderer/gl1_shader.h"
|
#include "gl/old_renderer/gl1_shader.h"
|
||||||
#include "gl/common/glc_convert.h"
|
#include "gl/common/glc_convert.h"
|
||||||
|
|
||||||
|
#include "gl/system/gl_framebuffer.h"
|
||||||
#include "gl/data/gl_data.h"
|
#include "gl/data/gl_data.h"
|
||||||
#include "gl/scene/gl_clipper.h"
|
#include "gl/scene/gl_clipper.h"
|
||||||
#include "gl/scene/gl_drawinfo.h"
|
#include "gl/scene/gl_drawinfo.h"
|
||||||
|
|
|
@ -49,6 +49,7 @@
|
||||||
#include "g_level.h"
|
#include "g_level.h"
|
||||||
#include "r_interpolate.h"
|
#include "r_interpolate.h"
|
||||||
#include "r_main.h"
|
#include "r_main.h"
|
||||||
|
#include "r_things.h"
|
||||||
#include "sbar.h"
|
#include "sbar.h"
|
||||||
#include "gl/gl_struct.h"
|
#include "gl/gl_struct.h"
|
||||||
#include "gl/old_renderer/gl1_renderer.h"
|
#include "gl/old_renderer/gl1_renderer.h"
|
||||||
|
@ -56,9 +57,9 @@
|
||||||
#include "gl/common/glc_templates.h"
|
#include "gl/common/glc_templates.h"
|
||||||
#include "gl/gl_functions.h"
|
#include "gl/gl_functions.h"
|
||||||
#include "gl/old_renderer/gl1_shader.h"
|
#include "gl/old_renderer/gl1_shader.h"
|
||||||
#include "gl/gl_framebuffer.h"
|
|
||||||
#include "gl/common/glc_convert.h"
|
#include "gl/common/glc_convert.h"
|
||||||
|
|
||||||
|
#include "gl/system/gl_framebuffer.h"
|
||||||
#include "gl/data/gl_data.h"
|
#include "gl/data/gl_data.h"
|
||||||
#include "gl/data/gl_vertexbuffer.h"
|
#include "gl/data/gl_vertexbuffer.h"
|
||||||
#include "gl/models/gl_models.h"
|
#include "gl/models/gl_models.h"
|
||||||
|
@ -76,10 +77,79 @@ CVAR(Bool, gl_texture, true, 0)
|
||||||
CVAR(Bool, gl_no_skyclear, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
CVAR(Bool, gl_no_skyclear, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||||
CVAR(Float, gl_mask_threshold, 0.5f,CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
CVAR(Float, gl_mask_threshold, 0.5f,CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||||
CVAR(Bool, gl_forcemultipass, false, 0)
|
CVAR(Bool, gl_forcemultipass, false, 0)
|
||||||
|
CVAR(Int,gl_nearclip,5,CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||||
|
|
||||||
|
EXTERN_CVAR (Int, screenblocks)
|
||||||
|
EXTERN_CVAR (Bool, cl_capfps)
|
||||||
|
EXTERN_CVAR (Bool, r_deathcamera)
|
||||||
|
|
||||||
|
|
||||||
extern int viewpitch;
|
extern int viewpitch;
|
||||||
|
|
||||||
DWORD gl_fixedcolormap;
|
DWORD gl_fixedcolormap;
|
||||||
|
area_t in_area;
|
||||||
|
|
||||||
|
|
||||||
|
void R_SetupFrame (AActor * camera);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// R_FrustumAngle
|
||||||
|
//
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
angle_t FGLRenderer::FrustumAngle()
|
||||||
|
{
|
||||||
|
float tilt= fabs(mAngles.Pitch);
|
||||||
|
|
||||||
|
// If the pitch is larger than this you can look all around at a FOV of 90°
|
||||||
|
if (tilt>46.0f) return 0xffffffff;
|
||||||
|
|
||||||
|
// ok, this is a gross hack that barely works...
|
||||||
|
// but at least it doesn't overestimate too much...
|
||||||
|
double floatangle=2.0+(45.0+((tilt/1.9)))*mCurrentFoV*48.0/BaseRatioSizes[WidescreenRatio][3]/90.0;
|
||||||
|
angle_t a1 = ANGLE_1*toint(floatangle);
|
||||||
|
if (a1>=ANGLE_180) return 0xffffffff;
|
||||||
|
return a1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Sets the area the camera is in
|
||||||
|
//
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void FGLRenderer::SetViewArea()
|
||||||
|
{
|
||||||
|
// The render_sector is better suited to represent the current position in GL
|
||||||
|
viewsector = R_PointInSubsector(viewx, viewy)->render_sector;
|
||||||
|
|
||||||
|
// keep the view within the render sector's floor and ceiling
|
||||||
|
fixed_t theZ = viewsector->ceilingplane.ZatPoint (viewx, viewy) - 4*FRACUNIT;
|
||||||
|
if (viewz > theZ)
|
||||||
|
{
|
||||||
|
viewz = theZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
theZ = viewsector->floorplane.ZatPoint (viewx, viewy) + 4*FRACUNIT;
|
||||||
|
if (viewz < theZ)
|
||||||
|
{
|
||||||
|
viewz = theZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the heightsec state from the render sector, not the current one!
|
||||||
|
if (viewsector->heightsec && !(viewsector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC))
|
||||||
|
{
|
||||||
|
in_area = viewz<=viewsector->heightsec->floorplane.ZatPoint(viewx,viewy) ? area_below :
|
||||||
|
(viewz>viewsector->heightsec->ceilingplane.ZatPoint(viewx,viewy) &&
|
||||||
|
!(viewsector->heightsec->MoreFlags&SECF_FAKEFLOORONLY)) ? area_above:area_normal;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
in_area=area_default; // depends on exposed lower sectors
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
|
@ -770,6 +840,118 @@ void FGLRenderer::SetFixedColormap (player_t *player)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Renders one viewpoint in a scene
|
||||||
|
//
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, float fov, float ratio, float fovratio, bool mainview)
|
||||||
|
{
|
||||||
|
TThinkerIterator<ADynamicLight> it(STAT_DLIGHT);
|
||||||
|
|
||||||
|
// Check if there's some lights. If not some code can be skipped.
|
||||||
|
mLightCount = (it.Next()!=NULL);
|
||||||
|
|
||||||
|
sector_t * retval;
|
||||||
|
R_SetupFrame (camera);
|
||||||
|
SetViewArea();
|
||||||
|
mAngles.Pitch = clamp<float>((float)((double)(int)(viewpitch))/ANGLE_1, -90, 90);
|
||||||
|
|
||||||
|
// Scroll the sky
|
||||||
|
mSky1Pos = (float)fmod(gl_frameMS * level.skyspeed1, 1024.f) * 90.f/256.f;
|
||||||
|
mSky2Pos = (float)fmod(gl_frameMS * level.skyspeed2, 1024.f) * 90.f/256.f;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (camera->player && camera->player-players==consoleplayer &&
|
||||||
|
((camera->player->cheats & CF_CHASECAM) || (r_deathcamera && camera->health <= 0)) && camera==camera->player->mo)
|
||||||
|
{
|
||||||
|
mViewActor=NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mViewActor=camera;
|
||||||
|
}
|
||||||
|
|
||||||
|
retval = viewsector;
|
||||||
|
|
||||||
|
SetViewport(bounds);
|
||||||
|
mCurrentFoV = fov;
|
||||||
|
SetProjection(fov, ratio, fovratio); // switch to perspective mode and set up clipper
|
||||||
|
SetCameraPos(viewx, viewy, viewz, viewangle);
|
||||||
|
SetViewMatrix(false, false);
|
||||||
|
|
||||||
|
clipper.Clear();
|
||||||
|
angle_t a1 = GLRenderer->FrustumAngle();
|
||||||
|
clipper.SafeAddClipRange(viewangle+a1, viewangle-a1);
|
||||||
|
|
||||||
|
ProcessScene();
|
||||||
|
|
||||||
|
gl_frameCount++; // This counter must be increased right before the interpolations are restored.
|
||||||
|
interpolator.RestoreInterpolations ();
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///-----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// renders the view
|
||||||
|
//
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void FGLRenderer::RenderView (player_t* player)
|
||||||
|
{
|
||||||
|
AActor *&LastCamera = static_cast<OpenGLFrameBuffer*>(screen)->LastCamera;
|
||||||
|
|
||||||
|
if (player->camera != LastCamera)
|
||||||
|
{
|
||||||
|
// If the camera changed don't interpolate
|
||||||
|
// Otherwise there will be some not so nice effects.
|
||||||
|
R_ResetViewInterpolation();
|
||||||
|
LastCamera=player->camera;
|
||||||
|
}
|
||||||
|
|
||||||
|
mVBO->BindVBO();
|
||||||
|
|
||||||
|
// reset statistics counters
|
||||||
|
ResetProfilingData();
|
||||||
|
|
||||||
|
// Get this before everything else
|
||||||
|
if (cl_capfps || r_NoInterpolate) r_TicFrac = FRACUNIT;
|
||||||
|
else r_TicFrac = I_GetTimeFrac (&r_FrameTime);
|
||||||
|
gl_frameMS = I_MSTime();
|
||||||
|
|
||||||
|
R_FindParticleSubsectors ();
|
||||||
|
|
||||||
|
// prepare all camera textures that have been used in the last frame
|
||||||
|
FCanvasTextureInfo::UpdateAll();
|
||||||
|
|
||||||
|
|
||||||
|
// I stopped using BaseRatioSizes here because the information there wasn't well presented.
|
||||||
|
#define RMUL (1.6f/1.333333f)
|
||||||
|
static float ratios[]={RMUL*1.333333f, RMUL*1.777777f, RMUL*1.6f, RMUL*1.333333f, RMUL*1.2f};
|
||||||
|
|
||||||
|
// now render the main view
|
||||||
|
float fovratio;
|
||||||
|
float ratio = ratios[WidescreenRatio];
|
||||||
|
if (!(WidescreenRatio&4))
|
||||||
|
{
|
||||||
|
fovratio = 1.6f;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fovratio = ratio;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetFixedColormap (player);
|
||||||
|
|
||||||
|
sector_t * viewsector = RenderViewpoint(player->camera, NULL, FieldOfView * 360.0f / FINEANGLES, ratio, fovratio, true);
|
||||||
|
EndDrawScene(viewsector);
|
||||||
|
|
||||||
|
All.Unclock();
|
||||||
|
}
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Render the view to a savegame picture
|
// Render the view to a savegame picture
|
||||||
|
|
|
@ -42,7 +42,6 @@
|
||||||
#include "r_translate.h"
|
#include "r_translate.h"
|
||||||
#include "g_level.h"
|
#include "g_level.h"
|
||||||
#include "doomstat.h"
|
#include "doomstat.h"
|
||||||
#include "gl/gl_framebuffer.h"
|
|
||||||
#include "gl/gl_struct.h"
|
#include "gl/gl_struct.h"
|
||||||
#include "gl/old_renderer/gl1_renderer.h"
|
#include "gl/old_renderer/gl1_renderer.h"
|
||||||
#include "gl/gl_lights.h"
|
#include "gl/gl_lights.h"
|
||||||
|
@ -53,6 +52,7 @@
|
||||||
#include "r_sky.h"
|
#include "r_sky.h"
|
||||||
#include "gl/common/glc_convert.h"
|
#include "gl/common/glc_convert.h"
|
||||||
|
|
||||||
|
#include "gl/system/gl_framebuffer.h"
|
||||||
#include "gl/scene/gl_drawinfo.h"
|
#include "gl/scene/gl_drawinfo.h"
|
||||||
#include "gl/scene/gl_portal.h"
|
#include "gl/scene/gl_portal.h"
|
||||||
#include "gl/models/gl_models.h"
|
#include "gl/models/gl_models.h"
|
||||||
|
|
|
@ -52,9 +52,9 @@
|
||||||
#include "templates.h"
|
#include "templates.h"
|
||||||
#include "gl/common/glc_clock.h"
|
#include "gl/common/glc_clock.h"
|
||||||
#include "gl/common/glc_templates.h"
|
#include "gl/common/glc_templates.h"
|
||||||
#include "gl/gl_framebuffer.h"
|
|
||||||
#include "gl/old_renderer/gl1_renderer.h"
|
#include "gl/old_renderer/gl1_renderer.h"
|
||||||
|
|
||||||
|
#include "gl/system/gl_framebuffer.h"
|
||||||
#include "gl/data/gl_data.h"
|
#include "gl/data/gl_data.h"
|
||||||
#include "gl/textures/gl_texture.h"
|
#include "gl/textures/gl_texture.h"
|
||||||
#include "gl/textures/gl_translate.h"
|
#include "gl/textures/gl_translate.h"
|
|
@ -38,7 +38,6 @@
|
||||||
#include "gl/gl_include.h"
|
#include "gl/gl_include.h"
|
||||||
#include "tarray.h"
|
#include "tarray.h"
|
||||||
#include "doomtype.h"
|
#include "doomtype.h"
|
||||||
#include "m_argv.h"
|
|
||||||
#include "gl/gl_intern.h"
|
#include "gl/gl_intern.h"
|
||||||
|
|
||||||
#ifndef unix
|
#ifndef unix
|
||||||
|
@ -350,7 +349,6 @@ static void APIENTRY LoadExtensions()
|
||||||
// This loads any function pointers and flags that require a vaild render context to
|
// This loads any function pointers and flags that require a vaild render context to
|
||||||
// initialize properly
|
// initialize properly
|
||||||
|
|
||||||
gl->shadermodel = 0; // assume no shader support
|
|
||||||
gl->vendorstring=(char*)glGetString(GL_VENDOR);
|
gl->vendorstring=(char*)glGetString(GL_VENDOR);
|
||||||
|
|
||||||
// First try the regular function
|
// First try the regular function
|
||||||
|
@ -364,8 +362,8 @@ static void APIENTRY LoadExtensions()
|
||||||
if (CheckExtension("GL_NV_texture_env_combine4")) gl->flags|=RFL_TEX_ENV_COMBINE4_NV;
|
if (CheckExtension("GL_NV_texture_env_combine4")) gl->flags|=RFL_TEX_ENV_COMBINE4_NV;
|
||||||
if (CheckExtension("GL_ATI_texture_env_combine3")) gl->flags|=RFL_TEX_ENV_COMBINE4_NV;
|
if (CheckExtension("GL_ATI_texture_env_combine3")) gl->flags|=RFL_TEX_ENV_COMBINE4_NV;
|
||||||
if (CheckExtension("GL_ARB_texture_non_power_of_two")) gl->flags|=RFL_NPOT_TEXTURE;
|
if (CheckExtension("GL_ARB_texture_non_power_of_two")) gl->flags|=RFL_NPOT_TEXTURE;
|
||||||
if (CheckExtension("GL_ARB_texture_compression")) gl->flags|=RFL_TEXTURE_COMPRESSION;
|
if (CheckExtension("GL_ARB_vertex_buffer_object")) gl->flags|=RFL_VBO;
|
||||||
if (CheckExtension("GL_EXT_texture_compression_s3tc")) gl->flags|=RFL_TEXTURE_COMPRESSION_S3TC;
|
|
||||||
|
|
||||||
if (strcmp((const char*)glGetString(GL_VERSION), "2.1") >= 0) gl->flags|=RFL_GL_21;
|
if (strcmp((const char*)glGetString(GL_VERSION), "2.1") >= 0) gl->flags|=RFL_GL_21;
|
||||||
if (strcmp((const char*)glGetString(GL_VERSION), "3.0") >= 0) gl->flags|=RFL_GL_30;
|
if (strcmp((const char*)glGetString(GL_VERSION), "3.0") >= 0) gl->flags|=RFL_GL_30;
|
||||||
|
@ -437,24 +435,7 @@ static void APIENTRY LoadExtensions()
|
||||||
gl->GetUniformiv = (PFNGLGETUNIFORMIVARBPROC)wglGetProcAddress("glGetUniformivARB");
|
gl->GetUniformiv = (PFNGLGETUNIFORMIVARBPROC)wglGetProcAddress("glGetUniformivARB");
|
||||||
gl->GetShaderSource = (PFNGLGETSHADERSOURCEARBPROC)wglGetProcAddress("glGetShaderSourceARB");
|
gl->GetShaderSource = (PFNGLGETSHADERSOURCEARBPROC)wglGetProcAddress("glGetShaderSourceARB");
|
||||||
|
|
||||||
gl->EnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)wglGetProcAddress("glEnableVertexAttribArrayARB");
|
gl->flags|=RFL_GLSL;
|
||||||
gl->DisableVertexAttribArray= (PFNGLDISABLEVERTEXATTRIBARRAYPROC)wglGetProcAddress("glDisableVertexAttribArrayARB");
|
|
||||||
gl->VertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)wglGetProcAddress("glVertexAttribPointerARB");
|
|
||||||
|
|
||||||
// Rules:
|
|
||||||
// SM4 will always use shaders. No option to switch them off is needed here.
|
|
||||||
// SM3 has shaders optional but they are off by default (they will have a performance impact
|
|
||||||
// SM2 only uses shaders for colormaps on camera textures and has no option to use them in general.
|
|
||||||
// On SM2 cards the shaders will be too slow and show visual bugs (at least on GF 6800.)
|
|
||||||
if (strcmp((const char*)glGetString(GL_SHADING_LANGUAGE_VERSION), "1.3") >= 0) gl->shadermodel = 4;
|
|
||||||
else if (CheckExtension("GL_NV_GPU_SHADER4")) gl->shadermodel = 4; // for pre-3.0 drivers that support GF8xxx.
|
|
||||||
else if (CheckExtension("GL_NV_VERTEX_PROGRAM3")) gl->shadermodel = 3;
|
|
||||||
else if (!strstr(gl->vendorstring, "NVIDIA")) gl->shadermodel = 3;
|
|
||||||
else gl->shadermodel = 2; // Only for older NVidia cards which had notoriously bad shader support.
|
|
||||||
|
|
||||||
// Command line overrides for testing and problem cases.
|
|
||||||
if (Args->CheckParm("-sm2") && gl->shadermodel > 2) gl->shadermodel = 2;
|
|
||||||
else if (Args->CheckParm("-sm3") && gl->shadermodel > 3) gl->shadermodel = 3;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CheckExtension("GL_ARB_occlusion_query"))
|
if (CheckExtension("GL_ARB_occlusion_query"))
|
||||||
|
@ -478,18 +459,7 @@ static void APIENTRY LoadExtensions()
|
||||||
gl->flags|=RFL_OCCLUSION_QUERY;
|
gl->flags|=RFL_OCCLUSION_QUERY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gl->flags & RFL_GL_21)
|
if (gl->flags & RFL_VBO)
|
||||||
{
|
|
||||||
gl->BindBuffer = (PFNGLBINDBUFFERPROC)wglGetProcAddress("glBindBuffer");
|
|
||||||
gl->DeleteBuffers = (PFNGLDELETEBUFFERSPROC)wglGetProcAddress("glDeleteBuffers");
|
|
||||||
gl->GenBuffers = (PFNGLGENBUFFERSPROC)wglGetProcAddress("glGenBuffers");
|
|
||||||
gl->BufferData = (PFNGLBUFFERDATAPROC)wglGetProcAddress("glBufferData");
|
|
||||||
gl->BufferSubData = (PFNGLBUFFERSUBDATAPROC)wglGetProcAddress("glBufferSubData");
|
|
||||||
gl->MapBuffer = (PFNGLMAPBUFFERPROC)wglGetProcAddress("glMapBuffer");
|
|
||||||
gl->UnmapBuffer = (PFNGLUNMAPBUFFERPROC)wglGetProcAddress("glUnmapBuffer");
|
|
||||||
gl->flags |= RFL_VBO;
|
|
||||||
}
|
|
||||||
else if (CheckExtension("GL_ARB_vertex_buffer_object"))
|
|
||||||
{
|
{
|
||||||
gl->BindBuffer = (PFNGLBINDBUFFERPROC)wglGetProcAddress("glBindBufferARB");
|
gl->BindBuffer = (PFNGLBINDBUFFERPROC)wglGetProcAddress("glBindBufferARB");
|
||||||
gl->DeleteBuffers = (PFNGLDELETEBUFFERSPROC)wglGetProcAddress("glDeleteBuffersARB");
|
gl->DeleteBuffers = (PFNGLDELETEBUFFERSPROC)wglGetProcAddress("glDeleteBuffersARB");
|
||||||
|
@ -498,45 +468,25 @@ static void APIENTRY LoadExtensions()
|
||||||
gl->BufferSubData = (PFNGLBUFFERSUBDATAPROC)wglGetProcAddress("glBufferSubDataARB");
|
gl->BufferSubData = (PFNGLBUFFERSUBDATAPROC)wglGetProcAddress("glBufferSubDataARB");
|
||||||
gl->MapBuffer = (PFNGLMAPBUFFERPROC)wglGetProcAddress("glMapBufferARB");
|
gl->MapBuffer = (PFNGLMAPBUFFERPROC)wglGetProcAddress("glMapBufferARB");
|
||||||
gl->UnmapBuffer = (PFNGLUNMAPBUFFERPROC)wglGetProcAddress("glUnmapBufferARB");
|
gl->UnmapBuffer = (PFNGLUNMAPBUFFERPROC)wglGetProcAddress("glUnmapBufferARB");
|
||||||
gl->flags|=RFL_VBO;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CheckExtension("GL_ARB_map_buffer_range"))
|
if (gl->flags & RFL_GL_21)
|
||||||
{
|
{
|
||||||
gl->MapBufferRange = (PFNGLMAPBUFFERRANGEPROC)wglGetProcAddress("glMapBufferRange");
|
gl->EnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)wglGetProcAddress("glEnableVertexAttribArray");
|
||||||
gl->FlushMappedBufferRange = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC)wglGetProcAddress("glFlushMappedBufferRange");
|
gl->DisableVertexAttribArray= (PFNGLDISABLEVERTEXATTRIBARRAYPROC)wglGetProcAddress("glDisableVertexAttribArray");
|
||||||
gl->flags|=RFL_MAP_BUFFER_RANGE;
|
gl->VertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)wglGetProcAddress("glVertexAttribPointer");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CheckExtension("GL_ARB_FRAMEBUFFER_OBJECT"))
|
// [BB] Check for the extensions that are necessary for on the fly texture compression.
|
||||||
|
if (CheckExtension("GL_ARB_texture_compression"))
|
||||||
{
|
{
|
||||||
gl->GenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)wglGetProcAddress("glGenFramebuffers");
|
gl->flags|=RFL_TEXTURE_COMPRESSION;
|
||||||
gl->BindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)wglGetProcAddress("glBindFramebuffer");
|
|
||||||
gl->FramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)wglGetProcAddress("glFramebufferTexture2D");
|
|
||||||
gl->GenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)wglGetProcAddress("glGenRenderbuffers");
|
|
||||||
gl->BindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)wglGetProcAddress("glBindRenderbuffer");
|
|
||||||
gl->RenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)wglGetProcAddress("glRenderbufferStorage");
|
|
||||||
gl->FramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)wglGetProcAddress("glFramebufferRenderbuffer");
|
|
||||||
|
|
||||||
gl->flags|=RFL_FRAMEBUFFER;
|
|
||||||
}
|
}
|
||||||
else if (CheckExtension("GL_EXT_FRAMEBUFFER_OBJECT") &&
|
if (CheckExtension("GL_EXT_texture_compression_s3tc"))
|
||||||
CheckExtension("GL_EXT_PACKED_DEPTH_STENCIL"))
|
|
||||||
{
|
{
|
||||||
gl->GenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)wglGetProcAddress("glGenFramebuffersEXT");
|
gl->flags|=RFL_TEXTURE_COMPRESSION_S3TC;
|
||||||
gl->BindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)wglGetProcAddress("glBindFramebufferEXT");
|
|
||||||
gl->FramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)wglGetProcAddress("glFramebufferTexture2DEXT");
|
|
||||||
gl->GenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)wglGetProcAddress("glGenRenderbuffersEXT");
|
|
||||||
gl->BindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)wglGetProcAddress("glBindRenderbufferEXT");
|
|
||||||
gl->RenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)wglGetProcAddress("glRenderbufferStorageEXT");
|
|
||||||
gl->FramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)wglGetProcAddress("glFramebufferRenderbufferEXT");
|
|
||||||
|
|
||||||
gl->flags|=RFL_FRAMEBUFFER;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
gl->ActiveTexture = (PFNGLACTIVETEXTUREPROC)wglGetProcAddress("glActiveTextureARB");
|
gl->ActiveTexture = (PFNGLACTIVETEXTUREPROC)wglGetProcAddress("glActiveTextureARB");
|
||||||
gl->MultiTexCoord2f = (PFNGLMULTITEXCOORD2FPROC) wglGetProcAddress("glMultiTexCoord2fARB");
|
gl->MultiTexCoord2f = (PFNGLMULTITEXCOORD2FPROC) wglGetProcAddress("glMultiTexCoord2fARB");
|
||||||
gl->MultiTexCoord2fv = (PFNGLMULTITEXCOORD2FVPROC) wglGetProcAddress("glMultiTexCoord2fvARB");
|
gl->MultiTexCoord2fv = (PFNGLMULTITEXCOORD2FVPROC) wglGetProcAddress("glMultiTexCoord2fvARB");
|
||||||
|
@ -553,7 +503,6 @@ static void APIENTRY PrintStartupLog()
|
||||||
Printf ("GL_VENDOR: %s\n", glGetString(GL_VENDOR));
|
Printf ("GL_VENDOR: %s\n", glGetString(GL_VENDOR));
|
||||||
Printf ("GL_RENDERER: %s\n", glGetString(GL_RENDERER));
|
Printf ("GL_RENDERER: %s\n", glGetString(GL_RENDERER));
|
||||||
Printf ("GL_VERSION: %s\n", glGetString(GL_VERSION));
|
Printf ("GL_VERSION: %s\n", glGetString(GL_VERSION));
|
||||||
Printf ("GL_SHADING_LANGUAGE_VERSION: %s\n", glGetString(GL_SHADING_LANGUAGE_VERSION));
|
|
||||||
Printf ("GL_EXTENSIONS: %s\n", glGetString(GL_EXTENSIONS));
|
Printf ("GL_EXTENSIONS: %s\n", glGetString(GL_EXTENSIONS));
|
||||||
#ifndef unix
|
#ifndef unix
|
||||||
Printf ("WGL_EXTENSIONS: %s\n", wgl_extensions);
|
Printf ("WGL_EXTENSIONS: %s\n", wgl_extensions);
|
|
@ -6,6 +6,7 @@ enum RenderFlags
|
||||||
RFL_NPOT_TEXTURE=1,
|
RFL_NPOT_TEXTURE=1,
|
||||||
RFL_NOSTENCIL=2,
|
RFL_NOSTENCIL=2,
|
||||||
RFL_FRAGMENT_PROGRAM=4,
|
RFL_FRAGMENT_PROGRAM=4,
|
||||||
|
RFL_GLSL=8,
|
||||||
RFL_OCCLUSION_QUERY=16,
|
RFL_OCCLUSION_QUERY=16,
|
||||||
RFL_TEX_ENV_COMBINE4_NV=32,
|
RFL_TEX_ENV_COMBINE4_NV=32,
|
||||||
RFL_TEX_ENV_COMBINE3_ATI=64,
|
RFL_TEX_ENV_COMBINE3_ATI=64,
|
||||||
|
@ -14,8 +15,6 @@ enum RenderFlags
|
||||||
RFL_TEXTURE_COMPRESSION_S3TC=256,
|
RFL_TEXTURE_COMPRESSION_S3TC=256,
|
||||||
|
|
||||||
RFL_VBO = 512,
|
RFL_VBO = 512,
|
||||||
RFL_MAP_BUFFER_RANGE = 1024,
|
|
||||||
RFL_FRAMEBUFFER = 2048,
|
|
||||||
|
|
||||||
|
|
||||||
RFL_GL_21 = 0x20000000,
|
RFL_GL_21 = 0x20000000,
|
||||||
|
@ -42,7 +41,6 @@ enum TexMode
|
||||||
struct RenderContext
|
struct RenderContext
|
||||||
{
|
{
|
||||||
unsigned int flags;
|
unsigned int flags;
|
||||||
unsigned int shadermodel;
|
|
||||||
int max_texturesize;
|
int max_texturesize;
|
||||||
char * vendorstring;
|
char * vendorstring;
|
||||||
|
|
||||||
|
@ -217,17 +215,6 @@ struct RenderContext
|
||||||
PFNGLDISABLEVERTEXATTRIBARRAYPROC DisableVertexAttribArray;
|
PFNGLDISABLEVERTEXATTRIBARRAYPROC DisableVertexAttribArray;
|
||||||
PFNGLVERTEXATTRIBPOINTERPROC VertexAttribPointer;
|
PFNGLVERTEXATTRIBPOINTERPROC VertexAttribPointer;
|
||||||
|
|
||||||
PFNGLMAPBUFFERRANGEPROC MapBufferRange;
|
|
||||||
PFNGLFLUSHMAPPEDBUFFERRANGEPROC FlushMappedBufferRange;
|
|
||||||
|
|
||||||
PFNGLGENFRAMEBUFFERSPROC GenFramebuffers;
|
|
||||||
PFNGLBINDFRAMEBUFFERPROC BindFramebuffer;
|
|
||||||
PFNGLFRAMEBUFFERTEXTURE2DPROC FramebufferTexture2D;
|
|
||||||
PFNGLGENRENDERBUFFERSPROC GenRenderbuffers;
|
|
||||||
PFNGLBINDRENDERBUFFERPROC BindRenderbuffer;
|
|
||||||
PFNGLRENDERBUFFERSTORAGEPROC RenderbufferStorage;
|
|
||||||
PFNGLFRAMEBUFFERRENDERBUFFERPROC FramebufferRenderbuffer;
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -54,11 +54,11 @@
|
||||||
|
|
||||||
#include "gl/gl_struct.h"
|
#include "gl/gl_struct.h"
|
||||||
#include "gl/gl_intern.h"
|
#include "gl/gl_intern.h"
|
||||||
#include "gl/gl_framebuffer.h"
|
|
||||||
#include "gl/old_renderer/gl1_renderer.h"
|
#include "gl/old_renderer/gl1_renderer.h"
|
||||||
#include "gl/gl_functions.h"
|
#include "gl/gl_functions.h"
|
||||||
#include "gl/old_renderer/gl1_shader.h"
|
#include "gl/old_renderer/gl1_shader.h"
|
||||||
|
|
||||||
|
#include "gl/system/gl_framebuffer.h"
|
||||||
#include "gl/data/gl_data.h"
|
#include "gl/data/gl_data.h"
|
||||||
#include "gl/textures/gl_texture.h"
|
#include "gl/textures/gl_texture.h"
|
||||||
#include "gl/textures/gl_translate.h"
|
#include "gl/textures/gl_translate.h"
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
#include "gl/gl_struct.h"
|
#include "gl/gl_struct.h"
|
||||||
#include "gl/gl_functions.h"
|
#include "gl/gl_functions.h"
|
||||||
#include "gl/old_renderer/gl1_shader.h"
|
#include "gl/old_renderer/gl1_shader.h"
|
||||||
#include "gl/gl_framebuffer.h"
|
|
||||||
#include "templates.h"
|
#include "templates.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
#include "c_console.h"
|
#include "c_console.h"
|
||||||
|
@ -18,6 +17,8 @@
|
||||||
#include "doomstat.h"
|
#include "doomstat.h"
|
||||||
//#include "gl_defs.h"
|
//#include "gl_defs.h"
|
||||||
|
|
||||||
|
#include "gl/system/gl_framebuffer.h"
|
||||||
|
|
||||||
void gl_CalculateCPUSpeed();
|
void gl_CalculateCPUSpeed();
|
||||||
|
|
||||||
CUSTOM_CVAR(Int, gl_vid_multisample, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL )
|
CUSTOM_CVAR(Int, gl_vid_multisample, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL )
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue