Skip to content

Commit

Permalink
Convert gl3w to glbinding
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedhussein89 committed Feb 28, 2022
1 parent e63cd19 commit e2b836a
Show file tree
Hide file tree
Showing 33 changed files with 215 additions and 446 deletions.
10 changes: 0 additions & 10 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,4 @@ Checks: 'portability-*,performance-*,readability-*,cppcoreguidelines-*,
HeaderFilterRegex: '.*'
AnalyzeTemporaryDtors: false
FormatStyle: none
CheckOptions:
- { key: readability-identifier-naming.NamespaceCase, value: camelBack }
- { key: readability-identifier-naming.ClassCase, value: CamelCase }
- { key: readability-identifier-naming.PrivateMemberPrefix, value: m }
- { key: readability-identifier-naming.PrivateMemberCase, value: CamelCase }
- { key: readability-identifier-naming.StructCase, value: CamelCase }
- { key: readability-identifier-naming.FunctionCase, value: camelBack }
- { key: readability-identifier-naming.VariableCase, value: camelBack }
- { key: readability-identifier-naming.GlobalConstantCase, value: UPPER_CASE }
- { key: readability-identifier-naming.LocalConstantCase, value: CamelBack }
...
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@ endif()
add_subdirectory(window)
add_subdirectory(opengl)
add_subdirectory(shaders)

39 changes: 0 additions & 39 deletions cmake/FindAssimp.cmake

This file was deleted.

42 changes: 0 additions & 42 deletions cmake/Findgl3w.cmake

This file was deleted.

10 changes: 5 additions & 5 deletions opengl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# ${CMAKE_SOURCE_DIR}/window/CMakeLists.txt
find_package(SDL2 REQUIRED)
find_package(SDL2 REQUIRED)
set(OpenGL_GL_PREFERENCE "GLVND")
find_package(OpenGL REQUIRED)
find_package(gl3w REQUIRED)
find_package(OpenGL REQUIRED)
find_package(glbinding REQUIRED)

if(UNIX AND ENABLE_X11)
find_package(X11 REQUIRED)
Expand Down Expand Up @@ -51,7 +51,7 @@ set(
demos
fixedPipelineOpenGLSDL
programmablePipelineOpenGLSDL
programmablePipelineGl3wSDL
programmablePipelineGlBindingSDL
programmablePipelineSDL2EGL
)

Expand All @@ -65,7 +65,7 @@ foreach(demo IN LISTS demos)
${demo}
PRIVATE
OpenGL::GL
gl3w::gl3w
glbinding::glbinding
SDL2::SDL2
SDL2::SDL2main
options::options
Expand Down
124 changes: 0 additions & 124 deletions opengl/programmablePipelineGl3wSDL.cpp

This file was deleted.

2 changes: 1 addition & 1 deletion opengl/shaders/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ foreach(sample IN LISTS samples)
SDL2::SDL2
SDL2::SDL2main
options::options
gl3w::gl3w
glbinding::glbinding
glm::glm
)

Expand Down
19 changes: 9 additions & 10 deletions opengl/shaders/controlTriangleColorWithMousePosition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
#include <string_view>
// GLM
#include <glm/vec4.hpp>
// GL3W
#include <GL/gl3w.h>
// glbinding
#include <glbinding/gl/gl.h>
#include <glbinding/glbinding.h>
// SDL
#include <SDL2/SDL.h>
#include <SDL2/SDL_opengl.h>

using namespace gl;

static constexpr auto GL3D_SUCCESS = 0;
static constexpr auto GL_SHADER_FAILURE = std::numeric_limits<std::uint32_t>::max();
Expand All @@ -35,7 +37,7 @@ static void DebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity
return;
}

std::cout << source << " : " << message << '\n';
std::cout << message << '\n';
}

static auto parseProgramOptions(int argc, char **argv) -> std::optional<std::pair<int, int>> {
Expand All @@ -49,7 +51,7 @@ static auto parseProgramOptions(int argc, char **argv) -> std::optional<std::pai
static auto checkShaderCompilation(GLuint shader) -> bool {
GLint compiled;
glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled);
if(compiled != GL_TRUE) {
if(compiled != 1) {
GLsizei log_length = 0;
GLchar message[1024];
glGetShaderInfoLog(shader, 1024, &log_length, message);
Expand All @@ -73,7 +75,7 @@ static auto createShader(GLenum shaderType, const char *shaderSource) -> GLuint
static auto checkProgramLinkage(GLuint program) -> bool {
GLint program_linked;
glGetProgramiv(program, GL_LINK_STATUS, &program_linked);
if(program_linked != GL_TRUE) {
if(program_linked != 1) {
GLsizei log_length = 0;
GLchar message[1024];
glGetProgramInfoLog(program, 1024, &log_length, message);
Expand Down Expand Up @@ -138,10 +140,7 @@ auto main(int argc, char *argv[]) -> int {
// Enable vsync
SDL_GL_SetSwapInterval(1);

if(gl3wInit() != GL3D_SUCCESS) {
std::cerr << "Can not initialize GL3W!\n";
return EXIT_FAILURE;
}
glbinding::initialize(nullptr, false);

// Set OpenGL Debug Callback
if(glDebugMessageCallback) {
Expand Down
19 changes: 9 additions & 10 deletions opengl/shaders/drawCube.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
#include <string_view>
// GLM
#include <glm/vec4.hpp>
// GL3W
#include <GL/gl3w.h>
// glbinding
#include <glbinding/gl/gl.h>
#include <glbinding/glbinding.h>
// SDL
#include <SDL2/SDL.h>
#include <SDL2/SDL_opengl.h>

using namespace gl;

[[maybe_unused]] static constexpr auto GL3D_SUCCESS = 0;

Expand All @@ -39,7 +41,7 @@ static void DebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity
return;
}

std::cout << source << " : " << message << '\n';
std::cout << message << '\n';
}

static auto parseProgramOptions(int argc, char **argv) -> std::optional<std::pair<int, int>> {
Expand All @@ -53,7 +55,7 @@ static auto parseProgramOptions(int argc, char **argv) -> std::optional<std::pai
static auto checkShaderCompilation(GLuint shader) -> bool {
GLint compiled;
glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled);
if(compiled != GL_TRUE) {
if(compiled != 1) {
GLsizei log_length = 0;
GLchar message[1024];
glGetShaderInfoLog(shader, 1024, &log_length, message);
Expand All @@ -77,7 +79,7 @@ static auto createShader(GLenum shaderType, const char *shaderSource) -> GLuint
static auto checkProgramLinkage(GLuint program) -> bool {
GLint program_linked;
glGetProgramiv(program, GL_LINK_STATUS, &program_linked);
if(program_linked != GL_TRUE) {
if(program_linked != 1) {
GLsizei log_length = 0;
GLchar message[1024];
glGetProgramInfoLog(program, 1024, &log_length, message);
Expand Down Expand Up @@ -142,10 +144,7 @@ auto main(int argc, char *argv[]) -> int {
// Enable vsync
SDL_GL_SetSwapInterval(SDL_SWAP_SYNCHRONIZED);

if(gl3wInit() != GL3D_SUCCESS) {
std::cerr << "Can not initialize GL3W!\n";
return EXIT_FAILURE;
}
glbinding::initialize(nullptr, false);

// Set OpenGL Debug Callback
if(glDebugMessageCallback) {
Expand Down
Loading

0 comments on commit e2b836a

Please sign in to comment.