This commit is contained in:
Gregory Wells
2025-08-19 08:39:29 -04:00
parent 740cf1e628
commit 55605b6d5f
4 changed files with 18 additions and 32 deletions

View File

@@ -3,20 +3,25 @@
#include "opengl_command_runner.h"
#include "commands/buffers/opengl_command_buffer.h"
#include "framebuffer/opengl_framebuffer.h"
#include <string.h>
#include "buffer/opengl_buffer.h"
GN_CPP_FUNCTION void openglBeginRenderPass(gnCommandBuffer buffer, gnRenderPassInfo passInfo) {
const char* func_name = "begin render pass";
openglCommandRunnerBindFunction(buffer->commandBuffer->commmandRunner, std::function<void()>([passInfo]{
// 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);
// glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// glEnable(GL_DEPTH_TEST);
// glViewport(passInfo.offset.x, passInfo.offset.y, passInfo.size.x, passInfo.size.y);
gnClearValue* values = (gnClearValue*)malloc(sizeof(gnClearValue*) * passInfo.clearValueCount);
memcpy(values, passInfo.clearValues, sizeof(gnClearValue*) * passInfo.clearValueCount);
openglCommandRunnerBindFunction(buffer->commandBuffer->commmandRunner, std::function<void()>([passInfo, values]{
glBindFramebuffer(GL_FRAMEBUFFER, passInfo.framebuffer->framebuffer->framebuffers[0]);
glClearColor(values[0].r, values[0].g, values[0].b, values[0].a);
glClear(GL_COLOR_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
glViewport(passInfo.offset.x, passInfo.offset.y, passInfo.size.x, passInfo.size.y);
free(values);
}));
}
GN_CPP_FUNCTION void openglEndRenderPass(gnCommandBuffer buffer) {
openglCommandRunnerBindFunction(buffer->commandBuffer->commmandRunner, std::function<void()>([]{
// glBindFramebuffer(GL_FRAMEBUFFER, 0);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}));
}
GN_CPP_FUNCTION void openglBindGraphicsPipeline(gnCommandBuffer buffer, gnGraphicsPipeline graphicsPipeline);

View File

@@ -18,6 +18,6 @@ const char * fragment_shader_source =
"in vec2 texcoord;\n"
"\n"
"void main() {\n"
" //FragColor = texture(tex, texcoord);\n"
" FragColor = vec4(texcoord, 0.0, 1.0);\n"
" FragColor = texture(tex, texcoord);\n"
" //FragColor = vec4(texcoord, 0.0, 1.0);\n"
"}\n" ;

View File

@@ -24,7 +24,6 @@ gnReturnCode openglCreateFramebuffer(gnFramebuffer framebuffer, gnDevice device,
});
return GN_FAILED_CREATE_OBJECT;
}
}
return GN_SUCCESS;
}

View File

@@ -9,33 +9,15 @@ gnReturnCode openglPresent(gnOutputDeviceHandle device, gnPresentInfo info) {
glUseProgram(device->outputDevice->shaderProgram);
glBindBuffer(GL_ARRAY_BUFFER, device->outputDevice->buffer);
glBindTexture(GL_TEXTURE_2D, GLuintArrayListAt(info.presentationQueues[i]->presentationQueue->textures, info.imageIndices[i]));
glDrawArrays(GL_TRIANGLES, 0, 6);
glActiveTexture(GL_TEXTURE0);
glUseProgram(0);
glBindTexture(GL_TEXTURE_2D, 0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
swapBuffers(info.presentationQueues[i]->info.surface);
// id<MTLBlitCommandEncoder> blit = [commandBuffer blitCommandEncoder];
// [blit copyFromTexture:info.presentationQueues[i]->images[info.imageIndices[i]]->texture->texture
// sourceSlice:0
// sourceLevel:0
// sourceOrigin:(MTLOrigin){0, 0, 0}
// sourceSize:(MTLSize){info.presentationQueues[i]->info.imageSize.x, info.presentationQueues[i]->info.imageSize.y, 1}
// toTexture:drawable.texture
// destinationSlice:0
// destinationLevel:0
// destinationOrigin:(MTLOrigin){0, 0, 0}];
// [blit endEncoding];
// [drawable texture];
// [commandBuffer presentDrawable:drawable];
// [commandBuffer commit];
// device->outputDevice->executingCommandBuffer = commandBuffer;
}
// [device->outputDevice->executingCommandBuffer waitUntilCompleted];
// for (uint32_t i = 0; i < info.presentationQueueCount; i++) {
// if (info.presentationQueues[i]->info.imageSize.x != info.presentationQueues[i]->info.surface->windowSurface->layer.drawableSize.width ||
// info.presentationQueues[i]->info.imageSize.y != info.presentationQueues[i]->info.surface->windowSurface->layer.drawableSize.height) {