mirror of
https://github.com/leozide/leocad
synced 2025-01-13 08:01:38 +01:00
QGLWidget cleanup.
This commit is contained in:
parent
ab9df4a712
commit
dbb4c9e44b
21 changed files with 18 additions and 12792 deletions
|
@ -759,14 +759,10 @@ lcStartupMode lcApplication::Initialize(QList<QPair<QString, bool>>& LibraryPath
|
|||
return lcStartupMode::Error;
|
||||
}
|
||||
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
if (!InitializeRenderer(AASamples))
|
||||
return lcStartupMode::Error;
|
||||
#endif
|
||||
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
if (!SaveAndExit)
|
||||
#endif
|
||||
{
|
||||
gMainWindow = new lcMainWindow();
|
||||
lcLoadDefaultKeyboardShortcuts();
|
||||
|
@ -788,12 +784,8 @@ lcStartupMode lcApplication::Initialize(QList<QPair<QString, bool>>& LibraryPath
|
|||
fprintf(stderr, "%s", Message.toLatin1().constData());
|
||||
}
|
||||
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
if (!SaveAndExit)
|
||||
#endif
|
||||
{
|
||||
gMainWindow->CreateWidgets();
|
||||
}
|
||||
|
||||
Project* NewProject = new Project();
|
||||
SetProject(NewProject);
|
||||
|
@ -828,7 +820,6 @@ lcStartupMode lcApplication::Initialize(QList<QPair<QString, bool>>& LibraryPath
|
|||
if (!ModelName.isEmpty())
|
||||
mProject->SetActiveModel(ModelName);
|
||||
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
std::unique_ptr<lcView> ActiveView;
|
||||
|
||||
if (SaveImage)
|
||||
|
@ -853,9 +844,6 @@ lcStartupMode lcApplication::Initialize(QList<QPair<QString, bool>>& LibraryPath
|
|||
ActiveView->SetOffscreenContext();
|
||||
ActiveView->MakeCurrent();
|
||||
}
|
||||
#else
|
||||
lcView* ActiveView = gMainWindow->GetActiveView();
|
||||
#endif
|
||||
|
||||
if (SaveImage)
|
||||
ActiveView->SetSize(ImageWidth, ImageHeight);
|
||||
|
@ -919,16 +907,7 @@ lcStartupMode lcApplication::Initialize(QList<QPair<QString, bool>>& LibraryPath
|
|||
|
||||
if (SaveImage)
|
||||
{
|
||||
lcModel* ActiveModel;
|
||||
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
ActiveModel = ActiveView->GetModel();
|
||||
#else
|
||||
if (ModelName.isEmpty())
|
||||
ActiveModel = mProject->GetMainModel();
|
||||
else
|
||||
ActiveModel = mProject->GetActiveModel();
|
||||
#endif
|
||||
lcModel* ActiveModel = ActiveView->GetModel();
|
||||
|
||||
if (ImageName.isEmpty())
|
||||
ImageName = mProject->GetImageFileName(true);
|
||||
|
@ -968,14 +947,10 @@ lcStartupMode lcApplication::Initialize(QList<QPair<QString, bool>>& LibraryPath
|
|||
if (SetHighlightColor)
|
||||
mPreferences.mHighlightNewPartsColor = HighlightColor;
|
||||
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
if (CameraName.isEmpty() && !SetCameraPosition)
|
||||
ActiveView->ZoomExtents();
|
||||
|
||||
ActiveView->SaveStepImages(Frame, ImageStart != ImageEnd, ImageStart, ImageEnd);
|
||||
#else
|
||||
ActiveModel->SaveStepImages(Frame, ImageStart != ImageEnd, CameraName.isEmpty() && !SetCameraPosition, ImageWidth, ImageHeight, ImageStart, ImageEnd);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (SaveWavefront)
|
||||
|
@ -1090,31 +1065,20 @@ bool lcApplication::InitializeRenderer(int AASamples)
|
|||
{
|
||||
if (AASamples > 1)
|
||||
{
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
QSurfaceFormat Format = QSurfaceFormat::defaultFormat();
|
||||
Format.setSamples(AASamples);
|
||||
QSurfaceFormat::setDefaultFormat(Format);
|
||||
#else
|
||||
QGLFormat Format;
|
||||
Format.setSampleBuffers(true);
|
||||
Format.setSamples(AASamples);
|
||||
QGLFormat::setDefaultFormat(Format);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
if (!lcContext::CreateOffscreenContext())
|
||||
return false;
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void lcApplication::ShutdownRenderer()
|
||||
{
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
lcContext::DestroyOffscreenContext();
|
||||
#endif
|
||||
}
|
||||
|
||||
void lcApplication::ShowPreferencesDialog()
|
||||
|
|
|
@ -136,13 +136,6 @@ const lcCommand gCommands[] =
|
|||
QT_TRANSLATE_NOOP("Status", "Display how the model would look if printed"),
|
||||
""
|
||||
},
|
||||
// LC_FILE_PRINT_BOM
|
||||
{
|
||||
QT_TRANSLATE_NOOP("Action", "File.PrintBOM"),
|
||||
QT_TRANSLATE_NOOP("Menu", "Print &Bill of Materials..."),
|
||||
QT_TRANSLATE_NOOP("Status", "Print a list of parts used"),
|
||||
""
|
||||
},
|
||||
// LC_FILE_RECENT1
|
||||
{
|
||||
QT_TRANSLATE_NOOP("Action", "File.Recent1"),
|
||||
|
|
|
@ -21,7 +21,6 @@ enum lcCommandId
|
|||
LC_FILE_INSTRUCTIONS,
|
||||
LC_FILE_PRINT,
|
||||
LC_FILE_PRINT_PREVIEW,
|
||||
LC_FILE_PRINT_BOM,
|
||||
LC_FILE_RECENT_FIRST,
|
||||
LC_FILE_RECENT1 = LC_FILE_RECENT_FIRST,
|
||||
LC_FILE_RECENT2,
|
||||
|
|
|
@ -11,10 +11,7 @@
|
|||
#include "lc_viewsphere.h"
|
||||
#include "lc_stringcache.h"
|
||||
#include "lc_partselectionwidget.h"
|
||||
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
#include <QOpenGLFunctions_3_2_Core>
|
||||
#endif
|
||||
|
||||
#ifdef LC_OPENGLES
|
||||
#define glEnableClientState(...)
|
||||
|
@ -27,10 +24,8 @@
|
|||
#define GL_STATIC_DRAW_ARB GL_STATIC_DRAW
|
||||
#endif
|
||||
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
std::unique_ptr<QOpenGLContext> lcContext::mOffscreenContext;
|
||||
std::unique_ptr<QOffscreenSurface> lcContext::mOffscreenSurface;
|
||||
#endif
|
||||
lcProgram lcContext::mPrograms[static_cast<int>(lcMaterialType::Count)];
|
||||
int lcContext::mValidContexts;
|
||||
|
||||
|
@ -97,8 +92,6 @@ lcContext::~lcContext()
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
|
||||
bool lcContext::CreateOffscreenContext()
|
||||
{
|
||||
std::unique_ptr<QOpenGLContext> OffscreenContext(new QOpenGLContext());
|
||||
|
@ -136,8 +129,6 @@ void lcContext::DestroyOffscreenContext()
|
|||
mOffscreenContext.reset();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void lcContext::CreateShaderPrograms()
|
||||
{
|
||||
const char* ShaderPrefix =
|
||||
|
@ -304,25 +295,17 @@ void lcContext::MakeCurrent()
|
|||
{
|
||||
if (mWidget)
|
||||
mWidget->makeCurrent();
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
else
|
||||
mOffscreenContext->makeCurrent(mOffscreenSurface.get());
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
void lcContext::SetGLContext(QOpenGLContext* Context, QOpenGLWidget* Widget)
|
||||
#else
|
||||
void lcContext::SetGLContext(const QGLContext* Context, QGLWidget* Widget)
|
||||
#endif
|
||||
{
|
||||
mContext = Context;
|
||||
mWidget = Widget;
|
||||
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
MakeCurrent();
|
||||
initializeOpenGLFunctions();
|
||||
#endif
|
||||
|
||||
if (!mValidContexts)
|
||||
{
|
||||
|
@ -347,24 +330,15 @@ void lcContext::SetGLContext(const QGLContext* Context, QGLWidget* Widget)
|
|||
mValidContexts++;
|
||||
}
|
||||
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
|
||||
void lcContext::SetOffscreenContext()
|
||||
{
|
||||
SetGLContext(mOffscreenContext.get(), nullptr);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void lcContext::SetDefaultState()
|
||||
{
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
if (QSurfaceFormat::defaultFormat().samples() > 1)
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
#elif !defined(LC_OPENGLES)
|
||||
if (QGLFormat::defaultFormat().sampleBuffers() && QGLFormat::defaultFormat().samples() > 1)
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
#endif
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
|
@ -676,16 +650,7 @@ void lcContext::ClearFramebuffer()
|
|||
if (!mFramebufferObject)
|
||||
return;
|
||||
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, mContext->defaultFramebufferObject());
|
||||
#else
|
||||
if (gSupportsFramebufferObjectARB)
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
#if !defined(LC_OPENGLES) && !defined(LC_USE_QOPENGLWIDGET)
|
||||
else if (gSupportsFramebufferObjectEXT)
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
mFramebufferObject = 0;
|
||||
}
|
||||
|
@ -694,17 +659,9 @@ lcFramebuffer lcContext::CreateFramebuffer(int Width, int Height, bool Depth, bo
|
|||
{
|
||||
lcFramebuffer Framebuffer(Width, Height);
|
||||
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
if (gSupportsFramebufferObject)
|
||||
#else
|
||||
if (gSupportsFramebufferObjectARB)
|
||||
#endif
|
||||
{
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
int Samples = (Multisample && gSupportsTexImage2DMultisample && QSurfaceFormat::defaultFormat().samples() > 1) ? QSurfaceFormat::defaultFormat().samples() : 1;
|
||||
#else
|
||||
int Samples = (Multisample && gSupportsTexImage2DMultisample && QGLFormat::defaultFormat().sampleBuffers()) ? QGLFormat::defaultFormat().samples() : 1;
|
||||
#endif
|
||||
|
||||
glGenFramebuffers(1, &Framebuffer.mObject);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, Framebuffer.mObject);
|
||||
|
@ -728,7 +685,6 @@ lcFramebuffer lcContext::CreateFramebuffer(int Width, int Height, bool Depth, bo
|
|||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, Framebuffer.mDepthRenderbuffer);
|
||||
}
|
||||
}
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
else
|
||||
{
|
||||
QOpenGLFunctions_3_2_Core* Funcs = mContext->versionFunctions<QOpenGLFunctions_3_2_Core>();
|
||||
|
@ -745,82 +701,24 @@ lcFramebuffer lcContext::CreateFramebuffer(int Width, int Height, bool Depth, bo
|
|||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, Framebuffer.mDepthRenderbuffer);
|
||||
}
|
||||
}
|
||||
#elif !defined(LC_OPENGLES)
|
||||
else
|
||||
{
|
||||
BindTexture2DMS(Framebuffer.mColorTexture);
|
||||
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, Samples, GL_RGBA, Width, Height, GL_TRUE);
|
||||
BindTexture2DMS(0);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, Framebuffer.mColorTexture, 0);
|
||||
|
||||
if (Depth)
|
||||
{
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, Framebuffer.mDepthRenderbuffer);
|
||||
glRenderbufferStorageMultisample(GL_RENDERBUFFER, Samples, GL_DEPTH_COMPONENT24, Width, Height);
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, Framebuffer.mDepthRenderbuffer);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
|
||||
DestroyFramebuffer(Framebuffer);
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, mFramebufferObject);
|
||||
}
|
||||
#if !defined(LC_OPENGLES) && !defined(LC_USE_QOPENGLWIDGET)
|
||||
else if (gSupportsFramebufferObjectEXT)
|
||||
{
|
||||
glGenFramebuffersEXT(1, &Framebuffer.mObject);
|
||||
glGenTextures(1, &Framebuffer.mColorTexture);
|
||||
|
||||
BindTexture2D(Framebuffer.mColorTexture);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, Width, Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
|
||||
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, Framebuffer.mObject);
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, Framebuffer.mColorTexture, 0);
|
||||
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, Framebuffer.mObject);
|
||||
|
||||
glGenRenderbuffersEXT(1, &Framebuffer.mDepthRenderbuffer);
|
||||
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, Framebuffer.mDepthRenderbuffer);
|
||||
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, Width, Height);
|
||||
|
||||
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, Framebuffer.mDepthRenderbuffer);
|
||||
|
||||
BindTexture2D(0);
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, Framebuffer.mObject);
|
||||
|
||||
if (glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT)
|
||||
DestroyFramebuffer(Framebuffer);
|
||||
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mFramebufferObject);
|
||||
}
|
||||
#endif
|
||||
|
||||
return Framebuffer;
|
||||
}
|
||||
|
||||
void lcContext::DestroyFramebuffer(lcFramebuffer& Framebuffer)
|
||||
{
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
if (gSupportsFramebufferObject)
|
||||
#else
|
||||
if (gSupportsFramebufferObjectARB)
|
||||
#endif
|
||||
{
|
||||
glDeleteFramebuffers(1, &Framebuffer.mObject);
|
||||
glDeleteTextures(1, &Framebuffer.mColorTexture);
|
||||
glDeleteRenderbuffers(1, &Framebuffer.mDepthRenderbuffer);
|
||||
}
|
||||
#if !defined(LC_OPENGLES) && !defined(LC_USE_QOPENGLWIDGET)
|
||||
else if (gSupportsFramebufferObjectEXT)
|
||||
{
|
||||
glDeleteFramebuffersEXT(1, &Framebuffer.mObject);
|
||||
glDeleteTextures(1, &Framebuffer.mColorTexture);
|
||||
glDeleteRenderbuffersEXT(1, &Framebuffer.mDepthRenderbuffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
Framebuffer.mObject = 0;
|
||||
Framebuffer.mColorTexture = 0;
|
||||
|
@ -834,33 +732,17 @@ void lcContext::BindFramebuffer(GLuint FramebufferObject)
|
|||
if (FramebufferObject == mFramebufferObject)
|
||||
return;
|
||||
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, FramebufferObject);
|
||||
#else
|
||||
if (gSupportsFramebufferObjectARB)
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, FramebufferObject);
|
||||
#ifndef LC_OPENGLES
|
||||
else if (gSupportsFramebufferObjectEXT)
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, FramebufferObject);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
mFramebufferObject = FramebufferObject;
|
||||
}
|
||||
|
||||
std::pair<lcFramebuffer, lcFramebuffer> lcContext::CreateRenderFramebuffer(int Width, int Height)
|
||||
{
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
if (gSupportsFramebufferObject && gSupportsTexImage2DMultisample && QSurfaceFormat::defaultFormat().samples() > 1)
|
||||
return std::make_pair(CreateFramebuffer(Width, Height, true, true), CreateFramebuffer(Width, Height, false, false));
|
||||
else
|
||||
return std::make_pair(CreateFramebuffer(Width, Height, true, false), lcFramebuffer());
|
||||
#else
|
||||
if (gSupportsFramebufferObjectARB && gSupportsTexImage2DMultisample && QGLFormat::defaultFormat().sampleBuffers() && QGLFormat::defaultFormat().samples() > 1)
|
||||
return std::make_pair(CreateFramebuffer(Width, Height, true, true), CreateFramebuffer(Width, Height, false, false));
|
||||
else
|
||||
return std::make_pair(CreateFramebuffer(Width, Height, true, false), lcFramebuffer());
|
||||
#endif
|
||||
}
|
||||
|
||||
void lcContext::DestroyRenderFramebuffer(std::pair<lcFramebuffer, lcFramebuffer>& RenderFramebuffer)
|
||||
|
@ -890,12 +772,8 @@ void lcContext::GetRenderFramebufferImage(const std::pair<lcFramebuffer, lcFrame
|
|||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, RenderFramebuffer.second.mObject);
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, RenderFramebuffer.first.mObject);
|
||||
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
QOpenGLFunctions_3_2_Core* Funcs = mContext->versionFunctions<QOpenGLFunctions_3_2_Core>();
|
||||
Funcs->glBlitFramebuffer(0, 0, Width, Height, 0, 0, Width, Height, GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||
#else
|
||||
glBlitFramebuffer(0, 0, Width, Height, 0, 0, Width, Height, GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||
#endif
|
||||
|
||||
BindFramebuffer(RenderFramebuffer.second);
|
||||
#endif
|
||||
|
|
|
@ -107,11 +107,7 @@ enum class lcPolygonOffset
|
|||
Translucent
|
||||
};
|
||||
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
class lcContext : protected QOpenGLFunctions
|
||||
#else
|
||||
class lcContext
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
lcContext();
|
||||
|
@ -120,10 +116,8 @@ public:
|
|||
lcContext(const lcContext&) = delete;
|
||||
lcContext& operator=(const lcContext&) = delete;
|
||||
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
static bool CreateOffscreenContext();
|
||||
static void DestroyOffscreenContext();
|
||||
#endif
|
||||
|
||||
void CreateResources();
|
||||
void DestroyResources();
|
||||
|
@ -132,12 +126,9 @@ public:
|
|||
void ClearResources();
|
||||
|
||||
void MakeCurrent();
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
|
||||
void SetGLContext(QOpenGLContext* GLContext, QOpenGLWidget* Widget);
|
||||
void SetOffscreenContext();
|
||||
#else
|
||||
void SetGLContext(const QGLContext* GLContext, QGLWidget* Widget);
|
||||
#endif
|
||||
|
||||
void ClearColorAndDepth(const lcVector4& ClearColor);
|
||||
void ClearDepth();
|
||||
|
@ -240,13 +231,8 @@ protected:
|
|||
void CreateShaderPrograms();
|
||||
void FlushState();
|
||||
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
QOpenGLWidget* mWidget = nullptr;
|
||||
QOpenGLContext* mContext = nullptr;
|
||||
#else
|
||||
QGLWidget* mWidget = nullptr;
|
||||
const QGLContext* mContext = nullptr;
|
||||
#endif
|
||||
bool mValid = false;
|
||||
|
||||
GLuint mVertexBufferObject;
|
||||
|
@ -284,10 +270,8 @@ protected:
|
|||
|
||||
GLuint mFramebufferObject;
|
||||
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
static std::unique_ptr<QOpenGLContext> mOffscreenContext;
|
||||
static std::unique_ptr<QOffscreenSurface> mOffscreenSurface;
|
||||
#endif
|
||||
|
||||
static lcProgram mPrograms[static_cast<int>(lcMaterialType::Count)];
|
||||
static int mValidContexts;
|
||||
|
|
11847
common/lc_glext.h
11847
common/lc_glext.h
File diff suppressed because it is too large
Load diff
|
@ -1,130 +1,15 @@
|
|||
#include "lc_global.h"
|
||||
#include "lc_glextensions.h"
|
||||
#include <QOpenGLFunctions_3_2_Core>
|
||||
|
||||
bool gSupportsShaderObjects;
|
||||
bool gSupportsVertexBufferObject;
|
||||
bool gSupportsFramebufferObject;
|
||||
#ifndef LC_USE_QOPENGLWIDGET
|
||||
bool gSupportsFramebufferObjectARB;
|
||||
bool gSupportsFramebufferObjectEXT;
|
||||
#endif
|
||||
bool gSupportsTexImage2DMultisample;
|
||||
bool gSupportsBlendFuncSeparate;
|
||||
bool gSupportsAnisotropic;
|
||||
GLfloat gMaxAnisotropy;
|
||||
|
||||
#ifdef LC_LOAD_GLEXTENSIONS
|
||||
|
||||
PFNGLBINDBUFFERARBPROC lcBindBufferARB;
|
||||
PFNGLDELETEBUFFERSARBPROC lcDeleteBuffersARB;
|
||||
PFNGLGENBUFFERSARBPROC lcGenBuffersARB;
|
||||
PFNGLISBUFFERARBPROC lcIsBufferARB;
|
||||
PFNGLBUFFERDATAARBPROC lcBufferDataARB;
|
||||
PFNGLBUFFERSUBDATAARBPROC lcBufferSubDataARB;
|
||||
PFNGLGETBUFFERSUBDATAARBPROC lcGetBufferSubDataARB;
|
||||
PFNGLMAPBUFFERARBPROC lcMapBufferARB;
|
||||
PFNGLUNMAPBUFFERARBPROC lcUnmapBufferARB;
|
||||
PFNGLGETBUFFERPARAMETERIVARBPROC lcGetBufferParameterivARB;
|
||||
PFNGLGETBUFFERPOINTERVARBPROC lcGetBufferPointervARB;
|
||||
|
||||
PFNGLISRENDERBUFFERPROC lcIsRenderbuffer;
|
||||
PFNGLBINDRENDERBUFFERPROC lcBindRenderbuffer;
|
||||
PFNGLDELETERENDERBUFFERSPROC lcDeleteRenderbuffers;
|
||||
PFNGLGENRENDERBUFFERSPROC lcGenRenderbuffers;
|
||||
PFNGLRENDERBUFFERSTORAGEPROC lcRenderbufferStorage;
|
||||
PFNGLGETRENDERBUFFERPARAMETERIVPROC lcGetRenderbufferParameteriv;
|
||||
PFNGLISFRAMEBUFFERPROC lcIsFramebuffer;
|
||||
PFNGLBINDFRAMEBUFFERPROC lcBindFramebuffer;
|
||||
PFNGLDELETEFRAMEBUFFERSPROC lcDeleteFramebuffers;
|
||||
PFNGLGENFRAMEBUFFERSPROC lcGenFramebuffers;
|
||||
PFNGLCHECKFRAMEBUFFERSTATUSPROC lcCheckFramebufferStatus;
|
||||
PFNGLFRAMEBUFFERTEXTURE1DPROC lcFramebufferTexture1D;
|
||||
PFNGLFRAMEBUFFERTEXTURE2DPROC lcFramebufferTexture2D;
|
||||
PFNGLFRAMEBUFFERTEXTURE3DPROC lcFramebufferTexture3D;
|
||||
PFNGLFRAMEBUFFERRENDERBUFFERPROC lcFramebufferRenderbuffer;
|
||||
PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC lcGetFramebufferAttachmentParameteriv;
|
||||
PFNGLGENERATEMIPMAPPROC lcGenerateMipmap;
|
||||
PFNGLBLITFRAMEBUFFERPROC lcBlitFramebuffer;
|
||||
PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC lcRenderbufferStorageMultisample;
|
||||
PFNGLFRAMEBUFFERTEXTURELAYERPROC lcFramebufferTextureLayer;
|
||||
|
||||
PFNGLISRENDERBUFFEREXTPROC lcIsRenderbufferEXT;
|
||||
PFNGLBINDRENDERBUFFEREXTPROC lcBindRenderbufferEXT;
|
||||
PFNGLDELETERENDERBUFFERSEXTPROC lcDeleteRenderbuffersEXT;
|
||||
PFNGLGENRENDERBUFFERSEXTPROC lcGenRenderbuffersEXT;
|
||||
PFNGLRENDERBUFFERSTORAGEEXTPROC lcRenderbufferStorageEXT;
|
||||
PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC lcGetRenderbufferParameterivEXT;
|
||||
PFNGLISFRAMEBUFFEREXTPROC lcIsFramebufferEXT;
|
||||
PFNGLBINDFRAMEBUFFEREXTPROC lcBindFramebufferEXT;
|
||||
PFNGLDELETEFRAMEBUFFERSEXTPROC lcDeleteFramebuffersEXT;
|
||||
PFNGLGENFRAMEBUFFERSEXTPROC lcGenFramebuffersEXT;
|
||||
PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC lcCheckFramebufferStatusEXT;
|
||||
PFNGLFRAMEBUFFERTEXTURE1DEXTPROC lcFramebufferTexture1DEXT;
|
||||
PFNGLFRAMEBUFFERTEXTURE2DEXTPROC lcFramebufferTexture2DEXT;
|
||||
PFNGLFRAMEBUFFERTEXTURE3DEXTPROC lcFramebufferTexture3DEXT;
|
||||
PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC lcFramebufferRenderbufferEXT;
|
||||
PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC lcGetFramebufferAttachmentParameterivEXT;
|
||||
PFNGLGENERATEMIPMAPEXTPROC lcGenerateMipmapEXT;
|
||||
|
||||
PFNGLATTACHSHADERPROC lcAttachShader;
|
||||
PFNGLBINDATTRIBLOCATIONPROC lcBindAttribLocation;
|
||||
PFNGLCOMPILESHADERPROC lcCompileShader;
|
||||
PFNGLCREATEPROGRAMPROC lcCreateProgram;
|
||||
PFNGLCREATESHADERPROC lcCreateShader;
|
||||
PFNGLDELETEPROGRAMPROC lcDeleteProgram;
|
||||
PFNGLDELETESHADERPROC lcDeleteShader;
|
||||
PFNGLDETACHSHADERPROC lcDetachShader;
|
||||
PFNGLDISABLEVERTEXATTRIBARRAYPROC lcDisableVertexAttribArray;
|
||||
PFNGLENABLEVERTEXATTRIBARRAYPROC lcEnableVertexAttribArray;
|
||||
PFNGLGETACTIVEATTRIBPROC lcGetActiveAttrib;
|
||||
PFNGLGETACTIVEUNIFORMPROC lcGetActiveUniform;
|
||||
PFNGLGETATTACHEDSHADERSPROC lcGetAttachedShaders;
|
||||
PFNGLGETATTRIBLOCATIONPROC lcGetAttribLocation;
|
||||
PFNGLGETPROGRAMIVPROC lcGetProgramiv;
|
||||
PFNGLGETPROGRAMINFOLOGPROC lcGetProgramInfoLog;
|
||||
PFNGLGETSHADERIVPROC lcGetShaderiv;
|
||||
PFNGLGETSHADERINFOLOGPROC lcGetShaderInfoLog;
|
||||
PFNGLGETSHADERSOURCEPROC lcGetShaderSource;
|
||||
PFNGLGETUNIFORMLOCATIONPROC lcGetUniformLocation;
|
||||
PFNGLGETUNIFORMFVPROC lcGetUniformfv;
|
||||
PFNGLGETUNIFORMIVPROC lcGetUniformiv;
|
||||
PFNGLGETVERTEXATTRIBDVPROC lcGetVertexAttribdv;
|
||||
PFNGLGETVERTEXATTRIBFVPROC lcGetVertexAttribfv;
|
||||
PFNGLGETVERTEXATTRIBIVPROC lcGetVertexAttribiv;
|
||||
PFNGLGETVERTEXATTRIBPOINTERVPROC lcGetVertexAttribPointerv;
|
||||
PFNGLISPROGRAMPROC lcIsProgram;
|
||||
PFNGLISSHADERPROC lcIsShader;
|
||||
PFNGLLINKPROGRAMPROC lcLinkProgram;
|
||||
PFNGLSHADERSOURCEPROC lcShaderSource;
|
||||
PFNGLUSEPROGRAMPROC lcUseProgram;
|
||||
PFNGLUNIFORM1FPROC lcUniform1f;
|
||||
PFNGLUNIFORM2FPROC lcUniform2f;
|
||||
PFNGLUNIFORM3FPROC lcUniform3f;
|
||||
PFNGLUNIFORM4FPROC lcUniform4f;
|
||||
PFNGLUNIFORM1IPROC lcUniform1i;
|
||||
PFNGLUNIFORM2IPROC lcUniform2i;
|
||||
PFNGLUNIFORM3IPROC lcUniform3i;
|
||||
PFNGLUNIFORM4IPROC lcUniform4i;
|
||||
PFNGLUNIFORM1FVPROC lcUniform1fv;
|
||||
PFNGLUNIFORM2FVPROC lcUniform2fv;
|
||||
PFNGLUNIFORM3FVPROC lcUniform3fv;
|
||||
PFNGLUNIFORM4FVPROC lcUniform4fv;
|
||||
PFNGLUNIFORM1IVPROC lcUniform1iv;
|
||||
PFNGLUNIFORM2IVPROC lcUniform2iv;
|
||||
PFNGLUNIFORM3IVPROC lcUniform3iv;
|
||||
PFNGLUNIFORM4IVPROC lcUniform4iv;
|
||||
PFNGLUNIFORMMATRIX2FVPROC lcUniformMatrix2fv;
|
||||
PFNGLUNIFORMMATRIX3FVPROC lcUniformMatrix3fv;
|
||||
PFNGLUNIFORMMATRIX4FVPROC lcUniformMatrix4fv;
|
||||
PFNGLVALIDATEPROGRAMPROC lcValidateProgram;
|
||||
PFNGLVERTEXATTRIBPOINTERPROC lcVertexAttribPointer;
|
||||
|
||||
PFNGLTEXIMAGE2DMULTISAMPLEPROC lcTexImage2DMultisample;
|
||||
|
||||
PFNGLBLENDFUNCSEPARATEPROC lcBlendFuncSeparate;
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(QT_NO_DEBUG) && defined(GL_ARB_debug_output)
|
||||
|
||||
static void APIENTRY lcGLDebugCallback(GLenum Source, GLenum Type, GLuint Id, GLenum Severity, GLsizei Length, const GLchar* Message, GLvoid* UserParam)
|
||||
|
@ -141,10 +26,6 @@ static void APIENTRY lcGLDebugCallback(GLenum Source, GLenum Type, GLuint Id, GL
|
|||
|
||||
#endif
|
||||
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
|
||||
#include <QOpenGLFunctions_3_2_Core>
|
||||
|
||||
void lcInitializeGLExtensions(const QOpenGLContext* Context)
|
||||
{
|
||||
const QOpenGLFunctions* Functions = Context->functions();
|
||||
|
@ -184,245 +65,3 @@ void lcInitializeGLExtensions(const QOpenGLContext* Context)
|
|||
if (Funcs)
|
||||
gSupportsTexImage2DMultisample = true;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static bool lcIsGLExtensionSupported(const GLubyte* Extensions, const char* Name)
|
||||
{
|
||||
const GLubyte* Start;
|
||||
GLubyte* Where;
|
||||
GLubyte* Terminator;
|
||||
|
||||
Where = (GLubyte*)strchr(Name, ' ');
|
||||
if (Where || *Name == '\0')
|
||||
return false;
|
||||
|
||||
if (!Extensions)
|
||||
return false;
|
||||
|
||||
for (Start = Extensions; ;)
|
||||
{
|
||||
Where = (GLubyte*)strstr((const char*)Start, Name);
|
||||
if (!Where)
|
||||
break;
|
||||
|
||||
Terminator = Where + strlen(Name);
|
||||
if (Where == Start || *(Where - 1) == ' ')
|
||||
if (*Terminator == ' ' || *Terminator == '\0')
|
||||
return true;
|
||||
|
||||
Start = Terminator;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void lcInitializeGLExtensions(const QGLContext* Context)
|
||||
{
|
||||
const GLubyte* Extensions = glGetString(GL_EXTENSIONS);
|
||||
const GLubyte* Version = glGetString(GL_VERSION);
|
||||
int VersionMajor = 0, VersionMinor = 0;
|
||||
|
||||
if (Version)
|
||||
sscanf((const char*)Version, "%d.%d", &VersionMajor, &VersionMinor);
|
||||
|
||||
#if !defined(QT_NO_DEBUG) && defined(GL_ARB_debug_output)
|
||||
if (lcIsGLExtensionSupported(Extensions, "GL_KHR_debug"))
|
||||
{
|
||||
PFNGLDEBUGMESSAGECALLBACKARBPROC DebugMessageCallback = (PFNGLDEBUGMESSAGECALLBACKARBPROC)Context->getProcAddress("glDebugMessageCallback");
|
||||
|
||||
#ifndef GL_DEBUG_OUTPUT
|
||||
#define GL_DEBUG_OUTPUT 0x92E0
|
||||
#endif
|
||||
|
||||
if (DebugMessageCallback)
|
||||
{
|
||||
DebugMessageCallback((GLDEBUGPROCARB)&lcGLDebugCallback, nullptr);
|
||||
glEnable(GL_DEBUG_OUTPUT);
|
||||
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (lcIsGLExtensionSupported(Extensions, "GL_EXT_texture_filter_anisotropic"))
|
||||
{
|
||||
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &gMaxAnisotropy);
|
||||
|
||||
gSupportsAnisotropic = true;
|
||||
}
|
||||
|
||||
// todo: check gl version and use core functions instead
|
||||
if (lcIsGLExtensionSupported(Extensions, "GL_ARB_vertex_buffer_object"))
|
||||
{
|
||||
#ifdef LC_LOAD_GLEXTENSIONS
|
||||
lcBindBufferARB = (PFNGLBINDBUFFERARBPROC)Context->getProcAddress("glBindBufferARB");
|
||||
lcDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC)Context->getProcAddress("glDeleteBuffersARB");
|
||||
lcGenBuffersARB = (PFNGLGENBUFFERSARBPROC)Context->getProcAddress("glGenBuffersARB");
|
||||
lcIsBufferARB = (PFNGLISBUFFERARBPROC)Context->getProcAddress("glIsBufferARB");
|
||||
lcBufferDataARB = (PFNGLBUFFERDATAARBPROC)Context->getProcAddress("glBufferDataARB");
|
||||
lcBufferSubDataARB = (PFNGLBUFFERSUBDATAARBPROC)Context->getProcAddress("glBufferSubDataARB");
|
||||
lcGetBufferSubDataARB = (PFNGLGETBUFFERSUBDATAARBPROC)Context->getProcAddress("glGetBufferSubDataARB");
|
||||
lcMapBufferARB = (PFNGLMAPBUFFERARBPROC)Context->getProcAddress("glMapBufferARB");
|
||||
lcUnmapBufferARB = (PFNGLUNMAPBUFFERARBPROC)Context->getProcAddress("glUnmapBufferARB");
|
||||
lcGetBufferParameterivARB = (PFNGLGETBUFFERPARAMETERIVARBPROC)Context->getProcAddress("glGetBufferParameterivARB");
|
||||
lcGetBufferPointervARB = (PFNGLGETBUFFERPOINTERVARBPROC)Context->getProcAddress("glGetBufferPointervARB");
|
||||
#endif
|
||||
gSupportsVertexBufferObject = true;
|
||||
}
|
||||
|
||||
// todo: check gl version
|
||||
if (lcIsGLExtensionSupported(Extensions, "GL_ARB_framebuffer_object"))
|
||||
{
|
||||
#ifdef LC_LOAD_GLEXTENSIONS
|
||||
lcIsRenderbuffer = (PFNGLISRENDERBUFFERPROC)Context->getProcAddress("glIsRenderbuffer");
|
||||
lcBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)Context->getProcAddress("glBindRenderbuffer");
|
||||
lcDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)Context->getProcAddress("glDeleteRenderbuffers");
|
||||
lcGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)Context->getProcAddress("glGenRenderbuffers");
|
||||
lcRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)Context->getProcAddress("glRenderbufferStorage");
|
||||
lcGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC)Context->getProcAddress("glGetRenderbufferParameteriv");
|
||||
lcIsFramebuffer = (PFNGLISFRAMEBUFFERPROC)Context->getProcAddress("glIsFramebuffer");
|
||||
lcBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)Context->getProcAddress("glBindFramebuffer");
|
||||
lcDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)Context->getProcAddress("glDeleteFramebuffers");
|
||||
lcGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)Context->getProcAddress("glGenFramebuffers");
|
||||
lcCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)Context->getProcAddress("glCheckFramebufferStatus");
|
||||
lcFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC)Context->getProcAddress("glFramebufferTexture1D");
|
||||
lcFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)Context->getProcAddress("glFramebufferTexture2D");
|
||||
lcFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC)Context->getProcAddress("glFramebufferTexture3D");
|
||||
lcFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)Context->getProcAddress("glFramebufferRenderbuffer");
|
||||
lcGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)Context->getProcAddress("glGetFramebufferAttachmentParameteriv");
|
||||
lcGenerateMipmap = (PFNGLGENERATEMIPMAPPROC)Context->getProcAddress("glGenerateMipmap");
|
||||
lcBlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC)Context->getProcAddress("glBlitFramebuffer");
|
||||
lcRenderbufferStorageMultisample = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)Context->getProcAddress("glRenderbufferStorageMultisample");
|
||||
lcFramebufferTextureLayer = (PFNGLFRAMEBUFFERTEXTURELAYERARBPROC)Context->getProcAddress("glFramebufferTextureLayer");
|
||||
#endif
|
||||
gSupportsFramebufferObject = true;
|
||||
gSupportsFramebufferObjectARB = true;
|
||||
}
|
||||
|
||||
if (lcIsGLExtensionSupported(Extensions, "GL_EXT_framebuffer_object"))
|
||||
{
|
||||
#ifdef LC_LOAD_GLEXTENSIONS
|
||||
lcIsRenderbufferEXT = (PFNGLISRENDERBUFFEREXTPROC)Context->getProcAddress("glIsRenderbufferEXT");
|
||||
lcBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC)Context->getProcAddress("glBindRenderbufferEXT");
|
||||
lcDeleteRenderbuffersEXT = (PFNGLDELETERENDERBUFFERSEXTPROC)Context->getProcAddress("glDeleteRenderbuffersEXT");
|
||||
lcGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC)Context->getProcAddress("glGenRenderbuffersEXT");
|
||||
lcRenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC)Context->getProcAddress("glRenderbufferStorageEXT");
|
||||
lcGetRenderbufferParameterivEXT = (PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC)Context->getProcAddress("glGetRenderbufferParameterivEXT");
|
||||
lcIsFramebufferEXT = (PFNGLISFRAMEBUFFEREXTPROC)Context->getProcAddress("glIsFramebufferEXT");
|
||||
lcBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC)Context->getProcAddress("glBindFramebufferEXT");
|
||||
lcDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC)Context->getProcAddress("glDeleteFramebuffersEXT");
|
||||
lcGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC)Context->getProcAddress("glGenFramebuffersEXT");
|
||||
lcCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC)Context->getProcAddress("glCheckFramebufferStatusEXT");
|
||||
lcFramebufferTexture1DEXT = (PFNGLFRAMEBUFFERTEXTURE1DEXTPROC)Context->getProcAddress("glFramebufferTexture1DEXT");
|
||||
lcFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC)Context->getProcAddress("glFramebufferTexture2DEXT");
|
||||
lcFramebufferTexture3DEXT = (PFNGLFRAMEBUFFERTEXTURE3DEXTPROC)Context->getProcAddress("glFramebufferTexture3DEXT");
|
||||
lcFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC)Context->getProcAddress("glFramebufferRenderbufferEXT");
|
||||
lcGetFramebufferAttachmentParameterivEXT = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC)Context->getProcAddress("glGetFramebufferAttachmentParameterivEXT");
|
||||
lcGenerateMipmapEXT = (PFNGLGENERATEMIPMAPEXTPROC)Context->getProcAddress("glGenerateMipmapEXT");
|
||||
#endif
|
||||
gSupportsFramebufferObject = true;
|
||||
gSupportsFramebufferObjectEXT = true;
|
||||
}
|
||||
|
||||
if (lcIsGLExtensionSupported(Extensions, "GL_EXT_blend_func_separate"))
|
||||
{
|
||||
#ifdef LC_LOAD_GLEXTENSIONS
|
||||
lcBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC)Context->getProcAddress("glBlendFuncSeparateEXT");
|
||||
#endif
|
||||
|
||||
gSupportsBlendFuncSeparate = true;
|
||||
}
|
||||
|
||||
const GLubyte* GLSLVersion = glGetString(GL_SHADING_LANGUAGE_VERSION);
|
||||
int GLSLMajor = 0, GLSLMinor = 0;
|
||||
|
||||
if (GLSLVersion)
|
||||
sscanf((const char*)GLSLVersion, "%d.%d", &GLSLMajor, &GLSLMinor);
|
||||
|
||||
if (VersionMajor >= 2 && (GLSLMajor > 1 || (GLSLMajor == 1 && GLSLMinor >= 10)))
|
||||
{
|
||||
#ifdef LC_LOAD_GLEXTENSIONS
|
||||
lcAttachShader = (PFNGLATTACHSHADERPROC)Context->getProcAddress("glAttachShader");
|
||||
lcBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC)Context->getProcAddress("glBindAttribLocation");
|
||||
lcCompileShader = (PFNGLCOMPILESHADERPROC)Context->getProcAddress("glCompileShader");
|
||||
lcCreateProgram = (PFNGLCREATEPROGRAMPROC)Context->getProcAddress("glCreateProgram");
|
||||
lcCreateShader = (PFNGLCREATESHADERPROC)Context->getProcAddress("glCreateShader");
|
||||
lcDeleteProgram = (PFNGLDELETEPROGRAMPROC)Context->getProcAddress("glDeleteProgram");
|
||||
lcDeleteShader = (PFNGLDELETESHADERPROC)Context->getProcAddress("glDeleteShader");
|
||||
lcDetachShader = (PFNGLDETACHSHADERPROC)Context->getProcAddress("glDetachShader");
|
||||
lcDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC)Context->getProcAddress("glDisableVertexAttribArray");
|
||||
lcEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)Context->getProcAddress("glEnableVertexAttribArray");
|
||||
lcGetActiveAttrib = (PFNGLGETACTIVEATTRIBPROC)Context->getProcAddress("glGetActiveAttrib");
|
||||
lcGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC)Context->getProcAddress("glGetActiveUniform");
|
||||
lcGetAttachedShaders = (PFNGLGETATTACHEDSHADERSPROC)Context->getProcAddress("glGetAttachedShaders");
|
||||
lcGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)Context->getProcAddress("glGetAttribLocation");
|
||||
lcGetProgramiv = (PFNGLGETPROGRAMIVPROC)Context->getProcAddress("glGetProgramiv");
|
||||
lcGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)Context->getProcAddress("glGetProgramInfoLog");
|
||||
lcGetShaderiv = (PFNGLGETSHADERIVPROC)Context->getProcAddress("glGetShaderiv");
|
||||
lcGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)Context->getProcAddress("glGetShaderInfoLog");
|
||||
lcGetShaderSource = (PFNGLGETSHADERSOURCEPROC)Context->getProcAddress("glGetShaderSource");
|
||||
lcGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)Context->getProcAddress("glGetUniformLocation");
|
||||
lcGetUniformfv = (PFNGLGETUNIFORMFVPROC)Context->getProcAddress("glGetUniformfv");
|
||||
lcGetUniformiv = (PFNGLGETUNIFORMIVPROC)Context->getProcAddress("glGetUniformiv");
|
||||
lcGetVertexAttribdv = (PFNGLGETVERTEXATTRIBDVPROC)Context->getProcAddress("glGetVertexAttribdv");
|
||||
lcGetVertexAttribfv = (PFNGLGETVERTEXATTRIBFVPROC)Context->getProcAddress("glGetVertexAttribfv");
|
||||
lcGetVertexAttribiv = (PFNGLGETVERTEXATTRIBIVPROC)Context->getProcAddress("glGetVertexAttribiv");
|
||||
lcGetVertexAttribPointerv = (PFNGLGETVERTEXATTRIBPOINTERVPROC)Context->getProcAddress("glGetVertexAttribPointerv");
|
||||
lcIsProgram = (PFNGLISPROGRAMPROC)Context->getProcAddress("glIsProgram");
|
||||
lcIsShader = (PFNGLISSHADERPROC)Context->getProcAddress("glIsShader");
|
||||
lcLinkProgram = (PFNGLLINKPROGRAMPROC)Context->getProcAddress("glLinkProgram");
|
||||
lcShaderSource = (PFNGLSHADERSOURCEPROC)Context->getProcAddress("glShaderSource");
|
||||
lcUseProgram = (PFNGLUSEPROGRAMPROC)Context->getProcAddress("glUseProgram");
|
||||
lcUniform1f = (PFNGLUNIFORM1FPROC)Context->getProcAddress("glUniform1f");
|
||||
lcUniform2f = (PFNGLUNIFORM2FPROC)Context->getProcAddress("glUniform2f");
|
||||
lcUniform3f = (PFNGLUNIFORM3FPROC)Context->getProcAddress("glUniform3f");
|
||||
lcUniform4f = (PFNGLUNIFORM4FPROC)Context->getProcAddress("glUniform4f");
|
||||
lcUniform1i = (PFNGLUNIFORM1IPROC)Context->getProcAddress("glUniform1i");
|
||||
lcUniform2i = (PFNGLUNIFORM2IPROC)Context->getProcAddress("glUniform2i");
|
||||
lcUniform3i = (PFNGLUNIFORM3IPROC)Context->getProcAddress("glUniform3i");
|
||||
lcUniform4i = (PFNGLUNIFORM4IPROC)Context->getProcAddress("glUniform4i");
|
||||
lcUniform1fv = (PFNGLUNIFORM1FVPROC)Context->getProcAddress("glUniform1fv");
|
||||
lcUniform2fv = (PFNGLUNIFORM2FVPROC)Context->getProcAddress("glUniform2fv");
|
||||
lcUniform3fv = (PFNGLUNIFORM3FVPROC)Context->getProcAddress("glUniform3fv");
|
||||
lcUniform4fv = (PFNGLUNIFORM4FVPROC)Context->getProcAddress("glUniform4fv");
|
||||
lcUniform1iv = (PFNGLUNIFORM1IVPROC)Context->getProcAddress("glUniform1iv");
|
||||
lcUniform2iv = (PFNGLUNIFORM2IVPROC)Context->getProcAddress("glUniform2iv");
|
||||
lcUniform3iv = (PFNGLUNIFORM3IVPROC)Context->getProcAddress("glUniform3iv");
|
||||
lcUniform4iv = (PFNGLUNIFORM4IVPROC)Context->getProcAddress("glUniform4iv");
|
||||
lcUniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC)Context->getProcAddress("glUniformMatrix2fv");
|
||||
lcUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC)Context->getProcAddress("glUniformMatrix3fv");
|
||||
lcUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)Context->getProcAddress("glUniformMatrix4fv");
|
||||
lcValidateProgram = (PFNGLVALIDATEPROGRAMPROC)Context->getProcAddress("glValidateProgram");
|
||||
lcVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)Context->getProcAddress("glVertexAttribPointer");
|
||||
#endif
|
||||
gSupportsShaderObjects = true;
|
||||
}
|
||||
|
||||
#ifndef LC_OPENGLES
|
||||
if (VersionMajor > 3 || (VersionMajor == 3 && VersionMinor >= 2))
|
||||
{
|
||||
#ifdef LC_LOAD_GLEXTENSIONS
|
||||
lcTexImage2DMultisample = (PFNGLTEXIMAGE2DMULTISAMPLEPROC)Context->getProcAddress("glTexImage2DMultisample");
|
||||
#endif
|
||||
|
||||
gSupportsTexImage2DMultisample = true;
|
||||
}
|
||||
|
||||
if (VersionMajor >= 4)
|
||||
{
|
||||
#ifdef LC_LOAD_GLEXTENSIONS
|
||||
lcBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC)Context->getProcAddress("glBlendFuncSeparate");
|
||||
#endif
|
||||
|
||||
gSupportsBlendFuncSeparate = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef LC_OPENGLES
|
||||
gSupportsVertexBufferObject = true;
|
||||
gSupportsFramebufferObjectARB = true;
|
||||
gSupportsShaderObjects = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,243 +1,11 @@
|
|||
#pragma once
|
||||
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
void lcInitializeGLExtensions(const QOpenGLContext* Context);
|
||||
#else
|
||||
void lcInitializeGLExtensions(const QGLContext* Context);
|
||||
#endif
|
||||
|
||||
extern bool gSupportsShaderObjects;
|
||||
extern bool gSupportsVertexBufferObject;
|
||||
extern bool gSupportsFramebufferObject;
|
||||
#ifndef LC_USE_QOPENGLWIDGET
|
||||
extern bool gSupportsFramebufferObjectARB;
|
||||
extern bool gSupportsFramebufferObjectEXT;
|
||||
#endif
|
||||
extern bool gSupportsTexImage2DMultisample;
|
||||
extern bool gSupportsBlendFuncSeparate;
|
||||
extern bool gSupportsAnisotropic;
|
||||
extern GLfloat gMaxAnisotropy;
|
||||
|
||||
#if !defined(Q_OS_MAC) && !defined(QT_OPENGL_ES) && !defined(LC_USE_QOPENGLWIDGET)
|
||||
#define LC_LOAD_GLEXTENSIONS
|
||||
#endif
|
||||
|
||||
#ifdef LC_LOAD_GLEXTENSIONS
|
||||
|
||||
extern PFNGLBINDBUFFERARBPROC lcBindBufferARB;
|
||||
extern PFNGLDELETEBUFFERSARBPROC lcDeleteBuffersARB;
|
||||
extern PFNGLGENBUFFERSARBPROC lcGenBuffersARB;
|
||||
extern PFNGLISBUFFERARBPROC lcIsBufferARB;
|
||||
extern PFNGLBUFFERDATAARBPROC lcBufferDataARB;
|
||||
extern PFNGLBUFFERSUBDATAARBPROC lcBufferSubDataARB;
|
||||
extern PFNGLGETBUFFERSUBDATAARBPROC lcGetBufferSubDataARB;
|
||||
extern PFNGLMAPBUFFERARBPROC lcMapBufferARB;
|
||||
extern PFNGLUNMAPBUFFERARBPROC lcUnmapBufferARB;
|
||||
extern PFNGLGETBUFFERPARAMETERIVARBPROC lcGetBufferParameterivARB;
|
||||
extern PFNGLGETBUFFERPOINTERVARBPROC lcGetBufferPointervARB;
|
||||
|
||||
extern PFNGLISRENDERBUFFERPROC lcIsRenderbuffer;
|
||||
extern PFNGLBINDRENDERBUFFERPROC lcBindRenderbuffer;
|
||||
extern PFNGLDELETERENDERBUFFERSPROC lcDeleteRenderbuffers;
|
||||
extern PFNGLGENRENDERBUFFERSPROC lcGenRenderbuffers;
|
||||
extern PFNGLRENDERBUFFERSTORAGEPROC lcRenderbufferStorage;
|
||||
extern PFNGLGETRENDERBUFFERPARAMETERIVPROC lcGetRenderbufferParameteriv;
|
||||
extern PFNGLISFRAMEBUFFERPROC lcIsFramebuffer;
|
||||
extern PFNGLBINDFRAMEBUFFERPROC lcBindFramebuffer;
|
||||
extern PFNGLDELETEFRAMEBUFFERSPROC lcDeleteFramebuffers;
|
||||
extern PFNGLGENFRAMEBUFFERSPROC lcGenFramebuffers;
|
||||
extern PFNGLCHECKFRAMEBUFFERSTATUSPROC lcCheckFramebufferStatus;
|
||||
extern PFNGLFRAMEBUFFERTEXTURE1DPROC lcFramebufferTexture1D;
|
||||
extern PFNGLFRAMEBUFFERTEXTURE2DPROC lcFramebufferTexture2D;
|
||||
extern PFNGLFRAMEBUFFERTEXTURE3DPROC lcFramebufferTexture3D;
|
||||
extern PFNGLFRAMEBUFFERRENDERBUFFERPROC lcFramebufferRenderbuffer;
|
||||
extern PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC lcGetFramebufferAttachmentParameteriv;
|
||||
extern PFNGLGENERATEMIPMAPPROC lcGenerateMipmap;
|
||||
extern PFNGLBLITFRAMEBUFFERPROC lcBlitFramebuffer;
|
||||
extern PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC lcRenderbufferStorageMultisample;
|
||||
extern PFNGLFRAMEBUFFERTEXTURELAYERPROC lcFramebufferTextureLayer;
|
||||
|
||||
extern PFNGLISRENDERBUFFEREXTPROC lcIsRenderbufferEXT;
|
||||
extern PFNGLBINDRENDERBUFFEREXTPROC lcBindRenderbufferEXT;
|
||||
extern PFNGLDELETERENDERBUFFERSEXTPROC lcDeleteRenderbuffersEXT;
|
||||
extern PFNGLGENRENDERBUFFERSEXTPROC lcGenRenderbuffersEXT;
|
||||
extern PFNGLRENDERBUFFERSTORAGEEXTPROC lcRenderbufferStorageEXT;
|
||||
extern PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC lcGetRenderbufferParameterivEXT;
|
||||
extern PFNGLISFRAMEBUFFEREXTPROC lcIsFramebufferEXT;
|
||||
extern PFNGLBINDFRAMEBUFFEREXTPROC lcBindFramebufferEXT;
|
||||
extern PFNGLDELETEFRAMEBUFFERSEXTPROC lcDeleteFramebuffersEXT;
|
||||
extern PFNGLGENFRAMEBUFFERSEXTPROC lcGenFramebuffersEXT;
|
||||
extern PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC lcCheckFramebufferStatusEXT;
|
||||
extern PFNGLFRAMEBUFFERTEXTURE1DEXTPROC lcFramebufferTexture1DEXT;
|
||||
extern PFNGLFRAMEBUFFERTEXTURE2DEXTPROC lcFramebufferTexture2DEXT;
|
||||
extern PFNGLFRAMEBUFFERTEXTURE3DEXTPROC lcFramebufferTexture3DEXT;
|
||||
extern PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC lcFramebufferRenderbufferEXT;
|
||||
extern PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC lcGetFramebufferAttachmentParameterivEXT;
|
||||
extern PFNGLGENERATEMIPMAPEXTPROC lcGenerateMipmapEXT;
|
||||
|
||||
extern PFNGLATTACHSHADERPROC lcAttachShader;
|
||||
extern PFNGLBINDATTRIBLOCATIONPROC lcBindAttribLocation;
|
||||
extern PFNGLCOMPILESHADERPROC lcCompileShader;
|
||||
extern PFNGLCREATEPROGRAMPROC lcCreateProgram;
|
||||
extern PFNGLCREATESHADERPROC lcCreateShader;
|
||||
extern PFNGLDELETEPROGRAMPROC lcDeleteProgram;
|
||||
extern PFNGLDELETESHADERPROC lcDeleteShader;
|
||||
extern PFNGLDETACHSHADERPROC lcDetachShader;
|
||||
extern PFNGLDISABLEVERTEXATTRIBARRAYPROC lcDisableVertexAttribArray;
|
||||
extern PFNGLENABLEVERTEXATTRIBARRAYPROC lcEnableVertexAttribArray;
|
||||
extern PFNGLGETACTIVEATTRIBPROC lcGetActiveAttrib;
|
||||
extern PFNGLGETACTIVEUNIFORMPROC lcGetActiveUniform;
|
||||
extern PFNGLGETATTACHEDSHADERSPROC lcGetAttachedShaders;
|
||||
extern PFNGLGETATTRIBLOCATIONPROC lcGetAttribLocation;
|
||||
extern PFNGLGETPROGRAMIVPROC lcGetProgramiv;
|
||||
extern PFNGLGETPROGRAMINFOLOGPROC lcGetProgramInfoLog;
|
||||
extern PFNGLGETSHADERIVPROC lcGetShaderiv;
|
||||
extern PFNGLGETSHADERINFOLOGPROC lcGetShaderInfoLog;
|
||||
extern PFNGLGETSHADERSOURCEPROC lcGetShaderSource;
|
||||
extern PFNGLGETUNIFORMLOCATIONPROC lcGetUniformLocation;
|
||||
extern PFNGLGETUNIFORMFVPROC lcGetUniformfv;
|
||||
extern PFNGLGETUNIFORMIVPROC lcGetUniformiv;
|
||||
extern PFNGLGETVERTEXATTRIBDVPROC lcGetVertexAttribdv;
|
||||
extern PFNGLGETVERTEXATTRIBFVPROC lcGetVertexAttribfv;
|
||||
extern PFNGLGETVERTEXATTRIBIVPROC lcGetVertexAttribiv;
|
||||
extern PFNGLGETVERTEXATTRIBPOINTERVPROC lcGetVertexAttribPointerv;
|
||||
extern PFNGLISPROGRAMPROC lcIsProgram;
|
||||
extern PFNGLISSHADERPROC lcIsShader;
|
||||
extern PFNGLLINKPROGRAMPROC lcLinkProgram;
|
||||
extern PFNGLSHADERSOURCEPROC lcShaderSource;
|
||||
extern PFNGLUSEPROGRAMPROC lcUseProgram;
|
||||
extern PFNGLUNIFORM1FPROC lcUniform1f;
|
||||
extern PFNGLUNIFORM2FPROC lcUniform2f;
|
||||
extern PFNGLUNIFORM3FPROC lcUniform3f;
|
||||
extern PFNGLUNIFORM4FPROC lcUniform4f;
|
||||
extern PFNGLUNIFORM1IPROC lcUniform1i;
|
||||
extern PFNGLUNIFORM2IPROC lcUniform2i;
|
||||
extern PFNGLUNIFORM3IPROC lcUniform3i;
|
||||
extern PFNGLUNIFORM4IPROC lcUniform4i;
|
||||
extern PFNGLUNIFORM1FVPROC lcUniform1fv;
|
||||
extern PFNGLUNIFORM2FVPROC lcUniform2fv;
|
||||
extern PFNGLUNIFORM3FVPROC lcUniform3fv;
|
||||
extern PFNGLUNIFORM4FVPROC lcUniform4fv;
|
||||
extern PFNGLUNIFORM1IVPROC lcUniform1iv;
|
||||
extern PFNGLUNIFORM2IVPROC lcUniform2iv;
|
||||
extern PFNGLUNIFORM3IVPROC lcUniform3iv;
|
||||
extern PFNGLUNIFORM4IVPROC lcUniform4iv;
|
||||
extern PFNGLUNIFORMMATRIX2FVPROC lcUniformMatrix2fv;
|
||||
extern PFNGLUNIFORMMATRIX3FVPROC lcUniformMatrix3fv;
|
||||
extern PFNGLUNIFORMMATRIX4FVPROC lcUniformMatrix4fv;
|
||||
extern PFNGLVALIDATEPROGRAMPROC lcValidateProgram;
|
||||
extern PFNGLVERTEXATTRIBPOINTERPROC lcVertexAttribPointer;
|
||||
|
||||
extern PFNGLTEXIMAGE2DMULTISAMPLEPROC lcTexImage2DMultisample;
|
||||
|
||||
extern PFNGLBLENDFUNCSEPARATEPROC lcBlendFuncSeparate;
|
||||
|
||||
#define glBindBuffer lcBindBufferARB
|
||||
#define glDeleteBuffers lcDeleteBuffersARB
|
||||
#define glGenBuffers lcGenBuffersARB
|
||||
#define glIsBuffer lcIsBufferARB
|
||||
#define glBufferData lcBufferDataARB
|
||||
#define glBufferSubData lcBufferSubDataARB
|
||||
#define glGetBufferSubData lcGetBufferSubDataARB
|
||||
#define glMapBuffer lcMapBufferARB
|
||||
#define glUnmapBuffer lcUnmapBufferARB
|
||||
#define glGetBufferParameteriv lcGetBufferParameterivARB
|
||||
#define glGetBufferPointerv lcGetBufferPointervARB
|
||||
|
||||
#define glIsRenderbuffer lcIsRenderbuffer
|
||||
#define glBindRenderbuffer lcBindRenderbuffer
|
||||
#define glDeleteRenderbuffers lcDeleteRenderbuffers
|
||||
#define glGenRenderbuffers lcGenRenderbuffers
|
||||
#define glRenderbufferStorage lcRenderbufferStorage
|
||||
#define glGetRenderbufferParameteriv lcGetRenderbufferParameteriv
|
||||
#define glIsFramebuffer lcIsFramebuffer
|
||||
#define glBindFramebuffer lcBindFramebuffer
|
||||
#define glDeleteFramebuffers lcDeleteFramebuffers
|
||||
#define glGenFramebuffers lcGenFramebuffers
|
||||
#define glCheckFramebufferStatus lcCheckFramebufferStatus
|
||||
#define glFramebufferTexture1D lcFramebufferTexture1D
|
||||
#define glFramebufferTexture2D lcFramebufferTexture2D
|
||||
#define glFramebufferTexture3D lcFramebufferTexture3D
|
||||
#define glFramebufferRenderbuffer lcFramebufferRenderbuffer
|
||||
#define glGetFramebufferAttachmentParameteriv lcGetFramebufferAttachmentParameteriv
|
||||
#define glGenerateMipmap lcGenerateMipmap
|
||||
#define glBlitFramebuffer lcBlitFramebuffer
|
||||
#define glRenderbufferStorageMultisample lcRenderbufferStorageMultisample
|
||||
#define glFramebufferTextureLayer lcFramebufferTextureLayer
|
||||
|
||||
#define glIsRenderbufferEXT lcIsRenderbufferEXT
|
||||
#define glBindRenderbufferEXT lcBindRenderbufferEXT
|
||||
#define glDeleteRenderbuffersEXT lcDeleteRenderbuffersEXT
|
||||
#define glGenRenderbuffersEXT lcGenRenderbuffersEXT
|
||||
#define glRenderbufferStorageEXT lcRenderbufferStorageEXT
|
||||
#define glGetRenderbufferParameterivEXT lcGetRenderbufferParameterivEXT
|
||||
#define glIsFramebufferEXT lcIsFramebufferEXT
|
||||
#define glBindFramebufferEXT lcBindFramebufferEXT
|
||||
#define glDeleteFramebuffersEXT lcDeleteFramebuffersEXT
|
||||
#define glGenFramebuffersEXT lcGenFramebuffersEXT
|
||||
#define glCheckFramebufferStatusEXT lcCheckFramebufferStatusEXT
|
||||
#define glFramebufferTexture1DEXT lcFramebufferTexture1DEXT
|
||||
#define glFramebufferTexture2DEXT lcFramebufferTexture2DEXT
|
||||
#define glFramebufferTexture3DEXT lcFramebufferTexture3DEXT
|
||||
#define glFramebufferRenderbufferEXT lcFramebufferRenderbufferEXT
|
||||
#define glGetFramebufferAttachmentParameterivEXT lcGetFramebufferAttachmentParameterivEXT
|
||||
#define glGenerateMipmapEXT lcGenerateMipmapEXT
|
||||
|
||||
#define glAttachShader lcAttachShader
|
||||
#define glBindAttribLocation lcBindAttribLocation
|
||||
#define glCompileShader lcCompileShader
|
||||
#define glCreateProgram lcCreateProgram
|
||||
#define glCreateShader lcCreateShader
|
||||
#define glDeleteProgram lcDeleteProgram
|
||||
#define glDeleteShader lcDeleteShader
|
||||
#define glDetachShader lcDetachShader
|
||||
#define glDisableVertexAttribArray lcDisableVertexAttribArray
|
||||
#define glEnableVertexAttribArray lcEnableVertexAttribArray
|
||||
#define glGetActiveAttrib lcGetActiveAttrib
|
||||
#define glGetActiveUniform lcGetActiveUniform
|
||||
#define glGetAttachedShaders lcGetAttachedShaders
|
||||
#define glGetAttribLocation lcGetAttribLocation
|
||||
#define glGetProgramiv lcGetProgramiv
|
||||
#define glGetProgramInfoLog lcGetProgramInfoLog
|
||||
#define glGetShaderiv lcGetShaderiv
|
||||
#define glGetShaderInfoLog lcGetShaderInfoLog
|
||||
#define glGetShaderSource lcGetShaderSource
|
||||
#define glGetUniformLocation lcGetUniformLocation
|
||||
#define glGetUniformfv lcGetUniformfv
|
||||
#define glGetUniformiv lcGetUniformiv
|
||||
#define glGetVertexAttribdv lcGetVertexAttribdv
|
||||
#define glGetVertexAttribfv lcGetVertexAttribfv
|
||||
#define glGetVertexAttribiv lcGetVertexAttribiv
|
||||
#define glGetVertexAttribPointerv lcGetVertexAttribPointerv
|
||||
#define glIsProgram lcIsProgram
|
||||
#define glIsShader lcIsShader
|
||||
#define glLinkProgram lcLinkProgram
|
||||
#define glShaderSource lcShaderSource
|
||||
#define glUseProgram lcUseProgram
|
||||
#define glUniform1f lcUniform1f
|
||||
#define glUniform2f lcUniform2f
|
||||
#define glUniform3f lcUniform3f
|
||||
#define glUniform4f lcUniform4f
|
||||
#define glUniform1i lcUniform1i
|
||||
#define glUniform2i lcUniform2i
|
||||
#define glUniform3i lcUniform3i
|
||||
#define glUniform4i lcUniform4i
|
||||
#define glUniform1fv lcUniform1fv
|
||||
#define glUniform2fv lcUniform2fv
|
||||
#define glUniform3fv lcUniform3fv
|
||||
#define glUniform4fv lcUniform4fv
|
||||
#define glUniform1iv lcUniform1iv
|
||||
#define glUniform2iv lcUniform2iv
|
||||
#define glUniform3iv lcUniform3iv
|
||||
#define glUniform4iv lcUniform4iv
|
||||
#define glUniformMatrix2fv lcUniformMatrix2fv
|
||||
#define glUniformMatrix3fv lcUniformMatrix3fv
|
||||
#define glUniformMatrix4fv lcUniformMatrix4fv
|
||||
#define glValidateProgram lcValidateProgram
|
||||
#define glVertexAttribPointer lcVertexAttribPointer
|
||||
|
||||
#define glTexImage2DMultisample lcTexImage2DMultisample
|
||||
|
||||
#define glBlendFuncSeparate lcBlendFuncSeparate
|
||||
|
||||
#endif
|
||||
|
|
|
@ -29,18 +29,7 @@
|
|||
#define LC_ARRAY_COUNT(x) ((sizeof(x)/sizeof(0[x])) / ((size_t)(!(sizeof(x) % sizeof(0[x])))))
|
||||
#define LC_ARRAY_SIZE_CHECK(a,s) static_assert(LC_ARRAY_COUNT(a) == static_cast<int>(s), QT_STRINGIFY(a) " size mismatch.")
|
||||
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 0))
|
||||
#define LC_USE_QOPENGLWIDGET 1
|
||||
#endif
|
||||
|
||||
#if !defined(EGL_VERSION_1_0) && !defined(GL_ES_VERSION_2_0) && !defined(GL_ES_VERSION_3_0) && !defined(QT_OPENGL_ES)
|
||||
#ifndef LC_USE_QOPENGLWIDGET
|
||||
#undef GL_LINES_ADJACENCY_EXT
|
||||
#undef GL_LINE_STRIP_ADJACENCY_EXT
|
||||
#undef GL_TRIANGLES_ADJACENCY_EXT
|
||||
#undef GL_TRIANGLE_STRIP_ADJACENCY_EXT
|
||||
#include "lc_glext.h"
|
||||
#endif
|
||||
#else
|
||||
#define LC_OPENGLES 1
|
||||
#endif
|
||||
|
|
|
@ -464,7 +464,6 @@ void lcMainWindow::CreateMenus()
|
|||
FileMenu->addAction(mActions[LC_FILE_INSTRUCTIONS]);
|
||||
FileMenu->addAction(mActions[LC_FILE_PRINT]);
|
||||
FileMenu->addAction(mActions[LC_FILE_PRINT_PREVIEW]);
|
||||
// FileMenu->addAction(mActions[LC_FILE_PRINT_BOM]);
|
||||
FileMenu->addSeparator();
|
||||
FileMenu->addAction(mActions[LC_FILE_RECENT1]);
|
||||
FileMenu->addAction(mActions[LC_FILE_RECENT2]);
|
||||
|
@ -2651,10 +2650,6 @@ void lcMainWindow::HandleCommand(lcCommandId CommandId)
|
|||
ShowPrintDialog();
|
||||
break;
|
||||
|
||||
// TODO: printing
|
||||
case LC_FILE_PRINT_BOM:
|
||||
break;
|
||||
|
||||
case LC_FILE_RECENT1:
|
||||
case LC_FILE_RECENT2:
|
||||
case LC_FILE_RECENT3:
|
||||
|
|
|
@ -1258,15 +1258,8 @@ QImage lcModel::GetStepImage(bool Zoom, int Width, int Height, lcStep Step)
|
|||
|
||||
lcView View(lcViewType::View, this);
|
||||
View.SetCamera(Camera, true);
|
||||
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
View.SetOffscreenContext();
|
||||
View.MakeCurrent();
|
||||
#else
|
||||
ActiveView->MakeCurrent();
|
||||
lcContext* Context = ActiveView->mContext;
|
||||
View.SetContext(Context);
|
||||
#endif
|
||||
|
||||
if (!View.BeginRenderToImage(Width, Height))
|
||||
{
|
||||
|
@ -1283,10 +1276,6 @@ QImage lcModel::GetStepImage(bool Zoom, int Width, int Height, lcStep Step)
|
|||
|
||||
QImage Image = View.GetRenderImage();
|
||||
|
||||
#ifndef LC_USE_QOPENGLWIDGET
|
||||
Context->ClearResources();
|
||||
#endif
|
||||
|
||||
View.EndRenderToImage();
|
||||
|
||||
SetTemporaryStep(CurrentStep);
|
||||
|
|
|
@ -390,7 +390,6 @@ void lcPartSelectionListModel::DrawPreview(int InfoIndex)
|
|||
const int Width = mIconSize * 2;
|
||||
const int Height = mIconSize * 2;
|
||||
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
if (mView && (mView->GetWidth() != Width || mView->GetHeight() != Height))
|
||||
mView.reset();
|
||||
|
||||
|
@ -412,25 +411,6 @@ void lcPartSelectionListModel::DrawPreview(int InfoIndex)
|
|||
mView->BindRenderFramebuffer();
|
||||
|
||||
lcContext* Context = mView->mContext;
|
||||
#else
|
||||
lcView* ActiveView = gMainWindow->GetActiveView();
|
||||
if (!ActiveView)
|
||||
return;
|
||||
|
||||
ActiveView->MakeCurrent();
|
||||
lcContext* Context = ActiveView->mContext;
|
||||
|
||||
if (mRenderFramebuffer.first.mWidth != Width || mRenderFramebuffer.first.mHeight != Height)
|
||||
{
|
||||
Context->DestroyRenderFramebuffer(mRenderFramebuffer);
|
||||
mRenderFramebuffer = Context->CreateRenderFramebuffer(Width, Height);
|
||||
}
|
||||
|
||||
if (!mRenderFramebuffer.first.IsValid())
|
||||
return;
|
||||
|
||||
Context->BindFramebuffer(mRenderFramebuffer.first);
|
||||
#endif
|
||||
|
||||
const float Aspect = (float)Width / (float)Height;
|
||||
Context->SetViewport(0, 0, Width, Height);
|
||||
|
@ -459,13 +439,9 @@ void lcPartSelectionListModel::DrawPreview(int InfoIndex)
|
|||
|
||||
Scene.Draw(Context);
|
||||
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
mView->UnbindRenderFramebuffer();
|
||||
|
||||
QImage Image = mView->GetRenderFramebufferImage().convertToFormat(QImage::Format_ARGB32);
|
||||
#else
|
||||
QImage Image = Context->GetRenderFramebufferImage(mRenderFramebuffer);
|
||||
Context->ClearFramebuffer();
|
||||
#endif
|
||||
|
||||
mParts[InfoIndex].second = QPixmap::fromImage(Image).scaled(mIconSize, mIconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||
|
||||
|
|
|
@ -136,11 +136,7 @@ protected:
|
|||
bool mShowDecoratedParts;
|
||||
bool mShowPartAliases;
|
||||
QByteArray mFilter;
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
std::unique_ptr<lcView> mView;
|
||||
#else
|
||||
std::pair<lcFramebuffer, lcFramebuffer> mRenderFramebuffer;
|
||||
#endif
|
||||
};
|
||||
|
||||
class lcPartSelectionListView : public QListView
|
||||
|
|
|
@ -86,26 +86,11 @@ void lcView::Redraw()
|
|||
mWidget->update();
|
||||
}
|
||||
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
|
||||
void lcView::SetOffscreenContext()
|
||||
{
|
||||
mContext->SetOffscreenContext();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void lcView::SetContext(lcContext* Context)
|
||||
{
|
||||
if (mDeleteContext)
|
||||
delete mContext;
|
||||
|
||||
mContext = Context;
|
||||
mDeleteContext = false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void lcView::SetFocus(bool Focus)
|
||||
{
|
||||
if (Focus)
|
||||
|
@ -730,8 +715,6 @@ lcArray<lcObject*> lcView::FindObjectsInBox(float x1, float y1, float x2, float
|
|||
return ObjectBoxTest.Objects;
|
||||
}
|
||||
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
|
||||
std::vector<QImage> lcView::GetStepImages(lcStep Start, lcStep End)
|
||||
{
|
||||
std::vector<QImage> Images;
|
||||
|
@ -789,21 +772,16 @@ void lcView::SaveStepImages(const QString& BaseName, bool AddStepSuffix, lcStep
|
|||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
bool lcView::BeginRenderToImage(int Width, int Height)
|
||||
{
|
||||
GLint MaxTexture;
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &MaxTexture);
|
||||
|
||||
MaxTexture = qMin(MaxTexture, 2048);
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
|
||||
const int Samples = QSurfaceFormat::defaultFormat().samples();
|
||||
if (Samples > 1)
|
||||
MaxTexture /= Samples;
|
||||
#else
|
||||
MaxTexture /= QGLFormat::defaultFormat().sampleBuffers() ? QGLFormat::defaultFormat().samples() : 1;
|
||||
#endif
|
||||
|
||||
int TileWidth = qMin(Width, MaxTexture);
|
||||
int TileHeight = qMin(Height, MaxTexture);
|
||||
|
@ -812,7 +790,6 @@ bool lcView::BeginRenderToImage(int Width, int Height)
|
|||
mHeight = TileHeight;
|
||||
mRenderImage = QImage(Width, Height, QImage::Format_ARGB32);
|
||||
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
QOpenGLFramebufferObjectFormat Format;
|
||||
Format.setAttachment(QOpenGLFramebufferObject::Depth);
|
||||
|
||||
|
@ -822,23 +799,11 @@ bool lcView::BeginRenderToImage(int Width, int Height)
|
|||
mRenderFramebuffer = std::unique_ptr<QOpenGLFramebufferObject>(new QOpenGLFramebufferObject(QSize(TileWidth, TileHeight), Format));
|
||||
|
||||
return mRenderFramebuffer->bind();
|
||||
#else
|
||||
mRenderFramebuffer = mContext->CreateRenderFramebuffer(TileWidth, TileHeight);
|
||||
mContext->BindFramebuffer(mRenderFramebuffer.first);
|
||||
|
||||
return mRenderFramebuffer.first.IsValid();
|
||||
#endif
|
||||
}
|
||||
|
||||
void lcView::EndRenderToImage()
|
||||
{
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
mRenderFramebuffer.reset();
|
||||
#else
|
||||
mRenderImage = QImage();
|
||||
mContext->DestroyRenderFramebuffer(mRenderFramebuffer);
|
||||
mContext->ClearFramebuffer();
|
||||
#endif
|
||||
}
|
||||
|
||||
QImage lcView::GetRenderImage() const
|
||||
|
@ -846,8 +811,6 @@ QImage lcView::GetRenderImage() const
|
|||
return mRenderImage;
|
||||
}
|
||||
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
|
||||
void lcView::BindRenderFramebuffer()
|
||||
{
|
||||
mRenderFramebuffer->bind();
|
||||
|
@ -863,8 +826,6 @@ QImage lcView::GetRenderFramebufferImage() const
|
|||
return mRenderFramebuffer->toImage();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void lcView::OnDraw()
|
||||
{
|
||||
if (!mModel)
|
||||
|
@ -959,15 +920,10 @@ void lcView::OnDraw()
|
|||
|
||||
if (!mRenderImage.isNull())
|
||||
{
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
UnbindRenderFramebuffer();
|
||||
QImage TileImage = GetRenderFramebufferImage();
|
||||
BindRenderFramebuffer();
|
||||
quint8* Buffer = TileImage.bits();
|
||||
#else
|
||||
quint8* Buffer = (quint8*)malloc(mWidth * mHeight * 4);
|
||||
mContext->GetRenderFramebufferImage(mRenderFramebuffer, Buffer);
|
||||
#endif
|
||||
uchar* ImageBuffer = mRenderImage.bits();
|
||||
|
||||
quint32 TileY = 0, SrcY = 0;
|
||||
|
@ -985,10 +941,6 @@ void lcView::OnDraw()
|
|||
|
||||
memcpy(dst, src, CurrentTileWidth * 4);
|
||||
}
|
||||
|
||||
#ifndef LC_USE_QOPENGLWIDGET
|
||||
free(Buffer);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -183,11 +183,7 @@ public:
|
|||
void MakeCurrent();
|
||||
void Redraw();
|
||||
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
void SetOffscreenContext();
|
||||
#else
|
||||
void SetContext(lcContext* Context);
|
||||
#endif
|
||||
|
||||
void SetFocus(bool Focus);
|
||||
void SetMousePosition(int MouseX, int MouseY);
|
||||
|
@ -246,13 +242,11 @@ public:
|
|||
bool BeginRenderToImage(int Width, int Height);
|
||||
void EndRenderToImage();
|
||||
QImage GetRenderImage() const;
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
void BindRenderFramebuffer();
|
||||
void UnbindRenderFramebuffer();
|
||||
QImage GetRenderFramebufferImage() const;
|
||||
std::vector<QImage> GetStepImages(lcStep Start, lcStep End);
|
||||
void SaveStepImages(const QString& BaseName, bool AddStepSuffix, lcStep Start, lcStep End);
|
||||
#endif
|
||||
|
||||
lcContext* mContext = nullptr;
|
||||
|
||||
|
@ -314,11 +308,7 @@ protected:
|
|||
PieceInfo* mMouseDownPiece;
|
||||
|
||||
QImage mRenderImage;
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
std::unique_ptr<QOpenGLFramebufferObject> mRenderFramebuffer;
|
||||
#else
|
||||
std::pair<lcFramebuffer, lcFramebuffer> mRenderFramebuffer;
|
||||
#endif
|
||||
bool mOverrideBackgroundColor = false;
|
||||
quint32 mBackgroundColor = 0;
|
||||
|
||||
|
|
|
@ -14,13 +14,8 @@
|
|||
|
||||
static QList<lcViewWidget*> gWidgetList;
|
||||
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
lcViewWidget::lcViewWidget(QWidget* Parent, lcView* View)
|
||||
: lcViewWidgetParent(Parent)
|
||||
#else
|
||||
lcViewWidget::lcViewWidget(QWidget* Parent, lcView* View)
|
||||
: lcViewWidgetParent(Parent, gWidgetList.isEmpty() ? nullptr : gWidgetList.first())
|
||||
#endif
|
||||
: QOpenGLWidget(Parent)
|
||||
{
|
||||
mWheelAccumulator = 0;
|
||||
mView = View;
|
||||
|
@ -46,7 +41,7 @@ lcViewWidget::~lcViewWidget()
|
|||
|
||||
QSize lcViewWidget::sizeHint() const
|
||||
{
|
||||
return mPreferredSize.isEmpty() ? lcViewWidgetParent::sizeHint() : mPreferredSize;
|
||||
return mPreferredSize.isEmpty() ? QOpenGLWidget::sizeHint() : mPreferredSize;
|
||||
}
|
||||
|
||||
void lcViewWidget::SetView(lcView* View)
|
||||
|
@ -91,7 +86,7 @@ void lcViewWidget::focusInEvent(QFocusEvent* FocusEvent)
|
|||
if (mView)
|
||||
mView->SetFocus(true);
|
||||
|
||||
lcViewWidgetParent::focusInEvent(FocusEvent);
|
||||
QOpenGLWidget::focusInEvent(FocusEvent);
|
||||
}
|
||||
|
||||
void lcViewWidget::focusOutEvent(QFocusEvent* FocusEvent)
|
||||
|
@ -99,7 +94,7 @@ void lcViewWidget::focusOutEvent(QFocusEvent* FocusEvent)
|
|||
if (mView)
|
||||
mView->SetFocus(false);
|
||||
|
||||
lcViewWidgetParent::focusOutEvent(FocusEvent);
|
||||
QOpenGLWidget::focusOutEvent(FocusEvent);
|
||||
}
|
||||
|
||||
void lcViewWidget::keyPressEvent(QKeyEvent* KeyEvent)
|
||||
|
@ -110,7 +105,7 @@ void lcViewWidget::keyPressEvent(QKeyEvent* KeyEvent)
|
|||
mView->UpdateCursor();
|
||||
}
|
||||
|
||||
lcViewWidgetParent::keyPressEvent(KeyEvent);
|
||||
QOpenGLWidget::keyPressEvent(KeyEvent);
|
||||
}
|
||||
|
||||
void lcViewWidget::keyReleaseEvent(QKeyEvent* KeyEvent)
|
||||
|
@ -121,7 +116,7 @@ void lcViewWidget::keyReleaseEvent(QKeyEvent* KeyEvent)
|
|||
mView->UpdateCursor();
|
||||
}
|
||||
|
||||
lcViewWidgetParent::keyReleaseEvent(KeyEvent);
|
||||
QOpenGLWidget::keyReleaseEvent(KeyEvent);
|
||||
}
|
||||
|
||||
void lcViewWidget::mousePressEvent(QMouseEvent* MouseEvent)
|
||||
|
@ -204,6 +199,7 @@ void lcViewWidget::mouseDoubleClickEvent(QMouseEvent* MouseEvent)
|
|||
case Qt::LeftButton:
|
||||
mView->OnLeftButtonDoubleClick();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -291,7 +287,7 @@ void lcViewWidget::dragMoveEvent(QDragMoveEvent* DragMoveEvent)
|
|||
return;
|
||||
}
|
||||
|
||||
lcViewWidgetParent::dragMoveEvent(DragMoveEvent);
|
||||
QOpenGLWidget::dragMoveEvent(DragMoveEvent);
|
||||
}
|
||||
|
||||
void lcViewWidget::dropEvent(QDropEvent* DropEvent)
|
||||
|
@ -307,5 +303,5 @@ void lcViewWidget::dropEvent(QDropEvent* DropEvent)
|
|||
return;
|
||||
}
|
||||
|
||||
lcViewWidgetParent::dropEvent(DropEvent);
|
||||
QOpenGLWidget::dropEvent(DropEvent);
|
||||
}
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
typedef QOpenGLWidget lcViewWidgetParent;
|
||||
#else
|
||||
typedef QGLWidget lcViewWidgetParent;
|
||||
#endif
|
||||
|
||||
class lcViewWidget : public lcViewWidgetParent
|
||||
class lcViewWidget : public QOpenGLWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -26,10 +20,10 @@ public:
|
|||
protected:
|
||||
float GetDeviceScale() const
|
||||
{
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
return devicePixelRatio();
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
|
||||
return devicePixelRatioF();
|
||||
#else
|
||||
return windowHandle()->devicePixelRatio();
|
||||
return devicePixelRatio();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -239,7 +239,6 @@ HEADERS += \
|
|||
common/lc_commands.h \
|
||||
common/lc_context.h \
|
||||
common/lc_file.h \
|
||||
common/lc_glext.h \
|
||||
common/lc_glextensions.h \
|
||||
common/lc_global.h \
|
||||
common/lc_http.h \
|
||||
|
|
|
@ -19,11 +19,7 @@ lcQAboutDialog::lcQAboutDialog(QWidget *parent) :
|
|||
#endif
|
||||
|
||||
lcViewWidget* Widget = gMainWindow->GetActiveView()->GetWidget();
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
QSurfaceFormat Format = Widget->context()->format();
|
||||
#else
|
||||
QGLFormat Format = Widget->context()->format();
|
||||
#endif
|
||||
|
||||
int ColorDepth = Format.redBufferSize() + Format.greenBufferSize() + Format.blueBufferSize() + Format.alphaBufferSize();
|
||||
|
||||
|
@ -34,9 +30,7 @@ lcQAboutDialog::lcQAboutDialog(QWidget *parent) :
|
|||
const QString BuffersFormat = tr("Color Buffer: %1 bits\nDepth Buffer: %2 bits\nStencil Buffer: %3 bits\n\n");
|
||||
const QString Buffers = BuffersFormat.arg(QString::number(ColorDepth), QString::number(Format.depthBufferSize()), QString::number(Format.stencilBufferSize()));
|
||||
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
const QString ExtensionsFormat = tr("Buffers: %1\nShaders: %2\nFramebuffers: %3\nTexImage2DMultisample: %4\nBlendFuncSeparate: %5\nAnisotropic: %6\n");
|
||||
|
||||
const QString VertexBuffers = gSupportsVertexBufferObject ? tr("Supported") : tr("Not supported");
|
||||
const QString Shaders = gSupportsShaderObjects ? tr("Supported") : tr("Not supported");
|
||||
const QString Framebuffers = gSupportsFramebufferObject ? tr("Supported") : tr("Not supported");
|
||||
|
@ -45,17 +39,6 @@ lcQAboutDialog::lcQAboutDialog(QWidget *parent) :
|
|||
const QString Anisotropic = gSupportsAnisotropic ? tr("Supported (max %1)").arg(gMaxAnisotropy) : tr("Not supported");
|
||||
|
||||
const QString Extensions = ExtensionsFormat.arg(VertexBuffers, Shaders, Framebuffers, TexImage2DMultisample, BlendFuncSeparate, Anisotropic);
|
||||
#else
|
||||
const QString ExtensionsFormat = tr("GL_ARB_vertex_buffer_object extension: %1\nGL_ARB_framebuffer_object extension: %2\nGL_EXT_framebuffer_object extension: %3\nGL_EXT_blend_func_separate: %4\nGL_EXT_texture_filter_anisotropic extension: %5\n");
|
||||
|
||||
const QString VertexBufferObject = gSupportsVertexBufferObject ? tr("Supported") : tr("Not supported");
|
||||
const QString FramebufferObjectARB = gSupportsFramebufferObjectARB ? tr("Supported") : tr("Not supported");
|
||||
const QString FramebufferObjectEXT = gSupportsFramebufferObjectEXT ? tr("Supported") : tr("Not supported");
|
||||
const QString BlendFuncSeparateEXT = gSupportsBlendFuncSeparate ? tr("Supported") : tr("Not supported");
|
||||
const QString Anisotropic = gSupportsAnisotropic ? tr("Supported (max %1)").arg(gMaxAnisotropy) : tr("Not supported");
|
||||
|
||||
const QString Extensions = ExtensionsFormat.arg(VertexBufferObject, FramebufferObjectARB, FramebufferObjectEXT, BlendFuncSeparateEXT, Anisotropic);
|
||||
#endif
|
||||
|
||||
ui->info->setText(QtVersion + Version + Buffers + Extensions);
|
||||
}
|
||||
|
|
|
@ -79,21 +79,12 @@ lcQPreferencesDialog::lcQPreferencesDialog(QWidget* Parent, lcPreferencesDialogO
|
|||
ui->antiAliasingSamples->setCurrentIndex(0);
|
||||
ui->edgeLines->setChecked(mOptions->Preferences.mDrawEdgeLines);
|
||||
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
if (QSurfaceFormat::defaultFormat().samples() > 1)
|
||||
{
|
||||
glGetFloatv(GL_SMOOTH_LINE_WIDTH_RANGE, mLineWidthRange);
|
||||
glGetFloatv(GL_SMOOTH_LINE_WIDTH_GRANULARITY, &mLineWidthGranularity);
|
||||
}
|
||||
else
|
||||
#elif !defined(LC_OPENGLES)
|
||||
if (QGLFormat::defaultFormat().sampleBuffers() && QGLFormat::defaultFormat().samples() > 1)
|
||||
{
|
||||
glGetFloatv(GL_SMOOTH_LINE_WIDTH_RANGE, mLineWidthRange);
|
||||
glGetFloatv(GL_SMOOTH_LINE_WIDTH_GRANULARITY, &mLineWidthGranularity);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
glGetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, mLineWidthRange);
|
||||
mLineWidthGranularity = 1.0f;
|
||||
|
|
|
@ -123,9 +123,7 @@ static void lcRegisterShellFileTypes()
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#ifdef LC_USE_QOPENGLWIDGET
|
||||
QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
|
||||
#endif
|
||||
|
||||
lcApplication Application(argc, argv);
|
||||
|
||||
|
|
Loading…
Reference in a new issue