Can build the project. Now trying to isolate opengl problem
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -12,3 +12,4 @@ x64**
|
||||
**.exe
|
||||
.cache**
|
||||
tags
|
||||
bin/*
|
||||
|
||||
Binary file not shown.
BIN
bin/LivePlotter.lib
(Stored with Git LFS)
BIN
bin/LivePlotter.lib
(Stored with Git LFS)
Binary file not shown.
19
build.sh
19
build.sh
@@ -1,17 +1,22 @@
|
||||
(
|
||||
cd bin
|
||||
rm *
|
||||
demo_srcs=../src/demo/*
|
||||
plotter_srcs=../src/plotter/*.cpp
|
||||
glad_src=../src/plotter/glad.c
|
||||
demo_srcs=../src/demo/*.cpp
|
||||
demo_srcs+=" ../src/util.cpp"
|
||||
plotter_srcs=../src/*.cpp
|
||||
glad_src=../src/glad.c
|
||||
glfw_lib=../ext/glfw/build/src/Debug/glfw3.lib
|
||||
if [ $# -eq 1 ] && [ "$1" == "release" ]
|
||||
then
|
||||
flags="-O2"
|
||||
dll_flags="-O2 -MTd"
|
||||
exe_flags="-O2 -MT"
|
||||
else
|
||||
flags="-Od -ZI"
|
||||
dll_flags="-Od -ZI -MDd"
|
||||
exe_flags="-Od -ZI -MD"
|
||||
fi
|
||||
echo $flags
|
||||
cl $plotter_srcs $glad_src $glfw_lib -I ../inc -I ../ext/glm -I ../ext/glfw/include $flags -std:c++20 -LD -FeLivePlotter.dll
|
||||
cl $demo_srcs -I ../inc -I ../ext/glm $flags -std:c++20 -Fedemo.exe
|
||||
cl $plotter_srcs $glad_src $glfw_lib kernel32.lib user32.lib Gdi32.lib Shell32.lib -I ../inc -I ../ext/glm -I ../ext/glfw/include $dll_flags -MP -std:c++20 -LD -FeLivePlotter.dll
|
||||
cp ../src/shaders/* .
|
||||
cp ../assets/* .
|
||||
cl $demo_srcs -I ../inc -I ../ext/glm $exe_flags -MP -std:c++20 -Fedemo.exe
|
||||
)
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
[
|
||||
{ "directory": "C:/Users/sethh/Documents/repos/LivePlotter", "command": "cl src/demo/demo.cpp -I inc -I ext/glm -I ../ext/glfw/include -Od -std:c++20 -Fo", "file": "src/demo/demo.cpp" },
|
||||
{ "directory": "C:/Users/sethh/Documents/repos/LivePlotter", "command": "cl src/plotter/body.cpp -I inc -I ext/glm -I ../ext/glfw/include -Od -std:c++20 -Fo", "file": "src/plotter/body.cpp" },
|
||||
{ "directory": "C:/Users/sethh/Documents/repos/LivePlotter", "command": "cl src/plotter/camera.cpp -I inc -I ext/glm -I ../ext/glfw/include -Od -std:c++20 -Fo", "file": "src/plotter/camera.cpp" },
|
||||
{ "directory": "C:/Users/sethh/Documents/repos/LivePlotter", "command": "cl src/plotter/live_plotter.cpp -I inc -I ext/glm -I ../ext/glfw/include -Od -std:c++20 -Fo", "file": "src/plotter/live_plotter.cpp" },
|
||||
{ "directory": "C:/Users/sethh/Documents/repos/LivePlotter", "command": "cl src/plotter/logger.cpp -I inc -I ext/glm -I ../ext/glfw/include -Od -std:c++20 -Fo", "file": "src/plotter/logger.cpp" },
|
||||
{ "directory": "C:/Users/sethh/Documents/repos/LivePlotter", "command": "cl src/plotter/shaders.cpp -I inc -I ext/glm -I ../ext/glfw/include -Od -std:c++20 -Fo", "file": "src/plotter/shaders.cpp" },
|
||||
{ "directory": "C:/Users/sethh/Documents/repos/LivePlotter", "command": "cl src/plotter/util.cpp -I inc -I ext/glm -I ../ext/glfw/include -Od -std:c++20 -Fo", "file": "src/plotter/util.cpp" },
|
||||
{ "directory": "C:/Users/sethh/Documents/repos/LivePlotter", "command": "cl src/body.cpp -I inc -I ext/glm -I ext/glfw/include -Od -std:c++20 -Fo", "file": "src/body.cpp" },
|
||||
{ "directory": "C:/Users/sethh/Documents/repos/LivePlotter", "command": "cl src/camera.cpp -I inc -I ext/glm -I ext/glfw/include -Od -std:c++20 -Fo", "file": "src/camera.cpp" },
|
||||
{ "directory": "C:/Users/sethh/Documents/repos/LivePlotter", "command": "cl src/demo/demo.cpp -I inc -I ext/glm -I ext/glfw/include -Od -std:c++20 -Fo", "file": "src/demo/demo.cpp" },
|
||||
{ "directory": "C:/Users/sethh/Documents/repos/LivePlotter", "command": "cl src/live_plotter.cpp -I inc -I ext/glm -I ext/glfw/include -Od -std:c++20 -Fo", "file": "src/live_plotter.cpp" },
|
||||
{ "directory": "C:/Users/sethh/Documents/repos/LivePlotter", "command": "cl src/shaders.cpp -I inc -I ext/glm -I ext/glfw/include -Od -std:c++20 -Fo", "file": "src/shaders.cpp" },
|
||||
{ "directory": "C:/Users/sethh/Documents/repos/LivePlotter", "command": "cl src/util.cpp -I inc -I ext/glm -I ext/glfw/include -Od -std:c++20 -Fo", "file": "src/util.cpp" },
|
||||
]
|
||||
|
||||
28
debug.cap
Normal file
28
debug.cap
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"rdocCaptureSettings": 1,
|
||||
"settings": {
|
||||
"autoStart": false,
|
||||
"commandLine": "",
|
||||
"environment": [
|
||||
],
|
||||
"executable": "C:\\Users\\sethh\\Documents\\repos\\LivePlotter\\bin\\demo.exe",
|
||||
"inject": false,
|
||||
"numQueuedFrames": 0,
|
||||
"options": {
|
||||
"allowFullscreen": true,
|
||||
"allowVSync": true,
|
||||
"apiValidation": false,
|
||||
"captureAllCmdLists": false,
|
||||
"captureCallstacks": false,
|
||||
"captureCallstacksOnlyDraws": false,
|
||||
"debugOutputMute": true,
|
||||
"delayForDebugger": 0,
|
||||
"hookIntoChildren": false,
|
||||
"refAllResources": false,
|
||||
"softMemoryLimit": 0,
|
||||
"verifyBufferAccess": false
|
||||
},
|
||||
"queuedFrameCap": 0,
|
||||
"workingDir": ""
|
||||
}
|
||||
}
|
||||
15
debug.rad
Normal file
15
debug.rad
Normal file
@@ -0,0 +1,15 @@
|
||||
// raddbg 0.9.21 project file
|
||||
|
||||
recent_file: path: "src/live_plotter.cpp"
|
||||
recent_file: path: "src/camera.cpp"
|
||||
recent_file: path: "src/body.cpp"
|
||||
recent_file: path: "src/shaders.cpp"
|
||||
recent_file: path: "../../../../../Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.44.35207/include/variant"
|
||||
recent_file: path: "../../../../../Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.44.35207/include/type_traits"
|
||||
recent_file: path: "src/demo/demo.cpp"
|
||||
target:
|
||||
{
|
||||
executable: "bin/demo.exe"
|
||||
working_directory: bin
|
||||
enabled: 1
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
srcs=src/*
|
||||
|
||||
echo [ > compile_commands.json
|
||||
find src -iname "*.cpp" -exec sh -c 'echo { \"directory\": \"$(cygpath -m $(pwd))\", \"command\": \"cl "$(cygpath -m {})" -I inc -I ext/glm -I ../ext/glfw/include -Od -std:c++20 -Fo\", \"file\": \"$(cygpath -m {})\" }, >> compile_commands.json' \;
|
||||
find src -iname "*.cpp" -exec sh -c 'echo { \"directory\": \"$(cygpath -m $(pwd))\", \"command\": \"cl "$(cygpath -m {})" -I inc -I ext/glm -I ext/glfw/include -Od -std:c++20 -Fo\", \"file\": \"$(cygpath -m {})\" }, >> compile_commands.json' \;
|
||||
echo ] >> compile_commands.json
|
||||
|
||||
97
inc/gldebug.hpp
Normal file
97
inc/gldebug.hpp
Normal file
@@ -0,0 +1,97 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <glad/glad.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
void APIENTRY gl_debug_cb(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *userParam)
|
||||
{
|
||||
// Some debug messages are just annoying informational messages
|
||||
switch (id)
|
||||
{
|
||||
case 131185: // glBufferData
|
||||
return;
|
||||
}
|
||||
|
||||
printf("Message: %s\n", message);
|
||||
printf("Source: ");
|
||||
|
||||
switch (source)
|
||||
{
|
||||
case GL_DEBUG_SOURCE_API:
|
||||
printf("API");
|
||||
break;
|
||||
case GL_DEBUG_SOURCE_WINDOW_SYSTEM:
|
||||
printf("Window System");
|
||||
break;
|
||||
case GL_DEBUG_SOURCE_SHADER_COMPILER:
|
||||
printf("Shader Compiler");
|
||||
break;
|
||||
case GL_DEBUG_SOURCE_THIRD_PARTY:
|
||||
printf("Third Party");
|
||||
break;
|
||||
case GL_DEBUG_SOURCE_APPLICATION:
|
||||
printf("Application");
|
||||
break;
|
||||
case GL_DEBUG_SOURCE_OTHER:
|
||||
printf("Other");
|
||||
break;
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
printf("Type: ");
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case GL_DEBUG_TYPE_ERROR:
|
||||
printf("Error");
|
||||
break;
|
||||
case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR:
|
||||
printf("Deprecated Behavior");
|
||||
break;
|
||||
case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR:
|
||||
printf("Undefined Behavior");
|
||||
break;
|
||||
case GL_DEBUG_TYPE_PORTABILITY:
|
||||
printf("Portability");
|
||||
break;
|
||||
case GL_DEBUG_TYPE_PERFORMANCE:
|
||||
printf("Performance");
|
||||
break;
|
||||
case GL_DEBUG_TYPE_MARKER:
|
||||
printf("Marker");
|
||||
break;
|
||||
case GL_DEBUG_TYPE_PUSH_GROUP:
|
||||
printf("Push Group");
|
||||
break;
|
||||
case GL_DEBUG_TYPE_POP_GROUP:
|
||||
printf("Pop Group");
|
||||
break;
|
||||
case GL_DEBUG_TYPE_OTHER:
|
||||
printf("Other");
|
||||
break;
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
printf("ID: %d\n", id);
|
||||
printf("Severity: ");
|
||||
|
||||
switch (severity)
|
||||
{
|
||||
case GL_DEBUG_SEVERITY_HIGH:
|
||||
printf("High");
|
||||
break;
|
||||
case GL_DEBUG_SEVERITY_MEDIUM:
|
||||
printf("Medium");
|
||||
break;
|
||||
case GL_DEBUG_SEVERITY_LOW:
|
||||
printf("Low");
|
||||
break;
|
||||
case GL_DEBUG_SEVERITY_NOTIFICATION:
|
||||
printf("Notification");
|
||||
break;
|
||||
}
|
||||
|
||||
printf("\n\n");
|
||||
}
|
||||
@@ -42,7 +42,8 @@ glm::mat4 world_to_camera(Camera& c) {
|
||||
glm::mat4 rotation_theta = glm::rotate(glm::mat4(1), c.theta, {0, 1, 0});
|
||||
glm::mat4 rotation_phi = glm::rotate(glm::mat4(1), c.phi, {1, 0, 0});
|
||||
glm::mat4 rotated_focus_to_camera = glm::translate(glm::mat4(1), { 0, 0, -c.distance });
|
||||
return rotated_focus_to_camera * rotation_phi * rotation_theta * world_to_focus;
|
||||
glm::mat4 res = rotated_focus_to_camera * rotation_phi * rotation_theta * world_to_focus;
|
||||
return res;
|
||||
}
|
||||
|
||||
glm::mat4 camera_to_world(Camera& c) { return glm::inverse(world_to_camera(c)); }
|
||||
@@ -1,28 +1,29 @@
|
||||
#include <cassert>
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <winnt.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <glm/ext/vector_float2.hpp>
|
||||
#include <glm/ext/vector_float4.hpp>
|
||||
#include <profileapi.h>
|
||||
#include <synchapi.h>
|
||||
#include <map>
|
||||
#include <glad/glad.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <glm/ext/matrix_clip_space.hpp>
|
||||
#include <glm/ext/matrix_transform.hpp>
|
||||
#include <glm/ext/vector_float3.hpp>
|
||||
#include <glm/matrix.hpp>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <winnt.h>
|
||||
|
||||
#include "glm/gtc/type_ptr.hpp"
|
||||
#include "sync.hpp"
|
||||
#include "util.hpp"
|
||||
#include "shaders.hpp"
|
||||
#include "body.hpp"
|
||||
#include "camera.hpp"
|
||||
#include "live_plotter.hpp"
|
||||
#include "gldebug.hpp"
|
||||
|
||||
using namespace sync;
|
||||
|
||||
@@ -69,6 +70,7 @@ bool _glfw_setup();
|
||||
void _refresh_win();
|
||||
double _time();
|
||||
|
||||
|
||||
extern DllExport bool __cdecl start(int win_w, int win_h) {
|
||||
if (running) {
|
||||
printf("Already running! Call stop before calling stop again\n");
|
||||
@@ -112,7 +114,8 @@ extern DllExport bool __cdecl stop() {
|
||||
extern DllExport pointid __cdecl create_point(float x, float y, float z) {
|
||||
lock(m);
|
||||
|
||||
// This is stupid. Please fix
|
||||
// TODO: This system is really stupid. Please fix
|
||||
// Also what happens if there isn't a replaceable point?
|
||||
int slot = -1;
|
||||
int start_loc = point_buf_i;
|
||||
do {
|
||||
@@ -125,7 +128,7 @@ extern DllExport pointid __cdecl create_point(float x, float y, float z) {
|
||||
|
||||
assert(slot > -1);
|
||||
|
||||
point_buf[slot] = {
|
||||
point_buf[slot] = {
|
||||
.initialized = false,
|
||||
.replaceable = false,
|
||||
.startloc = glm::vec3(x, y, z),
|
||||
@@ -206,8 +209,8 @@ void _scroll_cb(GLFWwindow* win, double xoffset, double yoffset) { zoom_camera(c
|
||||
DWORD _win_thread(LPVOID args) {
|
||||
glm::vec2* winsize = (glm::vec2*)args;
|
||||
camera = make_camera({ 0, 0, 0 }, 10);
|
||||
camera.theta = glm::radians(90.0f);
|
||||
camera.phi = glm::radians(30.0f);
|
||||
camera.theta = glm::radians(0.0f);
|
||||
camera.phi = glm::radians(0.0f);
|
||||
viewport = make_viewport(winsize->x, winsize->y, 45.0f);
|
||||
if (!_glfw_setup()) {
|
||||
printf("Failed to initialize glfw window\n");
|
||||
@@ -219,6 +222,17 @@ DWORD _win_thread(LPVOID args) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("Open GL Vendor: %s\n", glGetString(GL_VENDOR));
|
||||
printf("Open GL Renderer: %s\n", glGetString(GL_RENDERER));
|
||||
printf("Open GL Version: %s\n", glGetString(GL_VERSION));
|
||||
printf("Open GL Shader Language Version: %s\n", glGetString(GL_SHADING_LANGUAGE_VERSION));
|
||||
|
||||
// Enable debug messages
|
||||
glEnable(GL_DEBUG_OUTPUT);
|
||||
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
|
||||
glDebugMessageCallback(gl_debug_cb, 0);
|
||||
glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, nullptr, GL_TRUE);
|
||||
|
||||
if (!load_shader(&shader, vertex_filepath, fragment_filepath)) {
|
||||
printf("Failed to compile shaders\n");
|
||||
return -1;
|
||||
@@ -243,9 +257,11 @@ DWORD _win_thread(LPVOID args) {
|
||||
|
||||
bool _glfw_setup() {
|
||||
glfwInit();
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||
glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE);
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
|
||||
win = glfwCreateWindow(viewport.width, viewport.height, "LivePlotter", NULL, NULL);
|
||||
if (win == NULL) {
|
||||
printf("Failed to create GLFW window\n");
|
||||
@@ -258,6 +274,7 @@ bool _glfw_setup() {
|
||||
glfwSetMouseButtonCallback(win, _mouse_button_cb);
|
||||
glfwSetScrollCallback(win, _scroll_cb);
|
||||
|
||||
|
||||
_cursor_pos_cb(win, 0, 0);
|
||||
return true;
|
||||
}
|
||||
@@ -267,6 +284,11 @@ void _refresh_win() {
|
||||
set_uniform(shader, "camera_t", world_to_camera(camera));
|
||||
set_uniform(shader, "projection_t", camera_to_projection(viewport));
|
||||
|
||||
/*glm::mat4 cam = world_to_camera(camera);
|
||||
glm::mat4 view = camera_to_projection(viewport);
|
||||
glUniformMatrix4fv(glGetUniformLocation(shader, "camera_t"), 1, GL_FALSE, glm::value_ptr(cam));
|
||||
glUniformMatrix4fv(glGetUniformLocation(shader, "projection_t"), 1, GL_FALSE, glm::value_ptr(view));*/
|
||||
|
||||
if (trylock(m)) {
|
||||
for (int i = 0; i < point_buf_len; i++) {
|
||||
Point &p = point_buf[i];
|
||||
@@ -85,6 +85,7 @@ bool _compile_shader(uint *out_id, const char* filepath, int shader_type) {
|
||||
glGetShaderInfoLog(id, MAX_ERR_MSG_LEN, NULL, err_msg);
|
||||
printf("Error compiling shader %s\n", filepath);
|
||||
printf("Error msg: %s\n", err_msg);
|
||||
return false;
|
||||
}
|
||||
*out_id = id;
|
||||
return status == GL_TRUE;
|
||||
@@ -12,6 +12,7 @@ bool read_file(string* s, const char* filepath) {
|
||||
return false;
|
||||
}
|
||||
*s = { istreambuf_iterator<char>(file), istreambuf_iterator<char>() };
|
||||
return true;
|
||||
}
|
||||
|
||||
vector<string> split_str(string s, char delim) {
|
||||
@@ -40,4 +41,4 @@ glm::mat4 quat_to_mat4(glm::quat q) {
|
||||
return glm::mat4(col0, col1, col2, col3);
|
||||
}
|
||||
|
||||
float randf() { return (float)rand() / (float)RAND_MAX; }
|
||||
float randf() { return (float)rand() / (float)RAND_MAX; }
|
||||
Reference in New Issue
Block a user