OpenGL: Use OpenGLCommandList instead of raw GL in minimal test
- Replace glViewport() with commandList.SetViewport() - Replace glClearColor()+glClear() with commandList.Clear() - Add OpenGLCommandList include and instance
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include "XCEngine/RHI/OpenGL/OpenGLDevice.h"
|
#include "XCEngine/RHI/OpenGL/OpenGLDevice.h"
|
||||||
#include "XCEngine/RHI/OpenGL/OpenGLSwapChain.h"
|
#include "XCEngine/RHI/OpenGL/OpenGLSwapChain.h"
|
||||||
|
#include "XCEngine/RHI/OpenGL/OpenGLCommandList.h"
|
||||||
#include "XCEngine/Debug/Logger.h"
|
#include "XCEngine/Debug/Logger.h"
|
||||||
#include "XCEngine/Debug/ConsoleLogSink.h"
|
#include "XCEngine/Debug/ConsoleLogSink.h"
|
||||||
#include "XCEngine/Containers/String.h"
|
#include "XCEngine/Containers/String.h"
|
||||||
@@ -135,6 +136,9 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
|||||||
OpenGLSwapChain swapChain;
|
OpenGLSwapChain swapChain;
|
||||||
swapChain.Initialize(hwnd, gWidth, gHeight);
|
swapChain.Initialize(hwnd, gWidth, gHeight);
|
||||||
|
|
||||||
|
// Create command list for rendering commands
|
||||||
|
OpenGLCommandList commandList;
|
||||||
|
|
||||||
// Main render loop
|
// Main render loop
|
||||||
MSG msg = {};
|
MSG msg = {};
|
||||||
int frameCount = 0;
|
int frameCount = 0;
|
||||||
@@ -148,10 +152,9 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
|||||||
TranslateMessage(&msg);
|
TranslateMessage(&msg);
|
||||||
DispatchMessageW(&msg);
|
DispatchMessageW(&msg);
|
||||||
} else {
|
} else {
|
||||||
// Set viewport and clear color for each frame
|
// Set viewport and clear color using encapsulated command list
|
||||||
glViewport(0, 0, gWidth, gHeight);
|
commandList.SetViewport(0, 0, gWidth, gHeight);
|
||||||
glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
|
commandList.Clear(1.0f, 0.0f, 0.0f, 1.0f, 1 | 2);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
||||||
|
|
||||||
// Present the rendered frame
|
// Present the rendered frame
|
||||||
swapChain.Present(0, 0);
|
swapChain.Present(0, 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user