mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2025-02-21 10:51:25 +00:00
- GZDoom now runs on an OpenGL core profile. :)
It's probably still necessary to replace GLEW with another loader library. GLEW is pretty much broken on core OpenGL without some hacky workarounds...
This commit is contained in:
parent
6046b11b4f
commit
fc0cf4f998
6 changed files with 45 additions and 51 deletions
|
@ -121,6 +121,7 @@ void OpenGLFrameBuffer::InitializeState()
|
||||||
|
|
||||||
if (first)
|
if (first)
|
||||||
{
|
{
|
||||||
|
glewExperimental=TRUE;
|
||||||
glewInit();
|
glewInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +141,6 @@ void OpenGLFrameBuffer::InitializeState()
|
||||||
glDepthFunc(GL_LESS);
|
glDepthFunc(GL_LESS);
|
||||||
|
|
||||||
glEnable(GL_DITHER);
|
glEnable(GL_DITHER);
|
||||||
glEnable(GL_ALPHA_TEST);
|
|
||||||
glDisable(GL_CULL_FACE);
|
glDisable(GL_CULL_FACE);
|
||||||
glDisable(GL_POLYGON_OFFSET_FILL);
|
glDisable(GL_POLYGON_OFFSET_FILL);
|
||||||
glEnable(GL_POLYGON_OFFSET_LINE);
|
glEnable(GL_POLYGON_OFFSET_LINE);
|
||||||
|
|
|
@ -61,24 +61,15 @@ int occlusion_type=0;
|
||||||
|
|
||||||
static void CollectExtensions()
|
static void CollectExtensions()
|
||||||
{
|
{
|
||||||
const char *supported = NULL;
|
const char *extension;
|
||||||
char *extensions, *extension;
|
|
||||||
|
|
||||||
supported = (char *)glGetString(GL_EXTENSIONS);
|
int max = 0;
|
||||||
|
glGetIntegerv(GL_NUM_EXTENSIONS, &max);
|
||||||
|
|
||||||
if (supported)
|
for(int i = 0; i < max; i++)
|
||||||
{
|
{
|
||||||
extensions = new char[strlen(supported) + 1];
|
extension = (const char*)glGetStringi(GL_EXTENSIONS, i);
|
||||||
strcpy(extensions, supported);
|
m_Extensions.Push(FString(extension));
|
||||||
|
|
||||||
extension = strtok(extensions, " ");
|
|
||||||
while(extension)
|
|
||||||
{
|
|
||||||
m_Extensions.Push(FString(extension));
|
|
||||||
extension = strtok(NULL, " ");
|
|
||||||
}
|
|
||||||
|
|
||||||
delete [] extensions;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,14 +123,16 @@ void gl_LoadExtensions()
|
||||||
{
|
{
|
||||||
I_FatalError("Unsupported OpenGL version.\nAt least GL 3.0 is required to run " GAMENAME ".\n");
|
I_FatalError("Unsupported OpenGL version.\nAt least GL 3.0 is required to run " GAMENAME ".\n");
|
||||||
}
|
}
|
||||||
gl.version = strtod(version, NULL);
|
|
||||||
gl.glslversion = strtod((char*)glGetString(GL_SHADING_LANGUAGE_VERSION), NULL);
|
// add 0.01 to account for roundoff errors making the number a tad smaller than the actual version
|
||||||
|
gl.version = strtod(version, NULL) + 0.01f;
|
||||||
|
gl.glslversion = strtod((char*)glGetString(GL_SHADING_LANGUAGE_VERSION), NULL) + 0.01f;
|
||||||
|
|
||||||
gl.vendorstring=(char*)glGetString(GL_VENDOR);
|
gl.vendorstring=(char*)glGetString(GL_VENDOR);
|
||||||
|
|
||||||
if (CheckExtension("GL_ARB_texture_compression")) gl.flags|=RFL_TEXTURE_COMPRESSION;
|
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 (CheckExtension("GL_EXT_texture_compression_s3tc")) gl.flags|=RFL_TEXTURE_COMPRESSION_S3TC;
|
||||||
if (gl.version >= 4.f && CheckExtension("GL_ARB_buffer_storage")) gl.flags |= RFL_BUFFER_STORAGE;
|
if (CheckExtension("GL_ARB_buffer_storage")) gl.flags |= RFL_BUFFER_STORAGE;
|
||||||
|
|
||||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE,&gl.max_texturesize);
|
glGetIntegerv(GL_MAX_TEXTURE_SIZE,&gl.max_texturesize);
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||||
|
@ -157,11 +150,15 @@ void gl_PrintStartupLog()
|
||||||
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_SHADING_LANGUAGE_VERSION: %s\n", glGetString(GL_SHADING_LANGUAGE_VERSION));
|
||||||
Printf ("GL_EXTENSIONS: %s\n", glGetString(GL_EXTENSIONS));
|
Printf ("GL_EXTENSIONS:");
|
||||||
|
for (unsigned i = 0; i < m_Extensions.Size(); i++)
|
||||||
|
{
|
||||||
|
Printf(" %s", m_Extensions[i].GetChars());
|
||||||
|
}
|
||||||
int v;
|
int v;
|
||||||
|
|
||||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &v);
|
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &v);
|
||||||
Printf("Max. texture size: %d\n", v);
|
Printf("\nMax. texture size: %d\n", v);
|
||||||
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &v);
|
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &v);
|
||||||
Printf ("Max. texture units: %d\n", v);
|
Printf ("Max. texture units: %d\n", v);
|
||||||
glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &v);
|
glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &v);
|
||||||
|
|
|
@ -68,7 +68,6 @@
|
||||||
|
|
||||||
//GL headers
|
//GL headers
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
//#include "gl_load.h"
|
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
#include <OpenGL/OpenGL.h>
|
#include <OpenGL/OpenGL.h>
|
||||||
|
|
|
@ -610,7 +610,7 @@ bool Win32GLVideo::SetPixelFormat()
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
bool Win32GLVideo::SetupPixelFormat(bool allowsoftware, int multisample)
|
bool Win32GLVideo::SetupPixelFormat(int multisample)
|
||||||
{
|
{
|
||||||
int colorDepth;
|
int colorDepth;
|
||||||
HDC deskDC;
|
HDC deskDC;
|
||||||
|
@ -646,14 +646,7 @@ bool Win32GLVideo::SetupPixelFormat(bool allowsoftware, int multisample)
|
||||||
attributes[17] = true;
|
attributes[17] = true;
|
||||||
|
|
||||||
attributes[18] = WGL_ACCELERATION_ARB; //required to be FULL_ACCELERATION_ARB
|
attributes[18] = WGL_ACCELERATION_ARB; //required to be FULL_ACCELERATION_ARB
|
||||||
if (allowsoftware)
|
attributes[19] = WGL_FULL_ACCELERATION_ARB;
|
||||||
{
|
|
||||||
attributes[19] = WGL_NO_ACCELERATION_ARB;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
attributes[19] = WGL_FULL_ACCELERATION_ARB;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (multisample > 0)
|
if (multisample > 0)
|
||||||
{
|
{
|
||||||
|
@ -713,11 +706,8 @@ bool Win32GLVideo::SetupPixelFormat(bool allowsoftware, int multisample)
|
||||||
|
|
||||||
if (pfd.dwFlags & PFD_GENERIC_FORMAT)
|
if (pfd.dwFlags & PFD_GENERIC_FORMAT)
|
||||||
{
|
{
|
||||||
if (!allowsoftware)
|
Printf("R_OPENGL: OpenGL driver not accelerated! Falling back to software renderer.\n");
|
||||||
{
|
return false;
|
||||||
Printf("R_OPENGL: OpenGL driver not accelerated! Falling back to software renderer.\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -735,32 +725,40 @@ bool Win32GLVideo::SetupPixelFormat(bool allowsoftware, int multisample)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
bool Win32GLVideo::InitHardware (HWND Window, bool allowsoftware, int multisample)
|
bool Win32GLVideo::InitHardware (HWND Window, int multisample)
|
||||||
{
|
{
|
||||||
m_Window=Window;
|
m_Window=Window;
|
||||||
m_hDC = GetDC(Window);
|
m_hDC = GetDC(Window);
|
||||||
|
|
||||||
if (!SetupPixelFormat(allowsoftware, multisample))
|
if (!SetupPixelFormat(multisample))
|
||||||
{
|
{
|
||||||
Printf ("R_OPENGL: Reverting to software mode...\n");
|
Printf ("R_OPENGL: Reverting to software mode...\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_hRC = 0;
|
m_hRC = NULL;
|
||||||
if (myWglCreateContextAttribsARB != NULL)
|
if (myWglCreateContextAttribsARB != NULL)
|
||||||
{
|
{
|
||||||
int ctxAttribs[] = {
|
// let's try to get the best version possible.
|
||||||
WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
|
static int versions[] = { 44, 43, 42, 41, 40, 33, 32, -1 };
|
||||||
WGL_CONTEXT_MINOR_VERSION_ARB, 3,
|
|
||||||
WGL_CONTEXT_FLAGS_ARB, gl_debug? WGL_CONTEXT_DEBUG_BIT_ARB : 0,
|
|
||||||
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB,
|
|
||||||
0
|
|
||||||
};
|
|
||||||
|
|
||||||
m_hRC = myWglCreateContextAttribsARB(m_hDC, 0, ctxAttribs);
|
for (int i = 0; versions[i] > 0; i++)
|
||||||
|
{
|
||||||
|
int ctxAttribs[] = {
|
||||||
|
WGL_CONTEXT_MAJOR_VERSION_ARB, versions[i] / 10,
|
||||||
|
WGL_CONTEXT_MINOR_VERSION_ARB, versions[i] % 10,
|
||||||
|
WGL_CONTEXT_FLAGS_ARB, gl_debug ? WGL_CONTEXT_DEBUG_BIT_ARB : 0,
|
||||||
|
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
m_hRC = myWglCreateContextAttribsARB(m_hDC, 0, ctxAttribs);
|
||||||
|
if (m_hRC != NULL) break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (m_hRC == 0)
|
if (m_hRC == 0)
|
||||||
{
|
{
|
||||||
|
// If we are unable to get a core context, let's try whatever the system gives us.
|
||||||
m_hRC = wglCreateContext(m_hDC);
|
m_hRC = wglCreateContext(m_hDC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -903,7 +901,7 @@ Win32GLFrameBuffer::Win32GLFrameBuffer(void *hMonitor, int width, int height, in
|
||||||
I_RestoreWindowedPos();
|
I_RestoreWindowedPos();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!static_cast<Win32GLVideo *>(Video)->InitHardware(Window, false, localmultisample))
|
if (!static_cast<Win32GLVideo *>(Video)->InitHardware(Window, 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, int multisample);
|
bool InitHardware (HWND Window, 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);
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ protected:
|
||||||
HWND InitDummy();
|
HWND InitDummy();
|
||||||
void ShutdownDummy(HWND dummy);
|
void ShutdownDummy(HWND dummy);
|
||||||
bool SetPixelFormat();
|
bool SetPixelFormat();
|
||||||
bool SetupPixelFormat(bool allowsoftware, int multisample);
|
bool SetupPixelFormat(int multisample);
|
||||||
|
|
||||||
void GetDisplayDeviceName();
|
void GetDisplayDeviceName();
|
||||||
void MakeModesList();
|
void MakeModesList();
|
||||||
|
|
|
@ -22,7 +22,7 @@ void main()
|
||||||
|
|
||||||
#ifdef UNIFORM_VB
|
#ifdef UNIFORM_VB
|
||||||
|
|
||||||
if (gl_MultiTexCoord0.x >= 100000.0)
|
if (aTexCoord.x >= 100000.0)
|
||||||
{
|
{
|
||||||
int fakeVI = int(aTexCoord.y)*5;
|
int fakeVI = int(aTexCoord.y)*5;
|
||||||
vert = aPosition + vec4(fakeVB[fakeVI], fakeVB[fakeVI+1], fakeVB[fakeVI+2], 0.0);
|
vert = aPosition + vec4(fakeVB[fakeVI], fakeVB[fakeVI+1], fakeVB[fakeVI+2], 0.0);
|
||||||
|
|
Loading…
Reference in a new issue