mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-09 07:35:41 +12:00
misc: Switch from gl3w to glad
Also add more checks on window and context creation.
This commit is contained in:
parent
6c29e3e0be
commit
f3010f0909
12 changed files with 22075 additions and 10164 deletions
|
@ -18,7 +18,6 @@ include_directories(${PROJECT_SOURCE_DIR}/include/kernel)
|
||||||
include_directories (${FMT_INCLUDE_DIR})
|
include_directories (${FMT_INCLUDE_DIR})
|
||||||
include_directories(third_party/boost/)
|
include_directories(third_party/boost/)
|
||||||
include_directories(third_party/elfio/)
|
include_directories(third_party/elfio/)
|
||||||
include_directories(third_party/gl3w/)
|
|
||||||
include_directories(third_party/imgui/)
|
include_directories(third_party/imgui/)
|
||||||
include_directories(third_party/dynarmic/src)
|
include_directories(third_party/dynarmic/src)
|
||||||
include_directories(third_party/cryptopp/)
|
include_directories(third_party/cryptopp/)
|
||||||
|
@ -30,6 +29,7 @@ add_compile_definitions(SDL_MAIN_HANDLED)
|
||||||
set(SDL_STATIC ON CACHE BOOL "" FORCE)
|
set(SDL_STATIC ON CACHE BOOL "" FORCE)
|
||||||
set(SDL_SHARED OFF CACHE BOOL "" FORCE)
|
set(SDL_SHARED OFF CACHE BOOL "" FORCE)
|
||||||
add_subdirectory(third_party/SDL2)
|
add_subdirectory(third_party/SDL2)
|
||||||
|
add_subdirectory(third_party/glad)
|
||||||
include_directories(${SDL2_INCLUDE_DIR})
|
include_directories(${SDL2_INCLUDE_DIR})
|
||||||
|
|
||||||
set(BOOST_ROOT "${CMAKE_SOURCE_DIR}/third_party/boost")
|
set(BOOST_ROOT "${CMAKE_SOURCE_DIR}/third_party/boost")
|
||||||
|
@ -122,7 +122,6 @@ set(THIRD_PARTY_SOURCE_FILES third_party/imgui/imgui.cpp
|
||||||
third_party/imgui/imgui_tables.cpp
|
third_party/imgui/imgui_tables.cpp
|
||||||
third_party/imgui/imgui_widgets.cpp
|
third_party/imgui/imgui_widgets.cpp
|
||||||
third_party/imgui/imgui_demo.cpp
|
third_party/imgui/imgui_demo.cpp
|
||||||
third_party/gl3w/gl3w.cpp
|
|
||||||
)
|
)
|
||||||
|
|
||||||
source_group("Header Files\\Core" FILES ${HEADER_FILES})
|
source_group("Header Files\\Core" FILES ${HEADER_FILES})
|
||||||
|
@ -137,4 +136,4 @@ source_group("Source Files\\Third Party" FILES ${THIRD_PARTY_SOURCE_FILES})
|
||||||
|
|
||||||
add_executable(Alber ${SOURCE_FILES} ${FS_SOURCE_FILES} ${KERNEL_SOURCE_FILES} ${LOADER_SOURCE_FILES} ${SERVICE_SOURCE_FILES}
|
add_executable(Alber ${SOURCE_FILES} ${FS_SOURCE_FILES} ${KERNEL_SOURCE_FILES} ${LOADER_SOURCE_FILES} ${SERVICE_SOURCE_FILES}
|
||||||
${PICA_SOURCE_FILES} ${RENDERER_GL_SOURCE_FILES} ${THIRD_PARTY_SOURCE_FILES} ${HEADER_FILES})
|
${PICA_SOURCE_FILES} ${RENDERER_GL_SOURCE_FILES} ${THIRD_PARTY_SOURCE_FILES} ${HEADER_FILES})
|
||||||
target_link_libraries(Alber PRIVATE dynarmic SDL2-static)
|
target_link_libraries(Alber PRIVATE dynarmic SDL2-static glad)
|
|
@ -3,6 +3,7 @@
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
#include <glad/gl.h>
|
||||||
|
|
||||||
#include "cpu.hpp"
|
#include "cpu.hpp"
|
||||||
#include "io_file.hpp"
|
#include "io_file.hpp"
|
||||||
|
@ -35,7 +36,7 @@ class Emulator {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Emulator() : kernel(cpu, memory, gpu), cpu(memory, kernel), gpu(memory), memory(cpu.getTicksRef()) {
|
Emulator() : kernel(cpu, memory, gpu), cpu(memory, kernel), gpu(memory), memory(cpu.getTicksRef()) {
|
||||||
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS) < 0) {
|
||||||
Helpers::panic("Failed to initialize SDL2");
|
Helpers::panic("Failed to initialize SDL2");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,8 +46,21 @@ public:
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
|
||||||
window = SDL_CreateWindow("Alber", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, SDL_WINDOW_OPENGL);
|
window = SDL_CreateWindow("Alber", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, SDL_WINDOW_OPENGL);
|
||||||
|
|
||||||
|
if (window == nullptr) {
|
||||||
|
Helpers::panic("Window creation failed: %s", SDL_GetError());
|
||||||
|
}
|
||||||
|
|
||||||
glContext = SDL_GL_CreateContext(window);
|
glContext = SDL_GL_CreateContext(window);
|
||||||
|
|
||||||
|
if (glContext == nullptr) {
|
||||||
|
Helpers::panic("OpenGL context creation failed: %s", SDL_GetError());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!gladLoadGL(reinterpret_cast<GLADloadfunc>(SDL_GL_GetProcAddress))) {
|
||||||
|
Helpers::panic("OpenGL init failed: %s", SDL_GetError());
|
||||||
|
}
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "gl3w.h"
|
#include <glad/gl.h>
|
||||||
|
|
||||||
// Check if we have C++20. If yes, we can add C++20 std::span support
|
// Check if we have C++20. If yes, we can add C++20 std::span support
|
||||||
#ifdef _MSVC_LANG // MSVC does not properly define __cplusplus without a compiler flag...
|
#ifdef _MSVC_LANG // MSVC does not properly define __cplusplus without a compiler flag...
|
||||||
|
@ -523,8 +523,6 @@ namespace OpenGL {
|
||||||
static GLint getProgram() { return get<GLint>(GL_CURRENT_PROGRAM); }
|
static GLint getProgram() { return get<GLint>(GL_CURRENT_PROGRAM); }
|
||||||
static bool scissorEnabled() { return isEnabled(GL_SCISSOR_TEST); }
|
static bool scissorEnabled() { return isEnabled(GL_SCISSOR_TEST); }
|
||||||
|
|
||||||
static bool versionSupported(int major, int minor) { return gl3wIsSupported(major, minor); }
|
|
||||||
|
|
||||||
[[nodiscard]] static GLint uniformLocation(GLuint program, const char* name) {
|
[[nodiscard]] static GLint uniformLocation(GLuint program, const char* name) {
|
||||||
return glGetUniformLocation(program, name);
|
return glGetUniformLocation(program, name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
#include "emulator.hpp"
|
#include "emulator.hpp"
|
||||||
#include "gl3w.h"
|
|
||||||
|
|
||||||
int main (int argc, char *argv[]) {
|
int main (int argc, char *argv[]) {
|
||||||
Emulator emu;
|
Emulator emu;
|
||||||
if (gl3wInit()) {
|
|
||||||
Helpers::panic("Failed to initialize OpenGL");
|
|
||||||
}
|
|
||||||
|
|
||||||
emu.initGraphicsContext();
|
emu.initGraphicsContext();
|
||||||
|
|
||||||
|
|
1496
third_party/gl3w/gl3w.cpp
vendored
1496
third_party/gl3w/gl3w.cpp
vendored
File diff suppressed because it is too large
Load diff
2619
third_party/gl3w/gl3w.h
vendored
2619
third_party/gl3w/gl3w.h
vendored
File diff suppressed because it is too large
Load diff
5991
third_party/gl3w/glcorearb.h
vendored
5991
third_party/gl3w/glcorearb.h
vendored
File diff suppressed because it is too large
Load diff
7
third_party/glad/CMakeLists.txt
vendored
Normal file
7
third_party/glad/CMakeLists.txt
vendored
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
add_library(glad STATIC
|
||||||
|
src/gl.c
|
||||||
|
include/glad/gl.h
|
||||||
|
include/KHR/khrplatform.h
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(glad PUBLIC "include")
|
7
third_party/glad/README.md
vendored
Normal file
7
third_party/glad/README.md
vendored
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# glad
|
||||||
|
|
||||||
|
This was generated with [glad2](https://github.com/Dav1dde/glad) using the following command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python -m glad --api gl:core=4.3 --out-path glad --reproducible c --loader
|
||||||
|
```
|
13602
third_party/glad/include/glad/gl.h
vendored
Normal file
13602
third_party/glad/include/glad/gl.h
vendored
Normal file
File diff suppressed because one or more lines are too long
8394
third_party/glad/src/gl.c
vendored
Normal file
8394
third_party/glad/src/gl.c
vendored
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue