77 lines
2.8 KiB
C++
77 lines
2.8 KiB
C++
#ifndef ENGINE_H
|
|
#define ENGINE_H
|
|
|
|
#include <iostream>
|
|
#include <vector>
|
|
#include <GL/glew.h>
|
|
#include <GLFW/glfw3.h>
|
|
#include "imgui.h"
|
|
#include "imgui_impl_opengl3.h"
|
|
#include "imgui_impl_glfw.h"
|
|
#include <glm/glm.hpp>
|
|
#include <glm/gtc/matrix_transform.hpp>
|
|
#include <glm/gtc/type_ptr.hpp>
|
|
|
|
#include "Components/Component.h"
|
|
#include "Components/Camera.h"
|
|
|
|
// Forward declaration of Entity.
|
|
class Entity;
|
|
|
|
class Engine {
|
|
public:
|
|
// Main window.
|
|
static GLFWwindow* window;
|
|
|
|
// Initializes GLFW, GLEW, and sets up the main window and offscreen framebuffer.
|
|
static bool Init();
|
|
// Returns the main GLFW window.
|
|
static GLFWwindow* GetWindow();
|
|
// Clean up resources and shutdown GLFW.
|
|
static void Shutdown();
|
|
|
|
// Offscreen render function that uses the provided camera parameters and renders the scene
|
|
// (with entities) offscreen. Returns the color attachment as an ImTextureID.
|
|
static ImTextureID RenderScene(const glm::mat4 &view, const glm::mat4 &projection, const glm::vec3 &viewPos, const std::vector<Entity*>& entities);
|
|
|
|
// Resizes the offscreen framebuffer to the given dimensions.
|
|
static void ResizeFramebuffer(int width, int height);
|
|
|
|
// Retrieves the final rendered texture.
|
|
static ImTextureID GetFinalRenderingTexture();
|
|
|
|
// --- Billboard Rendering for 3D Icons ---
|
|
// Billboard shader and VAO for drawing icons (e.g., light icons) as billboards in 3D space.
|
|
static GLuint billboardShaderProgram;
|
|
static GLuint billboardVAO;
|
|
// Sets up billboard resources.
|
|
static bool SetupBillboard();
|
|
// Draws a billboarded icon at the given world position with a specified size.
|
|
static void DrawIconIn3DSpace(const glm::vec3 &worldPos, const glm::vec2 &size, ImTextureID texture, const glm::mat4 &view, const glm::mat4 &projection);
|
|
// Iterates over entities and draws icons for those of the appropriate type.
|
|
static void DrawIconsIn3DSpace(const std::vector<Entity*>& entities, const glm::mat4 &view, const glm::mat4 &projection, ImTextureID iconTexture);
|
|
|
|
private:
|
|
// Offscreen framebuffer and its attachments.
|
|
static GLuint framebuffer;
|
|
static GLuint colorTexture;
|
|
static GLuint depthRenderbuffer;
|
|
// Geometry for a simple cube.
|
|
static GLuint cubeVAO;
|
|
static GLuint cubeVBO;
|
|
// Shader program used for rendering the scene.
|
|
static GLuint shaderProgram;
|
|
// Rotation angle for the spinning cube (or animated models).
|
|
static float rotationAngle;
|
|
// Current offscreen framebuffer dimensions.
|
|
static int fbWidth;
|
|
static int fbHeight;
|
|
|
|
// Helper function to compile and link shaders.
|
|
static GLuint CompileShader(const char* vertexSrc, const char* fragmentSrc);
|
|
// Sets up cube geometry and shader (called during initialization).
|
|
static bool SetupScene();
|
|
};
|
|
|
|
#endif // ENGINE_H
|