mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-14 08:31:23 +00:00
- bumped minimum supported OpenGL version to 1.4. The engine was already using several 1.3 and 1.4 features which would have caused problems on 1.2.
- removed gl_vid_compatibility. With the bump to 1.4 no hardware requiring this flag is supported anymore. - disabled 16 bit framebuffers for the same reason. As a conseqence all code for rendering without stencil could also be removed.
This commit is contained in:
parent
761ab4ab78
commit
b61ef3a107
16 changed files with 443 additions and 586 deletions
|
@ -81,6 +81,22 @@ EXTERN_CVAR(Bool, gl_render_segs)
|
||||||
//
|
//
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb)
|
||||||
|
{
|
||||||
|
framebuffer = fb;
|
||||||
|
mCurrentPortal = NULL;
|
||||||
|
mMirrorCount = 0;
|
||||||
|
mPlaneMirrorCount = 0;
|
||||||
|
mLightCount = 0;
|
||||||
|
mAngles = FRotator(0,0,0);
|
||||||
|
mViewVector = FVector2(0,0);
|
||||||
|
mCameraPos = FVector3(0,0,0);
|
||||||
|
mVBO = NULL;
|
||||||
|
gl_spriteindex = 0;
|
||||||
|
mShaderManager = NULL;
|
||||||
|
glpart2 = glpart = gllight = mirrortexture = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void FGLRenderer::Initialize()
|
void FGLRenderer::Initialize()
|
||||||
{
|
{
|
||||||
glpart2 = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/glpart2.png"), FTexture::TEX_MiscPatch);
|
glpart2 = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/glpart2.png"), FTexture::TEX_MiscPatch);
|
||||||
|
|
|
@ -71,21 +71,7 @@ public:
|
||||||
FFlatVertexBuffer *mVBO;
|
FFlatVertexBuffer *mVBO;
|
||||||
|
|
||||||
|
|
||||||
FGLRenderer(OpenGLFrameBuffer *fb)
|
FGLRenderer(OpenGLFrameBuffer *fb);
|
||||||
{
|
|
||||||
framebuffer = fb;
|
|
||||||
mCurrentPortal = NULL;
|
|
||||||
mMirrorCount = 0;
|
|
||||||
mPlaneMirrorCount = 0;
|
|
||||||
mLightCount = 0;
|
|
||||||
mAngles = FRotator(0,0,0);
|
|
||||||
mViewVector = FVector2(0,0);
|
|
||||||
mCameraPos = FVector3(0,0,0);
|
|
||||||
mVBO = NULL;
|
|
||||||
gl_spriteindex = 0;
|
|
||||||
mShaderManager = NULL;
|
|
||||||
glpart2 = glpart = gllight = mirrortexture = NULL;
|
|
||||||
}
|
|
||||||
~FGLRenderer() ;
|
~FGLRenderer() ;
|
||||||
|
|
||||||
angle_t FrustumAngle();
|
angle_t FrustumAngle();
|
||||||
|
|
|
@ -46,6 +46,8 @@
|
||||||
#include "gl/renderer/gl_renderstate.h"
|
#include "gl/renderer/gl_renderstate.h"
|
||||||
#include "gl/renderer/gl_colormap.h"
|
#include "gl/renderer/gl_colormap.h"
|
||||||
|
|
||||||
|
void gl_SetTextureMode(int type);
|
||||||
|
|
||||||
FRenderState gl_RenderState;
|
FRenderState gl_RenderState;
|
||||||
int FStateAttr::ChangeCounter;
|
int FStateAttr::ChangeCounter;
|
||||||
|
|
||||||
|
@ -291,7 +293,7 @@ void FRenderState::Apply(bool forcenoshader)
|
||||||
GLRenderer->mShaderManager->SetActiveShader(NULL);
|
GLRenderer->mShaderManager->SetActiveShader(NULL);
|
||||||
if (mTextureMode != ffTextureMode)
|
if (mTextureMode != ffTextureMode)
|
||||||
{
|
{
|
||||||
gl.SetTextureMode((ffTextureMode = mTextureMode));
|
gl_SetTextureMode((ffTextureMode = mTextureMode));
|
||||||
}
|
}
|
||||||
if (mTextureEnabled != ffTextureEnabled)
|
if (mTextureEnabled != ffTextureEnabled)
|
||||||
{
|
{
|
||||||
|
|
|
@ -470,15 +470,6 @@ void GLPortal::EndFrame()
|
||||||
{
|
{
|
||||||
GLPortal * p;
|
GLPortal * p;
|
||||||
|
|
||||||
if (gl.flags & RFL_NOSTENCIL)
|
|
||||||
{
|
|
||||||
while (portals.Pop(p) && p)
|
|
||||||
{
|
|
||||||
delete p;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gl_portalinfo)
|
if (gl_portalinfo)
|
||||||
{
|
{
|
||||||
Printf("%s%d portals, depth = %d\n%s{\n", indent.GetChars(), portals.Size(), renderdepth, indent.GetChars());
|
Printf("%s%d portals, depth = %d\n%s{\n", indent.GetChars(), portals.Size(), renderdepth, indent.GetChars());
|
||||||
|
|
|
@ -511,15 +511,12 @@ void FGLRenderer::RenderScene(int recursion)
|
||||||
// flood all the gaps with the back sector's flat texture
|
// flood all the gaps with the back sector's flat texture
|
||||||
// This will always be drawn like GLDL_PLAIN or GLDL_FOG, depending on the fog settings
|
// This will always be drawn like GLDL_PLAIN or GLDL_FOG, depending on the fog settings
|
||||||
|
|
||||||
if (!(gl.flags&RFL_NOSTENCIL)) // needs a stencil to work!
|
gl.DepthMask(false); // don't write to Z-buffer!
|
||||||
{
|
gl_RenderState.EnableFog(true);
|
||||||
gl.DepthMask(false); // don't write to Z-buffer!
|
gl_RenderState.EnableAlphaTest(false);
|
||||||
gl_RenderState.EnableFog(true);
|
gl_RenderState.BlendFunc(GL_ONE,GL_ZERO);
|
||||||
gl_RenderState.EnableAlphaTest(false);
|
gl_drawinfo->DrawUnhandledMissingTextures();
|
||||||
gl_RenderState.BlendFunc(GL_ONE,GL_ZERO);
|
gl_RenderState.EnableAlphaTest(true);
|
||||||
gl_drawinfo->DrawUnhandledMissingTextures();
|
|
||||||
gl_RenderState.EnableAlphaTest(true);
|
|
||||||
}
|
|
||||||
gl.DepthMask(true);
|
gl.DepthMask(true);
|
||||||
|
|
||||||
gl.PolygonOffset(0.0f, 0.0f);
|
gl.PolygonOffset(0.0f, 0.0f);
|
||||||
|
|
|
@ -16,7 +16,6 @@ EXTERN_CVAR(Bool, gl_colormap_shader)
|
||||||
EXTERN_CVAR(Bool, gl_brightmap_shader)
|
EXTERN_CVAR(Bool, gl_brightmap_shader)
|
||||||
EXTERN_CVAR(Bool, gl_glow_shader)
|
EXTERN_CVAR(Bool, gl_glow_shader)
|
||||||
|
|
||||||
EXTERN_CVAR(Bool, gl_vid_compatibility)
|
|
||||||
EXTERN_CVAR(Bool,gl_enhanced_nightvision)
|
EXTERN_CVAR(Bool,gl_enhanced_nightvision)
|
||||||
EXTERN_CVAR(Int, screenblocks);
|
EXTERN_CVAR(Int, screenblocks);
|
||||||
EXTERN_CVAR(Bool, gl_texture)
|
EXTERN_CVAR(Bool, gl_texture)
|
||||||
|
|
|
@ -73,6 +73,8 @@ CVAR(Bool, gl_aalines, false, CVAR_ARCHIVE)
|
||||||
FGLRenderer *GLRenderer;
|
FGLRenderer *GLRenderer;
|
||||||
|
|
||||||
void gl_SetupMenu();
|
void gl_SetupMenu();
|
||||||
|
void gl_LoadExtensions();
|
||||||
|
void gl_PrintStartupLog();
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
|
@ -115,14 +117,14 @@ void OpenGLFrameBuffer::InitializeState()
|
||||||
{
|
{
|
||||||
static bool first=true;
|
static bool first=true;
|
||||||
|
|
||||||
gl.LoadExtensions();
|
gl_LoadExtensions();
|
||||||
Super::InitializeState();
|
Super::InitializeState();
|
||||||
if (first)
|
if (first)
|
||||||
{
|
{
|
||||||
first=false;
|
first=false;
|
||||||
// [BB] For some reason this crashes, if compiled with MinGW and optimization. Has to be investigated.
|
// [BB] For some reason this crashes, if compiled with MinGW and optimization. Has to be investigated.
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
gl.PrintStartupLog();
|
gl_PrintStartupLog();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (gl.flags&RFL_NPOT_TEXTURE)
|
if (gl.flags&RFL_NPOT_TEXTURE)
|
||||||
|
|
|
@ -53,9 +53,7 @@ static void APIENTRY glBlendEquationDummy (GLenum mode);
|
||||||
|
|
||||||
static TArray<FString> m_Extensions;
|
static TArray<FString> m_Extensions;
|
||||||
|
|
||||||
#define gl pgl
|
RenderContext gl;
|
||||||
|
|
||||||
RenderContext * gl;
|
|
||||||
|
|
||||||
int occlusion_type=0;
|
int occlusion_type=0;
|
||||||
|
|
||||||
|
@ -107,343 +105,17 @@ static bool CheckExtension(const char *ext)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
static void APIENTRY LoadExtensions()
|
static void InitContext()
|
||||||
{
|
{
|
||||||
CollectExtensions();
|
|
||||||
|
|
||||||
const char *version = (const char*)glGetString(GL_VERSION);
|
|
||||||
|
|
||||||
// Don't even start if it's lower than 1.2
|
|
||||||
if (strcmp(version, "1.2") < 0)
|
|
||||||
{
|
|
||||||
I_FatalError("Unsupported OpenGL version.\nAt least GL 1.2 is required to run "GAMENAME".\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
// This loads any function pointers and flags that require a vaild render context to
|
|
||||||
// initialize properly
|
|
||||||
|
|
||||||
gl->shadermodel = 0; // assume no shader support
|
|
||||||
gl->vendorstring=(char*)glGetString(GL_VENDOR);
|
|
||||||
|
|
||||||
// First try the regular function
|
|
||||||
gl->BlendEquation = (PFNGLBLENDEQUATIONPROC)wglGetProcAddress("glBlendEquation");
|
|
||||||
// If that fails try the EXT version
|
|
||||||
if (!gl->BlendEquation) gl->BlendEquation = (PFNGLBLENDEQUATIONPROC)wglGetProcAddress("glBlendEquationEXT");
|
|
||||||
// If that fails use a no-op dummy
|
|
||||||
if (!gl->BlendEquation) gl->BlendEquation = glBlendEquationDummy;
|
|
||||||
|
|
||||||
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_EXT_texture_compression_s3tc")) gl->flags|=RFL_TEXTURE_COMPRESSION_S3TC;
|
|
||||||
if (strstr(gl->vendorstring, "NVIDIA")) gl->flags|=RFL_NVIDIA;
|
|
||||||
else if (strstr(gl->vendorstring, "ATI Technologies")) gl->flags|=RFL_ATI;
|
|
||||||
|
|
||||||
if (strcmp(version, "2.0") >= 0) gl->flags|=RFL_GL_20;
|
|
||||||
if (strcmp(version, "2.1") >= 0) gl->flags|=RFL_GL_21;
|
|
||||||
if (strcmp(version, "3.0") >= 0) gl->flags|=RFL_GL_30;
|
|
||||||
|
|
||||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE,&gl->max_texturesize);
|
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
|
||||||
|
|
||||||
if (gl->flags & RFL_GL_20)
|
|
||||||
{
|
|
||||||
gl->DeleteShader = (PFNGLDELETESHADERPROC)wglGetProcAddress("glDeleteShader");
|
|
||||||
gl->DeleteProgram = (PFNGLDELETEPROGRAMPROC)wglGetProcAddress("glDeleteProgram");
|
|
||||||
gl->DetachShader = (PFNGLDETACHSHADERPROC)wglGetProcAddress("glDetachShader");
|
|
||||||
gl->CreateShader = (PFNGLCREATESHADERPROC)wglGetProcAddress("glCreateShader");
|
|
||||||
gl->ShaderSource = (PFNGLSHADERSOURCEPROC)wglGetProcAddress("glShaderSource");
|
|
||||||
gl->CompileShader = (PFNGLCOMPILESHADERPROC)wglGetProcAddress("glCompileShader");
|
|
||||||
gl->CreateProgram = (PFNGLCREATEPROGRAMPROC)wglGetProcAddress("glCreateProgram");
|
|
||||||
gl->AttachShader = (PFNGLATTACHSHADERPROC)wglGetProcAddress("glAttachShader");
|
|
||||||
gl->LinkProgram = (PFNGLLINKPROGRAMPROC)wglGetProcAddress("glLinkProgram");
|
|
||||||
gl->UseProgram = (PFNGLUSEPROGRAMPROC)wglGetProcAddress("glUseProgram");
|
|
||||||
gl->ValidateProgram = (PFNGLVALIDATEPROGRAMPROC)wglGetProcAddress("glValidateProgram");
|
|
||||||
|
|
||||||
gl->VertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC)wglGetProcAddress("glVertexAttrib1f");
|
|
||||||
gl->VertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC)wglGetProcAddress("glVertexAttrib2f");
|
|
||||||
gl->VertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC)wglGetProcAddress("glVertexAttrib4f");
|
|
||||||
gl->VertexAttrib2fv = (PFNGLVERTEXATTRIB4FVPROC)wglGetProcAddress("glVertexAttrib2fv");
|
|
||||||
gl->VertexAttrib3fv = (PFNGLVERTEXATTRIB4FVPROC)wglGetProcAddress("glVertexAttrib3fv");
|
|
||||||
gl->VertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC)wglGetProcAddress("glVertexAttrib4fv");
|
|
||||||
gl->VertexAttrib4ubv = (PFNGLVERTEXATTRIB4UBVPROC)wglGetProcAddress("glVertexAttrib4ubv");
|
|
||||||
gl->GetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)wglGetProcAddress("glGetAttribLocation");
|
|
||||||
gl->BindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC)wglGetProcAddress("glBindAttribLocation");
|
|
||||||
|
|
||||||
|
|
||||||
gl->Uniform1f = (PFNGLUNIFORM1FPROC)wglGetProcAddress("glUniform1f");
|
|
||||||
gl->Uniform2f = (PFNGLUNIFORM2FPROC)wglGetProcAddress("glUniform2f");
|
|
||||||
gl->Uniform3f = (PFNGLUNIFORM3FPROC)wglGetProcAddress("glUniform3f");
|
|
||||||
gl->Uniform4f = (PFNGLUNIFORM4FPROC)wglGetProcAddress("glUniform4f");
|
|
||||||
gl->Uniform1i = (PFNGLUNIFORM1IPROC)wglGetProcAddress("glUniform1i");
|
|
||||||
gl->Uniform2i = (PFNGLUNIFORM2IPROC)wglGetProcAddress("glUniform2i");
|
|
||||||
gl->Uniform3i = (PFNGLUNIFORM3IPROC)wglGetProcAddress("glUniform3i");
|
|
||||||
gl->Uniform4i = (PFNGLUNIFORM4IPROC)wglGetProcAddress("glUniform4i");
|
|
||||||
gl->Uniform1fv = (PFNGLUNIFORM1FVPROC)wglGetProcAddress("glUniform1fv");
|
|
||||||
gl->Uniform2fv = (PFNGLUNIFORM2FVPROC)wglGetProcAddress("glUniform2fv");
|
|
||||||
gl->Uniform3fv = (PFNGLUNIFORM3FVPROC)wglGetProcAddress("glUniform3fv");
|
|
||||||
gl->Uniform4fv = (PFNGLUNIFORM4FVPROC)wglGetProcAddress("glUniform4fv");
|
|
||||||
gl->Uniform1iv = (PFNGLUNIFORM1IVPROC)wglGetProcAddress("glUniform1iv");
|
|
||||||
gl->Uniform2iv = (PFNGLUNIFORM2IVPROC)wglGetProcAddress("glUniform2iv");
|
|
||||||
gl->Uniform3iv = (PFNGLUNIFORM3IVPROC)wglGetProcAddress("glUniform3iv");
|
|
||||||
gl->Uniform4iv = (PFNGLUNIFORM4IVPROC)wglGetProcAddress("glUniform4iv");
|
|
||||||
|
|
||||||
gl->UniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC)wglGetProcAddress("glUniformMatrix2fv");
|
|
||||||
gl->UniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC)wglGetProcAddress("glUniformMatrix3fv");
|
|
||||||
gl->UniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)wglGetProcAddress("glUniformMatrix4fv");
|
|
||||||
|
|
||||||
gl->GetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)wglGetProcAddress("glGetProgramInfoLog");
|
|
||||||
gl->GetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)wglGetProcAddress("glGetShaderInfoLog");
|
|
||||||
gl->GetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)wglGetProcAddress("glGetUniformLocation");
|
|
||||||
gl->GetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC)wglGetProcAddress("glGetActiveUniform");
|
|
||||||
gl->GetUniformfv = (PFNGLGETUNIFORMFVPROC)wglGetProcAddress("glGetUniformfv");
|
|
||||||
gl->GetUniformiv = (PFNGLGETUNIFORMIVPROC)wglGetProcAddress("glGetUniformiv");
|
|
||||||
gl->GetShaderSource = (PFNGLGETSHADERSOURCEPROC)wglGetProcAddress("glGetShaderSource");
|
|
||||||
|
|
||||||
gl->EnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)wglGetProcAddress("glEnableVertexAttribArray");
|
|
||||||
gl->DisableVertexAttribArray= (PFNGLDISABLEVERTEXATTRIBARRAYPROC)wglGetProcAddress("glDisableVertexAttribArray");
|
|
||||||
gl->VertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)wglGetProcAddress("glVertexAttribPointer");
|
|
||||||
|
|
||||||
// what'S the equivalent of this in GL 2.0???
|
|
||||||
gl->GetObjectParameteriv = (PFNGLGETOBJECTPARAMETERIVARBPROC)wglGetProcAddress("glGetObjectParameterivARB");
|
|
||||||
|
|
||||||
// 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_EXT_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"))
|
|
||||||
{
|
|
||||||
gl->GenQueries = (PFNGLGENQUERIESARBPROC)wglGetProcAddress("glGenQueriesARB");
|
|
||||||
gl->DeleteQueries = (PFNGLDELETEQUERIESARBPROC)wglGetProcAddress("glDeleteQueriesARB");
|
|
||||||
gl->GetQueryObjectuiv = (PFNGLGETQUERYOBJECTUIVARBPROC)wglGetProcAddress("glGetQueryObjectuivARB");
|
|
||||||
gl->BeginQuery = (PFNGLBEGINQUERYARBPROC)wglGetProcAddress("glBeginQueryARB");
|
|
||||||
gl->EndQuery = (PFNGLENDQUERYPROC)wglGetProcAddress("glEndQueryARB");
|
|
||||||
gl->flags|=RFL_OCCLUSION_QUERY;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gl->flags & RFL_GL_21)
|
|
||||||
{
|
|
||||||
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->DeleteBuffers = (PFNGLDELETEBUFFERSPROC)wglGetProcAddress("glDeleteBuffersARB");
|
|
||||||
gl->GenBuffers = (PFNGLGENBUFFERSPROC)wglGetProcAddress("glGenBuffersARB");
|
|
||||||
gl->BufferData = (PFNGLBUFFERDATAPROC)wglGetProcAddress("glBufferDataARB");
|
|
||||||
gl->BufferSubData = (PFNGLBUFFERSUBDATAPROC)wglGetProcAddress("glBufferSubDataARB");
|
|
||||||
gl->MapBuffer = (PFNGLMAPBUFFERPROC)wglGetProcAddress("glMapBufferARB");
|
|
||||||
gl->UnmapBuffer = (PFNGLUNMAPBUFFERPROC)wglGetProcAddress("glUnmapBufferARB");
|
|
||||||
gl->flags |= RFL_VBO;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CheckExtension("GL_ARB_map_buffer_range"))
|
|
||||||
{
|
|
||||||
gl->MapBufferRange = (PFNGLMAPBUFFERRANGEPROC)wglGetProcAddress("glMapBufferRange");
|
|
||||||
gl->FlushMappedBufferRange = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC)wglGetProcAddress("glFlushMappedBufferRange");
|
|
||||||
gl->flags|=RFL_MAP_BUFFER_RANGE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CheckExtension("GL_ARB_framebuffer_object"))
|
|
||||||
{
|
|
||||||
gl->GenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)wglGetProcAddress("glGenFramebuffers");
|
|
||||||
gl->DeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)wglGetProcAddress("glDeleteFramebuffers");
|
|
||||||
gl->BindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)wglGetProcAddress("glBindFramebuffer");
|
|
||||||
gl->FramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)wglGetProcAddress("glFramebufferTexture2D");
|
|
||||||
gl->GenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)wglGetProcAddress("glGenRenderbuffers");
|
|
||||||
gl->DeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)wglGetProcAddress("glDeleteRenderbuffers");
|
|
||||||
gl->BindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)wglGetProcAddress("glBindRenderbuffer");
|
|
||||||
gl->RenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)wglGetProcAddress("glRenderbufferStorage");
|
|
||||||
gl->FramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)wglGetProcAddress("glFramebufferRenderbuffer");
|
|
||||||
|
|
||||||
gl->flags|=RFL_FRAMEBUFFER;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (CheckExtension("GL_ARB_texture_buffer_object") &&
|
|
||||||
CheckExtension("GL_ARB_texture_float") &&
|
|
||||||
CheckExtension("GL_EXT_GPU_Shader4") &&
|
|
||||||
CheckExtension("GL_ARB_texture_rg") &&
|
|
||||||
gl->shadermodel == 4)
|
|
||||||
{
|
|
||||||
gl->TexBufferARB = (PFNGLTEXBUFFERARBPROC)wglGetProcAddress("glTexBufferARB");
|
|
||||||
gl->flags|=RFL_TEXTUREBUFFER;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
gl->ActiveTexture = (PFNGLACTIVETEXTUREPROC)wglGetProcAddress("glActiveTextureARB");
|
|
||||||
gl->MultiTexCoord2f = (PFNGLMULTITEXCOORD2FPROC) wglGetProcAddress("glMultiTexCoord2fARB");
|
|
||||||
gl->MultiTexCoord2fv = (PFNGLMULTITEXCOORD2FVPROC) wglGetProcAddress("glMultiTexCoord2fvARB");
|
|
||||||
}
|
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
|
|
||||||
static void APIENTRY PrintStartupLog()
|
|
||||||
{
|
|
||||||
Printf ("GL_VENDOR: %s\n", glGetString(GL_VENDOR));
|
|
||||||
Printf ("GL_RENDERER: %s\n", glGetString(GL_RENDERER));
|
|
||||||
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));
|
|
||||||
int v;
|
|
||||||
|
|
||||||
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &v);
|
|
||||||
Printf ("Max. texture units: %d\n", v);
|
|
||||||
glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &v);
|
|
||||||
Printf ("Max. fragment uniforms: %d\n", v);
|
|
||||||
if (gl->shadermodel == 4) gl->maxuniforms = v;
|
|
||||||
glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, &v);
|
|
||||||
Printf ("Max. vertex uniforms: %d\n", v);
|
|
||||||
glGetIntegerv(GL_MAX_VARYING_FLOATS, &v);
|
|
||||||
Printf ("Max. varying: %d\n", v);
|
|
||||||
glGetIntegerv(GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS, &v);
|
|
||||||
Printf ("Max. combined uniforms: %d\n", v);
|
|
||||||
glGetIntegerv(GL_MAX_COMBINED_UNIFORM_BLOCKS, &v);
|
|
||||||
Printf ("Max. combined uniform blocks: %d\n", v);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
|
|
||||||
static void APIENTRY glBlendEquationDummy (GLenum mode)
|
|
||||||
{
|
|
||||||
// If this is not supported all non-existent modes are
|
|
||||||
// made to draw nothing.
|
|
||||||
if (mode == GL_FUNC_ADD)
|
|
||||||
{
|
|
||||||
glColorMask(true, true, true, true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
glColorMask(false, false, false, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
|
|
||||||
static void APIENTRY SetTextureMode(int type)
|
|
||||||
{
|
|
||||||
static float white[] = {1.f,1.f,1.f,1.f};
|
|
||||||
|
|
||||||
if (gl_vid_compatibility)
|
|
||||||
{
|
|
||||||
type = TM_MODULATE;
|
|
||||||
}
|
|
||||||
if (type == TM_MASK)
|
|
||||||
{
|
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE);
|
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PRIMARY_COLOR);
|
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
|
|
||||||
|
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE);
|
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PRIMARY_COLOR);
|
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_TEXTURE0);
|
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
|
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA);
|
|
||||||
}
|
|
||||||
else if (type == TM_OPAQUE)
|
|
||||||
{
|
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
|
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE0);
|
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR);
|
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
|
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
|
|
||||||
|
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
|
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PRIMARY_COLOR);
|
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
|
|
||||||
}
|
|
||||||
else if (type == TM_INVERT)
|
|
||||||
{
|
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
|
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE0);
|
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR);
|
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_ONE_MINUS_SRC_COLOR);
|
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
|
|
||||||
|
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE);
|
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PRIMARY_COLOR);
|
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_TEXTURE0);
|
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
|
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA);
|
|
||||||
}
|
|
||||||
else if (type == TM_INVERTOPAQUE)
|
|
||||||
{
|
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
|
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE0);
|
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR);
|
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_ONE_MINUS_SRC_COLOR);
|
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
|
|
||||||
|
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
|
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PRIMARY_COLOR);
|
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
|
|
||||||
}
|
|
||||||
else // if (type == TM_MODULATE)
|
|
||||||
{
|
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
|
|
||||||
void APIENTRY GetContext(RenderContext & gl)
|
|
||||||
{
|
|
||||||
::gl=≷
|
|
||||||
|
|
||||||
gl.flags=0;
|
gl.flags=0;
|
||||||
|
|
||||||
gl.LoadExtensions = LoadExtensions;
|
|
||||||
gl.SetTextureMode = SetTextureMode;
|
|
||||||
gl.PrintStartupLog = PrintStartupLog;
|
|
||||||
|
|
||||||
gl.Begin = glBegin;
|
gl.Begin = glBegin;
|
||||||
gl.End = glEnd;
|
gl.End = glEnd;
|
||||||
gl.DrawArrays = glDrawArrays;
|
gl.DrawArrays = glDrawArrays;
|
||||||
|
@ -522,6 +194,322 @@ void APIENTRY GetContext(RenderContext & gl)
|
||||||
gl.BlendEquation = glBlendEquationDummy;
|
gl.BlendEquation = glBlendEquationDummy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
void gl_LoadExtensions()
|
||||||
|
{
|
||||||
|
InitContext();
|
||||||
|
CollectExtensions();
|
||||||
|
|
||||||
|
const char *version = (const char*)glGetString(GL_VERSION);
|
||||||
|
|
||||||
|
// Don't even start if it's lower than 1.4
|
||||||
|
if (strcmp(version, "1.4") < 0)
|
||||||
|
{
|
||||||
|
I_FatalError("Unsupported OpenGL version.\nAt least GL 1.4 is required to run "GAMENAME".\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// This loads any function pointers and flags that require a vaild render context to
|
||||||
|
// initialize properly
|
||||||
|
|
||||||
|
gl.shadermodel = 0; // assume no shader support
|
||||||
|
gl.vendorstring=(char*)glGetString(GL_VENDOR);
|
||||||
|
|
||||||
|
// First try the regular function
|
||||||
|
gl.BlendEquation = (PFNGLBLENDEQUATIONPROC)wglGetProcAddress("glBlendEquation");
|
||||||
|
// If that fails try the EXT version
|
||||||
|
if (!gl.BlendEquation) gl.BlendEquation = (PFNGLBLENDEQUATIONPROC)wglGetProcAddress("glBlendEquationEXT");
|
||||||
|
// If that fails use a no-op dummy
|
||||||
|
if (!gl.BlendEquation) gl.BlendEquation = glBlendEquationDummy;
|
||||||
|
|
||||||
|
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_EXT_texture_compression_s3tc")) gl.flags|=RFL_TEXTURE_COMPRESSION_S3TC;
|
||||||
|
if (strstr(gl.vendorstring, "NVIDIA")) gl.flags|=RFL_NVIDIA;
|
||||||
|
else if (strstr(gl.vendorstring, "ATI Technologies")) gl.flags|=RFL_ATI;
|
||||||
|
|
||||||
|
if (strcmp(version, "2.0") >= 0) gl.flags|=RFL_GL_20;
|
||||||
|
if (strcmp(version, "2.1") >= 0) gl.flags|=RFL_GL_21;
|
||||||
|
if (strcmp(version, "3.0") >= 0) gl.flags|=RFL_GL_30;
|
||||||
|
|
||||||
|
glGetIntegerv(GL_MAX_TEXTURE_SIZE,&gl.max_texturesize);
|
||||||
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||||
|
|
||||||
|
if (gl.flags & RFL_GL_20)
|
||||||
|
{
|
||||||
|
gl.DeleteShader = (PFNGLDELETESHADERPROC)wglGetProcAddress("glDeleteShader");
|
||||||
|
gl.DeleteProgram = (PFNGLDELETEPROGRAMPROC)wglGetProcAddress("glDeleteProgram");
|
||||||
|
gl.DetachShader = (PFNGLDETACHSHADERPROC)wglGetProcAddress("glDetachShader");
|
||||||
|
gl.CreateShader = (PFNGLCREATESHADERPROC)wglGetProcAddress("glCreateShader");
|
||||||
|
gl.ShaderSource = (PFNGLSHADERSOURCEPROC)wglGetProcAddress("glShaderSource");
|
||||||
|
gl.CompileShader = (PFNGLCOMPILESHADERPROC)wglGetProcAddress("glCompileShader");
|
||||||
|
gl.CreateProgram = (PFNGLCREATEPROGRAMPROC)wglGetProcAddress("glCreateProgram");
|
||||||
|
gl.AttachShader = (PFNGLATTACHSHADERPROC)wglGetProcAddress("glAttachShader");
|
||||||
|
gl.LinkProgram = (PFNGLLINKPROGRAMPROC)wglGetProcAddress("glLinkProgram");
|
||||||
|
gl.UseProgram = (PFNGLUSEPROGRAMPROC)wglGetProcAddress("glUseProgram");
|
||||||
|
gl.ValidateProgram = (PFNGLVALIDATEPROGRAMPROC)wglGetProcAddress("glValidateProgram");
|
||||||
|
|
||||||
|
gl.VertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC)wglGetProcAddress("glVertexAttrib1f");
|
||||||
|
gl.VertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC)wglGetProcAddress("glVertexAttrib2f");
|
||||||
|
gl.VertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC)wglGetProcAddress("glVertexAttrib4f");
|
||||||
|
gl.VertexAttrib2fv = (PFNGLVERTEXATTRIB4FVPROC)wglGetProcAddress("glVertexAttrib2fv");
|
||||||
|
gl.VertexAttrib3fv = (PFNGLVERTEXATTRIB4FVPROC)wglGetProcAddress("glVertexAttrib3fv");
|
||||||
|
gl.VertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC)wglGetProcAddress("glVertexAttrib4fv");
|
||||||
|
gl.VertexAttrib4ubv = (PFNGLVERTEXATTRIB4UBVPROC)wglGetProcAddress("glVertexAttrib4ubv");
|
||||||
|
gl.GetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)wglGetProcAddress("glGetAttribLocation");
|
||||||
|
gl.BindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC)wglGetProcAddress("glBindAttribLocation");
|
||||||
|
|
||||||
|
|
||||||
|
gl.Uniform1f = (PFNGLUNIFORM1FPROC)wglGetProcAddress("glUniform1f");
|
||||||
|
gl.Uniform2f = (PFNGLUNIFORM2FPROC)wglGetProcAddress("glUniform2f");
|
||||||
|
gl.Uniform3f = (PFNGLUNIFORM3FPROC)wglGetProcAddress("glUniform3f");
|
||||||
|
gl.Uniform4f = (PFNGLUNIFORM4FPROC)wglGetProcAddress("glUniform4f");
|
||||||
|
gl.Uniform1i = (PFNGLUNIFORM1IPROC)wglGetProcAddress("glUniform1i");
|
||||||
|
gl.Uniform2i = (PFNGLUNIFORM2IPROC)wglGetProcAddress("glUniform2i");
|
||||||
|
gl.Uniform3i = (PFNGLUNIFORM3IPROC)wglGetProcAddress("glUniform3i");
|
||||||
|
gl.Uniform4i = (PFNGLUNIFORM4IPROC)wglGetProcAddress("glUniform4i");
|
||||||
|
gl.Uniform1fv = (PFNGLUNIFORM1FVPROC)wglGetProcAddress("glUniform1fv");
|
||||||
|
gl.Uniform2fv = (PFNGLUNIFORM2FVPROC)wglGetProcAddress("glUniform2fv");
|
||||||
|
gl.Uniform3fv = (PFNGLUNIFORM3FVPROC)wglGetProcAddress("glUniform3fv");
|
||||||
|
gl.Uniform4fv = (PFNGLUNIFORM4FVPROC)wglGetProcAddress("glUniform4fv");
|
||||||
|
gl.Uniform1iv = (PFNGLUNIFORM1IVPROC)wglGetProcAddress("glUniform1iv");
|
||||||
|
gl.Uniform2iv = (PFNGLUNIFORM2IVPROC)wglGetProcAddress("glUniform2iv");
|
||||||
|
gl.Uniform3iv = (PFNGLUNIFORM3IVPROC)wglGetProcAddress("glUniform3iv");
|
||||||
|
gl.Uniform4iv = (PFNGLUNIFORM4IVPROC)wglGetProcAddress("glUniform4iv");
|
||||||
|
|
||||||
|
gl.UniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC)wglGetProcAddress("glUniformMatrix2fv");
|
||||||
|
gl.UniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC)wglGetProcAddress("glUniformMatrix3fv");
|
||||||
|
gl.UniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)wglGetProcAddress("glUniformMatrix4fv");
|
||||||
|
|
||||||
|
gl.GetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)wglGetProcAddress("glGetProgramInfoLog");
|
||||||
|
gl.GetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)wglGetProcAddress("glGetShaderInfoLog");
|
||||||
|
gl.GetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)wglGetProcAddress("glGetUniformLocation");
|
||||||
|
gl.GetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC)wglGetProcAddress("glGetActiveUniform");
|
||||||
|
gl.GetUniformfv = (PFNGLGETUNIFORMFVPROC)wglGetProcAddress("glGetUniformfv");
|
||||||
|
gl.GetUniformiv = (PFNGLGETUNIFORMIVPROC)wglGetProcAddress("glGetUniformiv");
|
||||||
|
gl.GetShaderSource = (PFNGLGETSHADERSOURCEPROC)wglGetProcAddress("glGetShaderSource");
|
||||||
|
|
||||||
|
gl.EnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)wglGetProcAddress("glEnableVertexAttribArray");
|
||||||
|
gl.DisableVertexAttribArray= (PFNGLDISABLEVERTEXATTRIBARRAYPROC)wglGetProcAddress("glDisableVertexAttribArray");
|
||||||
|
gl.VertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)wglGetProcAddress("glVertexAttribPointer");
|
||||||
|
|
||||||
|
// what'S the equivalent of this in GL 2.0???
|
||||||
|
gl.GetObjectParameteriv = (PFNGLGETOBJECTPARAMETERIVARBPROC)wglGetProcAddress("glGetObjectParameterivARB");
|
||||||
|
|
||||||
|
// 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_EXT_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"))
|
||||||
|
{
|
||||||
|
gl.GenQueries = (PFNGLGENQUERIESARBPROC)wglGetProcAddress("glGenQueriesARB");
|
||||||
|
gl.DeleteQueries = (PFNGLDELETEQUERIESARBPROC)wglGetProcAddress("glDeleteQueriesARB");
|
||||||
|
gl.GetQueryObjectuiv = (PFNGLGETQUERYOBJECTUIVARBPROC)wglGetProcAddress("glGetQueryObjectuivARB");
|
||||||
|
gl.BeginQuery = (PFNGLBEGINQUERYARBPROC)wglGetProcAddress("glBeginQueryARB");
|
||||||
|
gl.EndQuery = (PFNGLENDQUERYPROC)wglGetProcAddress("glEndQueryARB");
|
||||||
|
gl.flags|=RFL_OCCLUSION_QUERY;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gl.flags & RFL_GL_21)
|
||||||
|
{
|
||||||
|
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.DeleteBuffers = (PFNGLDELETEBUFFERSPROC)wglGetProcAddress("glDeleteBuffersARB");
|
||||||
|
gl.GenBuffers = (PFNGLGENBUFFERSPROC)wglGetProcAddress("glGenBuffersARB");
|
||||||
|
gl.BufferData = (PFNGLBUFFERDATAPROC)wglGetProcAddress("glBufferDataARB");
|
||||||
|
gl.BufferSubData = (PFNGLBUFFERSUBDATAPROC)wglGetProcAddress("glBufferSubDataARB");
|
||||||
|
gl.MapBuffer = (PFNGLMAPBUFFERPROC)wglGetProcAddress("glMapBufferARB");
|
||||||
|
gl.UnmapBuffer = (PFNGLUNMAPBUFFERPROC)wglGetProcAddress("glUnmapBufferARB");
|
||||||
|
gl.flags |= RFL_VBO;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CheckExtension("GL_ARB_map_buffer_range"))
|
||||||
|
{
|
||||||
|
gl.MapBufferRange = (PFNGLMAPBUFFERRANGEPROC)wglGetProcAddress("glMapBufferRange");
|
||||||
|
gl.FlushMappedBufferRange = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC)wglGetProcAddress("glFlushMappedBufferRange");
|
||||||
|
gl.flags|=RFL_MAP_BUFFER_RANGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CheckExtension("GL_ARB_framebuffer_object"))
|
||||||
|
{
|
||||||
|
gl.GenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)wglGetProcAddress("glGenFramebuffers");
|
||||||
|
gl.DeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)wglGetProcAddress("glDeleteFramebuffers");
|
||||||
|
gl.BindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)wglGetProcAddress("glBindFramebuffer");
|
||||||
|
gl.FramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)wglGetProcAddress("glFramebufferTexture2D");
|
||||||
|
gl.GenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)wglGetProcAddress("glGenRenderbuffers");
|
||||||
|
gl.DeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)wglGetProcAddress("glDeleteRenderbuffers");
|
||||||
|
gl.BindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)wglGetProcAddress("glBindRenderbuffer");
|
||||||
|
gl.RenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)wglGetProcAddress("glRenderbufferStorage");
|
||||||
|
gl.FramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)wglGetProcAddress("glFramebufferRenderbuffer");
|
||||||
|
|
||||||
|
gl.flags|=RFL_FRAMEBUFFER;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if (CheckExtension("GL_ARB_texture_buffer_object") &&
|
||||||
|
CheckExtension("GL_ARB_texture_float") &&
|
||||||
|
CheckExtension("GL_EXT_GPU_Shader4") &&
|
||||||
|
CheckExtension("GL_ARB_texture_rg") &&
|
||||||
|
gl.shadermodel == 4)
|
||||||
|
{
|
||||||
|
gl.TexBufferARB = (PFNGLTEXBUFFERARBPROC)wglGetProcAddress("glTexBufferARB");
|
||||||
|
gl.flags|=RFL_TEXTUREBUFFER;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
gl.ActiveTexture = (PFNGLACTIVETEXTUREPROC)wglGetProcAddress("glActiveTextureARB");
|
||||||
|
gl.MultiTexCoord2f = (PFNGLMULTITEXCOORD2FPROC) wglGetProcAddress("glMultiTexCoord2fARB");
|
||||||
|
gl.MultiTexCoord2fv = (PFNGLMULTITEXCOORD2FVPROC) wglGetProcAddress("glMultiTexCoord2fvARB");
|
||||||
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
void gl_PrintStartupLog()
|
||||||
|
{
|
||||||
|
Printf ("GL_VENDOR: %s\n", glGetString(GL_VENDOR));
|
||||||
|
Printf ("GL_RENDERER: %s\n", glGetString(GL_RENDERER));
|
||||||
|
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));
|
||||||
|
int v;
|
||||||
|
|
||||||
|
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &v);
|
||||||
|
Printf ("Max. texture units: %d\n", v);
|
||||||
|
glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &v);
|
||||||
|
Printf ("Max. fragment uniforms: %d\n", v);
|
||||||
|
if (gl.shadermodel == 4) gl.maxuniforms = v;
|
||||||
|
glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, &v);
|
||||||
|
Printf ("Max. vertex uniforms: %d\n", v);
|
||||||
|
glGetIntegerv(GL_MAX_VARYING_FLOATS, &v);
|
||||||
|
Printf ("Max. varying: %d\n", v);
|
||||||
|
glGetIntegerv(GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS, &v);
|
||||||
|
Printf ("Max. combined uniforms: %d\n", v);
|
||||||
|
glGetIntegerv(GL_MAX_COMBINED_UNIFORM_BLOCKS, &v);
|
||||||
|
Printf ("Max. combined uniform blocks: %d\n", v);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
static void APIENTRY glBlendEquationDummy (GLenum mode)
|
||||||
|
{
|
||||||
|
// If this is not supported all non-existent modes are
|
||||||
|
// made to draw nothing.
|
||||||
|
if (mode == GL_FUNC_ADD)
|
||||||
|
{
|
||||||
|
glColorMask(true, true, true, true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
glColorMask(false, false, false, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
void gl_SetTextureMode(int type)
|
||||||
|
{
|
||||||
|
static float white[] = {1.f,1.f,1.f,1.f};
|
||||||
|
|
||||||
|
if (type == TM_MASK)
|
||||||
|
{
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE);
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PRIMARY_COLOR);
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
|
||||||
|
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE);
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PRIMARY_COLOR);
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_TEXTURE0);
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA);
|
||||||
|
}
|
||||||
|
else if (type == TM_OPAQUE)
|
||||||
|
{
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE0);
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR);
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
|
||||||
|
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PRIMARY_COLOR);
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
|
||||||
|
}
|
||||||
|
else if (type == TM_INVERT)
|
||||||
|
{
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE0);
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR);
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_ONE_MINUS_SRC_COLOR);
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
|
||||||
|
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE);
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PRIMARY_COLOR);
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_TEXTURE0);
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA);
|
||||||
|
}
|
||||||
|
else if (type == TM_INVERTOPAQUE)
|
||||||
|
{
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE0);
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR);
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_ONE_MINUS_SRC_COLOR);
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
|
||||||
|
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PRIMARY_COLOR);
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
|
||||||
|
}
|
||||||
|
else // if (type == TM_MODULATE)
|
||||||
|
{
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//} // extern "C"
|
//} // extern "C"
|
||||||
|
|
|
@ -21,7 +21,6 @@ typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat
|
||||||
enum RenderFlags
|
enum RenderFlags
|
||||||
{
|
{
|
||||||
RFL_NPOT_TEXTURE=1,
|
RFL_NPOT_TEXTURE=1,
|
||||||
RFL_NOSTENCIL=2,
|
|
||||||
RFL_OCCLUSION_QUERY=4,
|
RFL_OCCLUSION_QUERY=4,
|
||||||
// [BB] Added texture compression flags.
|
// [BB] Added texture compression flags.
|
||||||
RFL_TEXTURE_COMPRESSION=8,
|
RFL_TEXTURE_COMPRESSION=8,
|
||||||
|
@ -67,10 +66,6 @@ struct RenderContext
|
||||||
return maxuniforms>=2048? 128:64;
|
return maxuniforms>=2048? 128:64;
|
||||||
}
|
}
|
||||||
|
|
||||||
void (APIENTRY * LoadExtensions) ();
|
|
||||||
void (APIENTRY * SetTextureMode) (int type);
|
|
||||||
void (APIENTRY * PrintStartupLog) ();
|
|
||||||
|
|
||||||
void (APIENTRY * Begin) (GLenum mode);
|
void (APIENTRY * Begin) (GLenum mode);
|
||||||
void (APIENTRY * End) (void);
|
void (APIENTRY * End) (void);
|
||||||
void (APIENTRY * DrawArrays) (GLenum mode, GLint first, GLsizei count);
|
void (APIENTRY * DrawArrays) (GLenum mode, GLint first, GLsizei count);
|
||||||
|
@ -237,7 +232,5 @@ struct RenderContext
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void APIENTRY GetContext(RenderContext & gl);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@ CVAR(Bool,gl_mirrors,true,0) // This is for debugging only!
|
||||||
CVAR(Bool,gl_mirror_envmap, true, CVAR_GLOBALCONFIG|CVAR_ARCHIVE)
|
CVAR(Bool,gl_mirror_envmap, true, CVAR_GLOBALCONFIG|CVAR_ARCHIVE)
|
||||||
CVAR(Bool, gl_render_segs, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
CVAR(Bool, gl_render_segs, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||||
CVAR(Bool, gl_seamless, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
CVAR(Bool, gl_seamless, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||||
CVAR(Bool, gl_vid_compatibility, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG);
|
|
||||||
|
|
||||||
CUSTOM_CVAR(Int, r_mirror_recursions,4,CVAR_GLOBALCONFIG|CVAR_ARCHIVE)
|
CUSTOM_CVAR(Int, r_mirror_recursions,4,CVAR_GLOBALCONFIG|CVAR_ARCHIVE)
|
||||||
{
|
{
|
||||||
|
|
|
@ -69,8 +69,6 @@ struct RECT {
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
EXTERN_CVAR(Bool, gl_vid_compatibility)
|
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Screen wipes
|
// Screen wipes
|
||||||
|
@ -127,10 +125,6 @@ private:
|
||||||
|
|
||||||
bool OpenGLFrameBuffer::WipeStartScreen(int type)
|
bool OpenGLFrameBuffer::WipeStartScreen(int type)
|
||||||
{
|
{
|
||||||
if (gl_vid_compatibility)
|
|
||||||
{
|
|
||||||
return false; // not all required features present.
|
|
||||||
}
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case wipe_Burn:
|
case wipe_Burn:
|
||||||
|
|
|
@ -119,10 +119,6 @@ void FHardwareTexture::LoadImage(unsigned char * buffer,int w, int h, unsigned i
|
||||||
rw = GetTexDimension (w);
|
rw = GetTexDimension (w);
|
||||||
rh = GetTexDimension (h);
|
rh = GetTexDimension (h);
|
||||||
|
|
||||||
if (gl_vid_compatibility)
|
|
||||||
{
|
|
||||||
mipmap=false;
|
|
||||||
}
|
|
||||||
gl.TexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, (mipmap && use_mipmapping && !forcenofiltering));
|
gl.TexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, (mipmap && use_mipmapping && !forcenofiltering));
|
||||||
|
|
||||||
if (rw == w && rh == h)
|
if (rw == w && rh == h)
|
||||||
|
|
|
@ -59,8 +59,6 @@ CUSTOM_CVAR(Int, gl_vid_multisample, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_
|
||||||
Printf("This won't take effect until "GAMENAME" is restarted.\n");
|
Printf("This won't take effect until "GAMENAME" is restarted.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderContext gl;
|
|
||||||
|
|
||||||
// PRIVATE DATA DEFINITIONS ------------------------------------------------
|
// PRIVATE DATA DEFINITIONS ------------------------------------------------
|
||||||
|
|
||||||
// Dummy screen sizes to pass when windowed
|
// Dummy screen sizes to pass when windowed
|
||||||
|
@ -123,7 +121,6 @@ SDLGLVideo::SDLGLVideo (int parm)
|
||||||
fprintf( stderr, "Video initialization failed: %s\n",
|
fprintf( stderr, "Video initialization failed: %s\n",
|
||||||
SDL_GetError( ) );
|
SDL_GetError( ) );
|
||||||
}
|
}
|
||||||
GetContext(gl);
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
// mouse cursor is visible by default on linux systems, we disable it by default
|
// mouse cursor is visible by default on linux systems, we disable it by default
|
||||||
SDL_ShowCursor (0);
|
SDL_ShowCursor (0);
|
||||||
|
@ -285,40 +282,18 @@ bool SDLGLVideo::SetResolution (int width, int height, int bits)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
bool SDLGLVideo::SetupPixelFormat(bool allowsoftware, bool nostencil, int multisample)
|
bool SDLGLVideo::SetupPixelFormat(bool allowsoftware, int multisample)
|
||||||
{
|
{
|
||||||
int stencil;
|
SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 );
|
||||||
|
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 );
|
||||||
if (!nostencil)
|
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 );
|
||||||
{
|
SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8 );
|
||||||
stencil=1;
|
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 24 );
|
||||||
SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 );
|
SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 8 );
|
||||||
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 );
|
|
||||||
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 );
|
|
||||||
SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8 );
|
|
||||||
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 24 );
|
|
||||||
SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 8 );
|
|
||||||
// SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
|
// SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
|
||||||
if (multisample > 0) {
|
if (multisample > 0) {
|
||||||
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 );
|
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 );
|
||||||
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, multisample );
|
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, multisample );
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Use the cheapest mode available and let's hope the driver can handle this...
|
|
||||||
stencil=0;
|
|
||||||
|
|
||||||
SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 4 );
|
|
||||||
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 4 );
|
|
||||||
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 4 );
|
|
||||||
SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 4 );
|
|
||||||
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
|
|
||||||
//SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 )*/
|
|
||||||
}
|
|
||||||
if (stencil==0)
|
|
||||||
{
|
|
||||||
gl.flags|=RFL_NOSTENCIL;
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -329,13 +304,20 @@ bool SDLGLVideo::SetupPixelFormat(bool allowsoftware, bool nostencil, int multis
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
bool SDLGLVideo::InitHardware (bool allowsoftware, bool nostencil, int multisample)
|
bool SDLGLVideo::InitHardware (bool allowsoftware, int multisample)
|
||||||
{
|
{
|
||||||
if (!SetupPixelFormat(allowsoftware, nostencil, multisample))
|
if (!SetupPixelFormat(allowsoftware, multisample))
|
||||||
{
|
{
|
||||||
Printf ("R_OPENGL: Reverting to software mode...\n");
|
Printf ("R_OPENGL: Reverting to software mode...\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
int value = 0;
|
||||||
|
SDL_GL_GetAttribute( SDL_GL_STENCIL_SIZE, &value );
|
||||||
|
if (!value)
|
||||||
|
{
|
||||||
|
Printf("R_OPENGL: Failed to initialize stencil buffer! Reverting to software mode...\n");
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -355,23 +337,15 @@ SDLGLFB::SDLGLFB (void *, int width, int height, int, int, bool fullscreen)
|
||||||
|
|
||||||
UpdatePending = false;
|
UpdatePending = false;
|
||||||
|
|
||||||
if (!static_cast<SDLGLVideo*>(Video)->InitHardware(false, gl_vid_compatibility, localmultisample))
|
if (!static_cast<SDLGLVideo*>(Video)->InitHardware(false, localmultisample))
|
||||||
{
|
{
|
||||||
vid_renderer = 0;
|
vid_renderer = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mac OS X version will crash when entering fullscreen mode with BPP <= 8
|
|
||||||
// Also it may crash with BPP == 16 on some configurations
|
|
||||||
// It seems 24 and 32 bits are safe values
|
|
||||||
// So value of vid_displaybits is ignored and hardcoded constant is used instead
|
|
||||||
|
|
||||||
Screen = SDL_SetVideoMode (width, height,
|
Screen = SDL_SetVideoMode (width, height,
|
||||||
#if defined(__APPLE__)
|
|
||||||
32,
|
32,
|
||||||
#else // ! __APPLE__
|
|
||||||
vid_displaybits,
|
|
||||||
#endif // __APPLE__
|
|
||||||
SDL_HWSURFACE|SDL_HWPALETTE|SDL_OPENGL | SDL_GL_DOUBLEBUFFER|SDL_ANYFORMAT|
|
SDL_HWSURFACE|SDL_HWPALETTE|SDL_OPENGL | SDL_GL_DOUBLEBUFFER|SDL_ANYFORMAT|
|
||||||
(fullscreen ? SDL_FULLSCREEN : 0));
|
(fullscreen ? SDL_FULLSCREEN : 0));
|
||||||
|
|
||||||
|
@ -401,13 +375,6 @@ SDLGLFB::~SDLGLFB ()
|
||||||
|
|
||||||
void SDLGLFB::InitializeState()
|
void SDLGLFB::InitializeState()
|
||||||
{
|
{
|
||||||
int value = 0;
|
|
||||||
SDL_GL_GetAttribute( SDL_GL_STENCIL_SIZE, &value );
|
|
||||||
if (!value)
|
|
||||||
{
|
|
||||||
Printf("Failed to use stencil buffer!\n"); //[C] is it needed to recreate buffer in "cheapest mode"?
|
|
||||||
gl.flags|=RFL_NOSTENCIL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SDLGLFB::CanUpdate ()
|
bool SDLGLFB::CanUpdate ()
|
||||||
|
|
|
@ -27,8 +27,8 @@ class SDLGLVideo : public IVideo
|
||||||
bool NextMode (int *width, int *height, bool *letterbox);
|
bool NextMode (int *width, int *height, bool *letterbox);
|
||||||
bool SetResolution (int width, int height, int bits);
|
bool SetResolution (int width, int height, int bits);
|
||||||
|
|
||||||
bool SetupPixelFormat(bool allowsoftware, bool nostencil, int multisample);
|
bool SetupPixelFormat(bool allowsoftware, int multisample);
|
||||||
bool InitHardware (bool allowsoftware, bool nostencil, int multisample);
|
bool InitHardware (bool allowsoftware, int multisample);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int IteratorMode;
|
int IteratorMode;
|
||||||
|
|
|
@ -29,10 +29,6 @@ CUSTOM_CVAR(Int, gl_vid_multisample, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_
|
||||||
|
|
||||||
CVAR(Bool, gl_debug, false, 0)
|
CVAR(Bool, gl_debug, false, 0)
|
||||||
|
|
||||||
RenderContext gl;
|
|
||||||
|
|
||||||
|
|
||||||
EXTERN_CVAR(Bool, gl_vid_compatibility)
|
|
||||||
EXTERN_CVAR(Int, vid_refreshrate)
|
EXTERN_CVAR(Int, vid_refreshrate)
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -49,12 +45,11 @@ Win32GLVideo::Win32GLVideo(int parm) : m_Modes(NULL), m_IsFullscreen(false)
|
||||||
I_SetWndProc();
|
I_SetWndProc();
|
||||||
m_DisplayWidth = vid_defwidth;
|
m_DisplayWidth = vid_defwidth;
|
||||||
m_DisplayHeight = vid_defheight;
|
m_DisplayHeight = vid_defheight;
|
||||||
m_DisplayBits = gl_vid_compatibility? 16:32;
|
m_DisplayBits = 32;
|
||||||
m_DisplayHz = 60;
|
m_DisplayHz = 60;
|
||||||
|
|
||||||
GetDisplayDeviceName();
|
GetDisplayDeviceName();
|
||||||
MakeModesList();
|
MakeModesList();
|
||||||
GetContext(gl);
|
|
||||||
SetPixelFormat();
|
SetPixelFormat();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -202,8 +197,8 @@ void Win32GLVideo::StartModeIterator(int bits, bool fs)
|
||||||
{
|
{
|
||||||
m_IteratorMode = m_Modes;
|
m_IteratorMode = m_Modes;
|
||||||
// I think it's better to ignore the game-side settings of bit depth.
|
// I think it's better to ignore the game-side settings of bit depth.
|
||||||
// The GL renderer will always default to 32 bits, except in compatibility mode
|
// The GL renderer will always default to 32 bits because 16 bit modes cannot have a stencil buffer.
|
||||||
m_IteratorBits = gl_vid_compatibility? 16:32;
|
m_IteratorBits = 32;
|
||||||
m_IteratorFS = fs;
|
m_IteratorFS = fs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,7 +334,7 @@ DFrameBuffer *Win32GLVideo::CreateFrameBuffer(int width, int height, bool fs, DF
|
||||||
|
|
||||||
m_DisplayWidth = width;
|
m_DisplayWidth = width;
|
||||||
m_DisplayHeight = height;
|
m_DisplayHeight = height;
|
||||||
m_DisplayBits = gl_vid_compatibility? 16:32;
|
m_DisplayBits = 32;
|
||||||
m_DisplayHz = 60;
|
m_DisplayHz = 60;
|
||||||
|
|
||||||
if (vid_refreshrate == 0)
|
if (vid_refreshrate == 0)
|
||||||
|
@ -604,7 +599,7 @@ bool Win32GLVideo::SetPixelFormat()
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
bool Win32GLVideo::SetupPixelFormat(bool allowsoftware, bool nostencil, int multisample)
|
bool Win32GLVideo::SetupPixelFormat(bool allowsoftware, int multisample)
|
||||||
{
|
{
|
||||||
int colorDepth;
|
int colorDepth;
|
||||||
HDC deskDC;
|
HDC deskDC;
|
||||||
|
@ -612,154 +607,90 @@ bool Win32GLVideo::SetupPixelFormat(bool allowsoftware, bool nostencil, int mult
|
||||||
int pixelFormat;
|
int pixelFormat;
|
||||||
unsigned int numFormats;
|
unsigned int numFormats;
|
||||||
float attribsFloat[] = {0.0f, 0.0f};
|
float attribsFloat[] = {0.0f, 0.0f};
|
||||||
int stencil;
|
|
||||||
|
|
||||||
deskDC = GetDC(GetDesktopWindow());
|
deskDC = GetDC(GetDesktopWindow());
|
||||||
colorDepth = GetDeviceCaps(deskDC, BITSPIXEL);
|
colorDepth = GetDeviceCaps(deskDC, BITSPIXEL);
|
||||||
ReleaseDC(GetDesktopWindow(), deskDC);
|
ReleaseDC(GetDesktopWindow(), deskDC);
|
||||||
|
|
||||||
/*
|
if (wglChoosePixelFormatARB)
|
||||||
if (!nostencil && colorDepth < 32)
|
|
||||||
{
|
{
|
||||||
Printf("R_OPENGL: Desktop not in 32 bit mode!\n");
|
attributes[0] = WGL_RED_BITS_ARB; //bits
|
||||||
return false;
|
attributes[1] = 8;
|
||||||
}
|
attributes[2] = WGL_GREEN_BITS_ARB; //bits
|
||||||
*/
|
attributes[3] = 8;
|
||||||
|
attributes[4] = WGL_BLUE_BITS_ARB; //bits
|
||||||
|
attributes[5] = 8;
|
||||||
|
attributes[6] = WGL_ALPHA_BITS_ARB;
|
||||||
|
attributes[7] = 8;
|
||||||
|
attributes[8] = WGL_DEPTH_BITS_ARB;
|
||||||
|
attributes[9] = 24;
|
||||||
|
attributes[10] = WGL_STENCIL_BITS_ARB;
|
||||||
|
attributes[11] = 8;
|
||||||
|
|
||||||
if (!nostencil)
|
attributes[12] = WGL_DRAW_TO_WINDOW_ARB; //required to be true
|
||||||
{
|
attributes[13] = true;
|
||||||
for (stencil=1;stencil>=0;stencil--)
|
attributes[14] = WGL_SUPPORT_OPENGL_ARB;
|
||||||
|
attributes[15] = true;
|
||||||
|
attributes[16] = WGL_DOUBLE_BUFFER_ARB;
|
||||||
|
attributes[17] = true;
|
||||||
|
|
||||||
|
attributes[18] = WGL_ACCELERATION_ARB; //required to be FULL_ACCELERATION_ARB
|
||||||
|
if (allowsoftware)
|
||||||
{
|
{
|
||||||
if (wglChoosePixelFormatARB && stencil)
|
attributes[19] = WGL_NO_ACCELERATION_ARB;
|
||||||
{
|
}
|
||||||
attributes[0] = WGL_RED_BITS_ARB; //bits
|
else
|
||||||
attributes[1] = 8;
|
{
|
||||||
attributes[2] = WGL_GREEN_BITS_ARB; //bits
|
attributes[19] = WGL_FULL_ACCELERATION_ARB;
|
||||||
attributes[3] = 8;
|
}
|
||||||
attributes[4] = WGL_BLUE_BITS_ARB; //bits
|
|
||||||
attributes[5] = 8;
|
|
||||||
attributes[6] = WGL_ALPHA_BITS_ARB;
|
|
||||||
attributes[7] = 8;
|
|
||||||
attributes[8] = WGL_DEPTH_BITS_ARB;
|
|
||||||
attributes[9] = 24;
|
|
||||||
attributes[10] = WGL_STENCIL_BITS_ARB;
|
|
||||||
attributes[11] = 8;
|
|
||||||
|
|
||||||
attributes[12] = WGL_DRAW_TO_WINDOW_ARB; //required to be true
|
if (multisample > 0)
|
||||||
attributes[13] = true;
|
{
|
||||||
attributes[14] = WGL_SUPPORT_OPENGL_ARB;
|
attributes[20] = WGL_SAMPLE_BUFFERS_ARB;
|
||||||
attributes[15] = true;
|
attributes[21] = true;
|
||||||
attributes[16] = WGL_DOUBLE_BUFFER_ARB;
|
attributes[22] = WGL_SAMPLES_ARB;
|
||||||
attributes[17] = true;
|
attributes[23] = multisample;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
attributes[20] = 0;
|
||||||
|
attributes[21] = 0;
|
||||||
|
attributes[22] = 0;
|
||||||
|
attributes[23] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
attributes[18] = WGL_ACCELERATION_ARB; //required to be FULL_ACCELERATION_ARB
|
attributes[24] = 0;
|
||||||
if (allowsoftware)
|
attributes[25] = 0;
|
||||||
{
|
|
||||||
attributes[19] = WGL_NO_ACCELERATION_ARB;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
attributes[19] = WGL_FULL_ACCELERATION_ARB;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (multisample > 0)
|
if (!wglChoosePixelFormatARB(m_hDC, attributes, attribsFloat, 1, &pixelFormat, &numFormats))
|
||||||
{
|
{
|
||||||
attributes[20] = WGL_SAMPLE_BUFFERS_ARB;
|
Printf("R_OPENGL: Couldn't choose pixel format. Retrying in compatibility mode\n");
|
||||||
attributes[21] = true;
|
goto oldmethod;
|
||||||
attributes[22] = WGL_SAMPLES_ARB;
|
}
|
||||||
attributes[23] = multisample;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
attributes[20] = 0;
|
|
||||||
attributes[21] = 0;
|
|
||||||
attributes[22] = 0;
|
|
||||||
attributes[23] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
attributes[24] = 0;
|
if (numFormats == 0)
|
||||||
attributes[25] = 0;
|
{
|
||||||
|
Printf("R_OPENGL: No valid pixel formats found. Retrying in compatibility mode\n");
|
||||||
if (!wglChoosePixelFormatARB(m_hDC, attributes, attribsFloat, 1, &pixelFormat, &numFormats))
|
goto oldmethod;
|
||||||
{
|
|
||||||
Printf("R_OPENGL: Couldn't choose pixel format. Retrying in compatibility mode\n");
|
|
||||||
goto oldmethod;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (numFormats == 0)
|
|
||||||
{
|
|
||||||
Printf("R_OPENGL: No valid pixel formats found. Retrying in compatibility mode\n");
|
|
||||||
goto oldmethod;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
oldmethod:
|
|
||||||
// If wglChoosePixelFormatARB is not found we have to do it the old fashioned way.
|
|
||||||
static PIXELFORMATDESCRIPTOR pfd = {
|
|
||||||
sizeof(PIXELFORMATDESCRIPTOR),
|
|
||||||
1,
|
|
||||||
PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
|
|
||||||
PFD_TYPE_RGBA,
|
|
||||||
32, // color depth
|
|
||||||
0, 0, 0, 0, 0, 0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0, 0, 0, 0,
|
|
||||||
32, // z depth
|
|
||||||
stencil*8, // stencil buffer
|
|
||||||
0,
|
|
||||||
PFD_MAIN_PLANE,
|
|
||||||
0,
|
|
||||||
0, 0, 0
|
|
||||||
};
|
|
||||||
|
|
||||||
pixelFormat = ChoosePixelFormat(m_hDC, &pfd);
|
|
||||||
DescribePixelFormat(m_hDC, pixelFormat, sizeof(pfd), &pfd);
|
|
||||||
|
|
||||||
if (pfd.dwFlags & PFD_GENERIC_FORMAT)
|
|
||||||
{
|
|
||||||
if (!allowsoftware)
|
|
||||||
{
|
|
||||||
if (stencil==0)
|
|
||||||
{
|
|
||||||
// not accelerated!
|
|
||||||
Printf("R_OPENGL: OpenGL driver not accelerated! Falling back to software renderer.\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Printf("R_OPENGL: OpenGL driver not accelerated! Retrying in compatibility mode\n");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Use the cheapest mode available and let's hope the driver can handle this...
|
oldmethod:
|
||||||
stencil=0;
|
|
||||||
|
|
||||||
// If wglChoosePixelFormatARB is not found we have to do it the old fashioned way.
|
// If wglChoosePixelFormatARB is not found we have to do it the old fashioned way.
|
||||||
static PIXELFORMATDESCRIPTOR pfd = {
|
static PIXELFORMATDESCRIPTOR pfd = {
|
||||||
sizeof(PIXELFORMATDESCRIPTOR),
|
sizeof(PIXELFORMATDESCRIPTOR),
|
||||||
1,
|
1,
|
||||||
PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
|
PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
|
||||||
PFD_TYPE_RGBA,
|
PFD_TYPE_RGBA,
|
||||||
16, // color depth
|
32, // color depth
|
||||||
0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0, 0, 0, 0,
|
0, 0, 0, 0,
|
||||||
16, // z depth
|
32, // z depth
|
||||||
0, // stencil buffer
|
8, // stencil buffer
|
||||||
0,
|
0,
|
||||||
PFD_MAIN_PLANE,
|
PFD_MAIN_PLANE,
|
||||||
0,
|
0,
|
||||||
|
@ -773,15 +704,11 @@ bool Win32GLVideo::SetupPixelFormat(bool allowsoftware, bool nostencil, int mult
|
||||||
{
|
{
|
||||||
if (!allowsoftware)
|
if (!allowsoftware)
|
||||||
{
|
{
|
||||||
Printf("R_OPENGL: OpenGL driver not accelerated! Falling back to software renderer.\n");
|
Printf("R_OPENGL: OpenGL driver not accelerated! Falling back to software renderer.\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (stencil==0)
|
|
||||||
{
|
|
||||||
gl.flags|=RFL_NOSTENCIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!::SetPixelFormat(m_hDC, pixelFormat, NULL))
|
if (!::SetPixelFormat(m_hDC, pixelFormat, NULL))
|
||||||
{
|
{
|
||||||
|
@ -797,12 +724,12 @@ bool Win32GLVideo::SetupPixelFormat(bool allowsoftware, bool nostencil, int mult
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
bool Win32GLVideo::InitHardware (HWND Window, bool allowsoftware, bool nostencil, int multisample)
|
bool Win32GLVideo::InitHardware (HWND Window, bool allowsoftware, int multisample)
|
||||||
{
|
{
|
||||||
m_Window=Window;
|
m_Window=Window;
|
||||||
m_hDC = GetDC(Window);
|
m_hDC = GetDC(Window);
|
||||||
|
|
||||||
if (!SetupPixelFormat(allowsoftware, nostencil, multisample))
|
if (!SetupPixelFormat(allowsoftware, multisample))
|
||||||
{
|
{
|
||||||
Printf ("R_OPENGL: Reverting to software mode...\n");
|
Printf ("R_OPENGL: Reverting to software mode...\n");
|
||||||
return false;
|
return false;
|
||||||
|
@ -965,7 +892,7 @@ Win32GLFrameBuffer::Win32GLFrameBuffer(void *hMonitor, int width, int height, in
|
||||||
I_RestoreWindowedPos();
|
I_RestoreWindowedPos();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!static_cast<Win32GLVideo *>(Video)->InitHardware(Window, false, gl_vid_compatibility, localmultisample))
|
if (!static_cast<Win32GLVideo *>(Video)->InitHardware(Window, false, localmultisample))
|
||||||
{
|
{
|
||||||
vid_renderer = 0;
|
vid_renderer = 0;
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -42,7 +42,7 @@ public:
|
||||||
DFrameBuffer *CreateFrameBuffer (int width, int height, bool fs, DFrameBuffer *old);
|
DFrameBuffer *CreateFrameBuffer (int width, int height, bool fs, DFrameBuffer *old);
|
||||||
virtual bool SetResolution (int width, int height, int bits);
|
virtual bool SetResolution (int width, int height, int bits);
|
||||||
void DumpAdapters();
|
void DumpAdapters();
|
||||||
bool InitHardware (HWND Window, bool allowsoftware, bool nostencil, int multisample);
|
bool InitHardware (HWND Window, bool allowsoftware, int multisample);
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
bool SetFullscreen(const char *devicename, int w, int h, int bits, int hz);
|
bool SetFullscreen(const char *devicename, int w, int h, int bits, int hz);
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ protected:
|
||||||
HWND InitDummy();
|
HWND InitDummy();
|
||||||
void ShutdownDummy(HWND dummy);
|
void ShutdownDummy(HWND dummy);
|
||||||
bool SetPixelFormat();
|
bool SetPixelFormat();
|
||||||
bool SetupPixelFormat(bool allowsoftware, bool nostencil, int multisample);
|
bool SetupPixelFormat(bool allowsoftware, int multisample);
|
||||||
|
|
||||||
void GetDisplayDeviceName();
|
void GetDisplayDeviceName();
|
||||||
void MakeModesList();
|
void MakeModesList();
|
||||||
|
|
Loading…
Reference in a new issue