Skip to content

Commit

Permalink
glwidgets, bindTexturePatch: Get the OpenGL extensions supported by t…
Browse files Browse the repository at this point in the history
…he graphics card, and conditionally enable anisotropic filtering with the maximum amount of taps for a less blurry viewport.
  • Loading branch information
Swyter committed May 9, 2024
1 parent dfaa295 commit 3813f1e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions bindTexturePatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ bool GLWidget::myBindTexture(const QString &fileName, DdsData &data)
} else
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

if (GLWidget::maxSupportedTexAnisoTaps > 1)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, GLWidget::maxSupportedTexAnisoTaps);

int offset = 0;
int w = ddsHeader.dwWidth;
int h = ddsHeader.dwHeight;
Expand Down
13 changes: 13 additions & 0 deletions glwidgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1684,6 +1684,19 @@ void GLWidget::initOpenGL2(){
//glewInit();
//initFramPrograms();
qDebug("Init glew2!");

/* swy: retrieve the list of supported OpenGL extensions; first as a long space-separated string,
then split into a QtSet dictionary for fast lookups */
const char *thing = (const char *) glGetString(GL_EXTENSIONS);
supportedExtensionsList = QString(thing).split(" ").toSet();
qDebug() << supportedExtensionsList;

if (supportedExtensionsList.contains("GL_EXT_texture_filter_anisotropic"))
{
glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, (GLint *) &maxSupportedTexAnisoTaps);
qDebug("swy: GL_EXT_texture_filter_anisotropic is supported, with x%u taps...", maxSupportedTexAnisoTaps);
}

openGL2ready = true;

readCustomShaders();
Expand Down
3 changes: 3 additions & 0 deletions glwidgets.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ class GLWidget : public QGLWidget, protected QOpenGLFunctions_2_0
MaterialError lastMatErr;
void setMaterialError(int newErr);

QSet<QString> supportedExtensionsList;
uint8_t maxSupportedTexAnisoTaps = 0;

void keyPressEvent( QKeyEvent * event );
void keyReleaseEvent( QKeyEvent * event );
private slots:
Expand Down

0 comments on commit 3813f1e

Please sign in to comment.