Use Legacy GLAD

This commit is contained in:
TheBrokenRail 2024-11-24 21:01:00 -05:00
parent 09c8af0396
commit cc060accaf
6 changed files with 47 additions and 14 deletions

View File

@ -83,3 +83,9 @@ function(force_set name value type)
set("${name}" "${value}" CACHE "${type}" "" FORCE) set("${name}" "${value}" CACHE "${type}" "" FORCE)
mark_as_advanced(FORCE "${name}") mark_as_advanced(FORCE "${name}")
endfunction() endfunction()
# Make Directory
function(set_and_mkdir name dir)
set("${name}" "${dir}" PARENT_SCOPE)
file(MAKE_DIRECTORY "${dir}")
endfunction()

View File

@ -1,13 +1,42 @@
project(imgui-glad) project(imgui-glad)
# Setup GLAD # Directories
set(MESSAGE_QUIET TRUE) set_and_mkdir(GLAD_DIR "${CMAKE_CURRENT_BINARY_DIR}/glad")
add_subdirectory(src/cmake) set_and_mkdir(GLAD_SRC_DIR "${GLAD_DIR}/src")
glad_add_library(glad SHARED REPRODUCIBLE QUIET API gl:compatibility=1.1) set_and_mkdir(GLAD_INCLUDE_DIR "${GLAD_DIR}/include")
set(MESSAGE_QUIET FALSE)
# Fix GL/gl.h # Files
setup_header_dirs(glad "${CMAKE_CURRENT_SOURCE_DIR}/include") set(GLAD_SOURCES
"${GLAD_INCLUDE_DIR}/KHR/khrplatform.h"
"${GLAD_INCLUDE_DIR}/glad/glad.h"
"${GLAD_SRC_DIR}/glad.c"
)
# Find Python
find_package(Python REQUIRED QUIET)
# Generate
add_custom_command(
OUTPUT ${GLAD_SOURCES}
COMMAND "${Python_EXECUTABLE}"
ARGS "-m" "glad"
"--out" "${GLAD_DIR}"
"--api" "gl=1.1"
"--generator" "c"
"--reproducible"
"--quiet"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src"
VERBATIM
)
# Build
add_library(glad SHARED ${GLAD_SOURCES})
# Headers
setup_header_dirs(glad
"${GLAD_INCLUDE_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/include"
)
# Install # Install
setup_library(glad TRUE FALSE) setup_library(glad TRUE FALSE)

View File

@ -1,2 +1,2 @@
#pragma once #pragma once
#include <glad/gl.h> #include <glad/glad.h>

@ -1 +1 @@
Subproject commit f49229523c58ad7698e941f7c51454e77dd9d6a8 Subproject commit e86f90457371c6233053bacf0d6f486a51ddcd67

View File

@ -18,7 +18,9 @@ Frame::Frame(const char *title, const int width, const int height) {
window = create_glfw_window(title, width, height); window = create_glfw_window(title, width, height);
// Load OpenGL // Load OpenGL
gladLoadGL(glfwGetProcAddress); if (!gladLoadGLLoader((GLADloadproc) glfwGetProcAddress)) {
ERR("Unable To Load GLAD");
}
// Disable V-Sync // Disable V-Sync
// (On Wayland, This Fixes Issues With The Clipboard) // (On Wayland, This Fixes Issues With The Clipboard)

View File

@ -200,10 +200,6 @@ set(SRC
) )
# Directories # Directories
function(set_and_mkdir name dir)
set("${name}" "${dir}" PARENT_SCOPE)
file(MAKE_DIRECTORY "${dir}")
endfunction()
set_and_mkdir(GENERATED_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated") set_and_mkdir(GENERATED_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated")
set_and_mkdir(INCLUDE_OUTPUT_DIR "${GENERATED_DIR}/include") set_and_mkdir(INCLUDE_OUTPUT_DIR "${GENERATED_DIR}/include")
set_and_mkdir(HEADER_OUTPUT_DIR "${INCLUDE_OUTPUT_DIR}/symbols") set_and_mkdir(HEADER_OUTPUT_DIR "${INCLUDE_OUTPUT_DIR}/symbols")