-
Notifications
You must be signed in to change notification settings - Fork 36
Open
Description
In Fedora, we are trying to get rid of GLEW since it is no longer maintained upstream.
If development of OpenCTM picks back up again, please consider migrating away from GLEW. Two reasonable approaches are:
- Use libepoxy
- Use GLAD; see also the web service for glad2.
I don’t have a complete, upstreamable PR including the necessary build-system changes, but the following seems to be all the source changes that are needed for the OpenCTM viewer to work with libepoxy in Fedora:
From e9f9acae4ba767f07ef9b2b3836324660aca4825 Mon Sep 17 00:00:00 2001
From: "Benjamin A. Beasley" <code@musicinmybrain.net>
Date: Wed, 23 Apr 2025 11:07:53 -0400
Subject: [PATCH] Adapt viewer to libepoxy instead of GLEW
---
tools/ctmviewer.cpp | 47 +++++++++++----------------------------------
1 file changed, 11 insertions(+), 36 deletions(-)
diff --git a/tools/ctmviewer.cpp b/tools/ctmviewer.cpp
index a11cc88..4600453 100644
--- a/tools/ctmviewer.cpp
+++ b/tools/ctmviewer.cpp
@@ -32,7 +32,7 @@
#include <fstream>
#include <sstream>
#include <cstdlib>
-#include <GL/glew.h>
+#include <epoxy/gl.h>
#ifdef __APPLE_CC__
#include <GLUT/glut.h>
#else
@@ -296,16 +296,9 @@ class GLButton {
glBindTexture(GL_TEXTURE_2D, mTexHandle);
- if(GLEW_VERSION_1_4)
- {
- // Generate mipmaps automatically and use them
- glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
- }
- else
- {
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- }
+ // Generate mipmaps automatically and use them
+ glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
@@ -583,16 +576,9 @@ void GLViewer::InitTexture(const char * aFileName)
glBindTexture(GL_TEXTURE_2D, mTexHandle);
- if(GLEW_VERSION_1_4)
- {
- // Generate mipmaps automatically and use them
- glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
- }
- else
- {
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- }
+ // Generate mipmaps automatically and use them
+ glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
@@ -692,13 +678,9 @@ void GLViewer::DrawMesh(Mesh * aMesh)
// Use glDrawElements to draw the triangles...
glShadeModel(GL_SMOOTH);
- if(GLEW_VERSION_1_2)
- glDrawRangeElements(GL_TRIANGLES, 0, aMesh->mVertices.size() - 1,
- aMesh->mIndices.size(), GL_UNSIGNED_INT,
- &aMesh->mIndices[0]);
- else
- glDrawElements(GL_TRIANGLES, aMesh->mIndices.size(), GL_UNSIGNED_INT,
- &aMesh->mIndices[0]);
+ glDrawRangeElements(GL_TRIANGLES, 0, aMesh->mVertices.size() - 1,
+ aMesh->mIndices.size(), GL_UNSIGNED_INT,
+ &aMesh->mIndices[0]);
// We do not use the client state anymore...
glDisableClientState(GL_VERTEX_ARRAY);
@@ -1640,15 +1622,8 @@ void GLViewer::Run(int argc, char **argv)
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("OpenCTM viewer");
- // Init GLEW (for OpenGL 2.x support)
- if(glewInit() != GLEW_OK)
- throw runtime_error("Unable to initialize GLEW.");
-
// Load the phong shader, if we can
- if(GLEW_VERSION_2_0)
- InitShader();
- else if(GLEW_VERSION_1_2)
- glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
+ InitShader();
// Set the GLUT callback functions (these are bridged to the corresponding
// class methods)
--
2.49.0
Metadata
Metadata
Assignees
Labels
No labels