command runner and some tests
This commit is contained in:
@@ -8,6 +8,7 @@ gnReturnCode openglCommandPoolAllocateCommandBuffers(gnCommandBufferHandle* comm
|
|||||||
if (pool->commandPool->canBeReallocated[c] == GN_TRUE) {
|
if (pool->commandPool->canBeReallocated[c] == GN_TRUE) {
|
||||||
pool->commandPool->canBeReallocated[c] = GN_FALSE;
|
pool->commandPool->canBeReallocated[c] = GN_FALSE;
|
||||||
commandBuffers[i]->commandBuffer = &pool->commandPool->commandBuffers[c];
|
commandBuffers[i]->commandBuffer = &pool->commandPool->commandBuffers[c];
|
||||||
|
commandBuffers[i]->commandBuffer->commmandRunner = openglCreateCommandRunner();
|
||||||
wasAbleToAllocate = GN_TRUE;
|
wasAbleToAllocate = GN_TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -21,18 +22,15 @@ gnReturnCode openglCommandPoolAllocateCommandBuffers(gnCommandBufferHandle* comm
|
|||||||
return GN_SUCCESS;
|
return GN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void openglResetCommandBuffer(gnCommandBuffer commandBuffer) {
|
void openglResetCommandBuffer(gnCommandBuffer commandBuffer) { /* nothing, for now command buffers are implictly reset on begin */ }
|
||||||
// commandBuffer->commandBuffer->
|
|
||||||
// nothing, for now command buffers are implictly reset on begin
|
|
||||||
}
|
|
||||||
gnReturnCode openglBeginCommandBuffer(gnCommandBuffer commandBuffer) {
|
gnReturnCode openglBeginCommandBuffer(gnCommandBuffer commandBuffer) {
|
||||||
commandBuffer->commandBuffer->commmandRunner = openglCreateCommandRunner();
|
openglResetCommandRunner(commandBuffer->commandBuffer->commmandRunner);
|
||||||
return GN_SUCCESS;
|
return GN_SUCCESS;
|
||||||
}
|
}
|
||||||
gnReturnCode openglEndCommandBuffer(gnCommandBuffer commandBuffer) {
|
gnReturnCode openglEndCommandBuffer(gnCommandBuffer commandBuffer) {
|
||||||
openglDestroyCommandRunner(commandBuffer->commandBuffer->commmandRunner);
|
|
||||||
return GN_SUCCESS;
|
return GN_SUCCESS;
|
||||||
}
|
}
|
||||||
void openglDestroyCommandBuffer(gnCommandBuffer commandBuffer) {
|
void openglDestroyCommandBuffer(gnCommandBuffer commandBuffer) {
|
||||||
commandBuffer->commandPool->commandPool->canBeReallocated[commandBuffer->commandBuffer->index] = GN_TRUE;
|
commandBuffer->commandPool->commandPool->canBeReallocated[commandBuffer->commandBuffer->index] = GN_TRUE;
|
||||||
|
openglDestroyCommandRunner(&commandBuffer->commandBuffer->commmandRunner);
|
||||||
}
|
}
|
||||||
|
@@ -1,8 +1,15 @@
|
|||||||
#include "opengl_command_runner.h"
|
#include "opengl_command_runner.h"
|
||||||
|
#include "vector"
|
||||||
|
|
||||||
typedef struct openglCommandRunner_t {
|
typedef struct openglCommandRunner_t {
|
||||||
|
std::vector<openglFunctionBinding> commands = {};
|
||||||
} glCommandRunner;
|
} glCommandRunner;
|
||||||
|
|
||||||
GN_CPP_FUNCTION openglCommandRunner openglCreateCommandRunner() { return new glCommandRunner(); }
|
GN_CPP_FUNCTION openglCommandRunner openglCreateCommandRunner() { return new glCommandRunner(); }
|
||||||
GN_CPP_FUNCTION void openglDestroyCommandRunner(openglCommandRunner runner) { delete runner; }
|
GN_CPP_FUNCTION void openglResetCommandRunner(openglCommandRunner runner) { runner->commands.clear(); }
|
||||||
|
GN_CPP_FUNCTION void openglDestroyCommandRunner(openglCommandRunner* runner) {
|
||||||
|
*runner = NULL;
|
||||||
|
delete runner;
|
||||||
|
}
|
||||||
|
|
||||||
|
void openglCommandRunnerBindFunction(openglCommandRunner runner, openglFunctionBinding binding) { runner->commands.push_back(binding); }
|
||||||
|
@@ -1,6 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "utils/gryphn_cpp_function.h"
|
#include "utils/gryphn_cpp_function.h"
|
||||||
typedef struct openglCommandRunner_t* openglCommandRunner;
|
typedef struct openglCommandRunner_t* openglCommandRunner;
|
||||||
|
typedef void (*openglFunctionBinding)();
|
||||||
|
|
||||||
GN_CPP_FUNCTION openglCommandRunner openglCreateCommandRunner();
|
GN_CPP_FUNCTION openglCommandRunner openglCreateCommandRunner();
|
||||||
GN_CPP_FUNCTION void openglDestroyCommandRunner(openglCommandRunner runner);
|
GN_CPP_FUNCTION void openglResetCommandRunner(openglCommandRunner runner);
|
||||||
|
GN_CPP_FUNCTION void openglDestroyCommandRunner(openglCommandRunner* runner);
|
||||||
|
|
||||||
|
void openglCommandRunnerBindFunction(openglCommandRunner runner, openglFunctionBinding binding);
|
||||||
|
@@ -1,8 +1,15 @@
|
|||||||
#include "glad/glad.h"
|
#include "glad/glad.h"
|
||||||
#include "opengl_commands.h"
|
#include "opengl_commands.h"
|
||||||
|
#include "opengl_command_runner.h"
|
||||||
|
#include "commands/buffers/opengl_command_buffer.h"
|
||||||
|
#include "stdio.h"
|
||||||
// #include "framebuffer/opengl_framebuffer.h"
|
// #include "framebuffer/opengl_framebuffer.h"
|
||||||
|
|
||||||
GN_CPP_FUNCTION void openglBeginRenderPass(gnCommandBuffer buffer, gnRenderPassInfo passInfo) {
|
GN_CPP_FUNCTION void openglBeginRenderPass(gnCommandBuffer buffer, gnRenderPassInfo passInfo) {
|
||||||
|
openglCommandRunnerBindFunction(buffer->commandBuffer->commmandRunner, []{
|
||||||
|
printf("Calling func: %s\n", "Begin Render Pass");
|
||||||
|
});
|
||||||
|
|
||||||
// glBindFramebuffer(GL_FRAMEBUFFER, passInfo.framebuffer->framebuffer->framebuffers[0]);
|
// glBindFramebuffer(GL_FRAMEBUFFER, passInfo.framebuffer->framebuffer->framebuffers[0]);
|
||||||
// glClearColor(passInfo.clearValues[0].r, passInfo.clearValues[0].g, passInfo.clearValues[0].b, passInfo.clearValues[0].a);
|
// glClearColor(passInfo.clearValues[0].r, passInfo.clearValues[0].g, passInfo.clearValues[0].b, passInfo.clearValues[0].a);
|
||||||
// glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
// glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
@@ -10,6 +17,10 @@ GN_CPP_FUNCTION void openglBeginRenderPass(gnCommandBuffer buffer, gnRenderPassI
|
|||||||
// glViewport(passInfo.offset.x, passInfo.offset.y, passInfo.size.x, passInfo.size.y);
|
// glViewport(passInfo.offset.x, passInfo.offset.y, passInfo.size.x, passInfo.size.y);
|
||||||
}
|
}
|
||||||
GN_CPP_FUNCTION void openglEndRenderPass(gnCommandBuffer buffer) {
|
GN_CPP_FUNCTION void openglEndRenderPass(gnCommandBuffer buffer) {
|
||||||
|
openglCommandRunnerBindFunction(buffer->commandBuffer->commmandRunner, []{
|
||||||
|
printf("Calling func: %s\n", "End Render Pass");
|
||||||
|
});
|
||||||
|
|
||||||
// glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
// glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
}
|
}
|
||||||
GN_CPP_FUNCTION void openglBindGraphicsPipeline(gnCommandBuffer buffer, gnGraphicsPipeline graphicsPipeline);
|
GN_CPP_FUNCTION void openglBindGraphicsPipeline(gnCommandBuffer buffer, gnGraphicsPipeline graphicsPipeline);
|
||||||
|
Reference in New Issue
Block a user