refactor(rendering): removed glfw dependency of render functions

This commit is contained in:
maelstrom 2025-07-09 10:16:48 +02:00
parent 19f048b52a
commit 1e5e60bbcf
4 changed files with 8 additions and 10 deletions

View file

@ -34,7 +34,7 @@ int main() {
glewInit(); glewInit();
gDataModel->Init(); gDataModel->Init();
renderInit(window, 1200, 900); renderInit(1200, 900);
// Baseplate // Baseplate
gWorkspace()->AddChild(Part::New({ gWorkspace()->AddChild(Part::New({
@ -66,7 +66,7 @@ int main() {
processInput(window); processInput(window);
gWorkspace()->PhysicsStep(deltaTime); gWorkspace()->PhysicsStep(deltaTime);
render(window); render();
glfwSwapBuffers(window); glfwSwapBuffers(window);
glfwPollEvents(); glfwPollEvents();

View file

@ -1,5 +1,4 @@
#include <GL/glew.h> #include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <GL/gl.h> #include <GL/gl.h>
#include <cmath> #include <cmath>
#include <cstdio> #include <cstdio>
@ -65,7 +64,7 @@ int viewportWidth, viewportHeight;
void renderDebugInfo(); void renderDebugInfo();
void drawRect(int x, int y, int width, int height, glm::vec3 color); void drawRect(int x, int y, int width, int height, glm::vec3 color);
void renderInit(GLFWwindow* window, int width, int height) { void renderInit(int width, int height) {
viewportWidth = width, viewportHeight = height; viewportWidth = width, viewportHeight = height;
glViewport(0, 0, width, height); glViewport(0, 0, width, height);
@ -650,7 +649,7 @@ void addDebugRenderCFrame(CFrame frame, Color3 color) {
} }
tu_time_t renderTime; tu_time_t renderTime;
void render(GLFWwindow* window) { void render() {
tu_time_t startTime = tu_clock_micros(); tu_time_t startTime = tu_clock_micros();
glClearColor(0.1f, 0.1f, 0.1f, 1.0f); glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

View file

@ -1,13 +1,12 @@
#pragma once #pragma once
#include <GLFW/glfw3.h>
extern bool wireframeRendering; extern bool wireframeRendering;
class CFrame; class CFrame;
class Color3; class Color3;
void renderInit(GLFWwindow* window, int width, int height); void renderInit(int width, int height);
void render(GLFWwindow* window); void render();
void setViewport(int width, int height); void setViewport(int width, int height);
void addDebugRenderCFrame(CFrame); void addDebugRenderCFrame(CFrame);
void addDebugRenderCFrame(CFrame, Color3); void addDebugRenderCFrame(CFrame, Color3);

View file

@ -35,7 +35,7 @@ MainGLWidget::MainGLWidget(QWidget* parent): QOpenGLWidget(parent), contextMenu(
void MainGLWidget::initializeGL() { void MainGLWidget::initializeGL() {
glewInit(); glewInit();
renderInit(NULL, width(), height()); renderInit(width(), height());
} }
inline void playSound(QString path) { inline void playSound(QString path) {
@ -63,7 +63,7 @@ extern std::weak_ptr<Part> draggingObject;
extern std::optional<HandleFace> draggingHandle; extern std::optional<HandleFace> draggingHandle;
extern Shader* shader; extern Shader* shader;
void MainGLWidget::paintGL() { void MainGLWidget::paintGL() {
::render(NULL); ::render();
} }
bool isMouseRightDragging = false; bool isMouseRightDragging = false;