Add OpenGLPipelineState and integrate into main.cpp
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include "XCEngine/Debug/FileLogSink.h"
|
||||
#include "XCEngine/RHI/OpenGL/OpenGLShader.h"
|
||||
#include "XCEngine/RHI/OpenGL/OpenGLDevice.h"
|
||||
#include "XCEngine/RHI/OpenGL/OpenGLPipelineState.h"
|
||||
|
||||
using namespace XCEngine::Debug;
|
||||
using namespace XCEngine::RHI;
|
||||
@@ -262,6 +263,7 @@ private:
|
||||
Model* model = nullptr;
|
||||
OpenGLShader* shader = nullptr;
|
||||
OpenGLDevice* device = nullptr;
|
||||
OpenGLPipelineState* pipeline = nullptr;
|
||||
int frameCount = 0;
|
||||
|
||||
void framebuffer_size_callback(GLFWwindow* window, int width, int height)
|
||||
@@ -279,10 +281,17 @@ void Initialize()
|
||||
|
||||
Log("OpenGL Test Application Started");
|
||||
|
||||
pipeline = new OpenGLPipelineState();
|
||||
ViewportState viewport;
|
||||
viewport.width = SCR_WIDTH;
|
||||
viewport.height = SCR_HEIGHT;
|
||||
pipeline->SetViewport(viewport);
|
||||
pipeline->SetClearColor(0.1f, 0.1f, 0.1f, 1.0f);
|
||||
pipeline->Apply();
|
||||
|
||||
model = new Model("res/models/backpack/backpack.obj");
|
||||
shader = new OpenGLShader();
|
||||
shader->CompileFromFile("Shaders/vertexshader.glsl", "Shaders/fragmentshader.glsl");
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
Log("Initialization complete");
|
||||
}
|
||||
@@ -319,8 +328,7 @@ bool SaveScreenshot(const char* filename)
|
||||
|
||||
void Render()
|
||||
{
|
||||
glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
pipeline->Clear(3); // COLOR_BUFFER_BIT | DEPTH_BUFFER_BIT
|
||||
|
||||
shader->Use();
|
||||
|
||||
@@ -387,6 +395,7 @@ int main()
|
||||
|
||||
Log("Application closed");
|
||||
|
||||
delete pipeline;
|
||||
delete device;
|
||||
delete shader;
|
||||
delete model;
|
||||
|
||||
Reference in New Issue
Block a user