render
This commit is contained in:
@@ -3,20 +3,25 @@
|
|||||||
#include "opengl_command_runner.h"
|
#include "opengl_command_runner.h"
|
||||||
#include "commands/buffers/opengl_command_buffer.h"
|
#include "commands/buffers/opengl_command_buffer.h"
|
||||||
#include "framebuffer/opengl_framebuffer.h"
|
#include "framebuffer/opengl_framebuffer.h"
|
||||||
|
#include <string.h>
|
||||||
|
#include "buffer/opengl_buffer.h"
|
||||||
|
|
||||||
GN_CPP_FUNCTION void openglBeginRenderPass(gnCommandBuffer buffer, gnRenderPassInfo passInfo) {
|
GN_CPP_FUNCTION void openglBeginRenderPass(gnCommandBuffer buffer, gnRenderPassInfo passInfo) {
|
||||||
const char* func_name = "begin render pass";
|
gnClearValue* values = (gnClearValue*)malloc(sizeof(gnClearValue*) * passInfo.clearValueCount);
|
||||||
openglCommandRunnerBindFunction(buffer->commandBuffer->commmandRunner, std::function<void()>([passInfo]{
|
memcpy(values, passInfo.clearValues, sizeof(gnClearValue*) * passInfo.clearValueCount);
|
||||||
// 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);
|
openglCommandRunnerBindFunction(buffer->commandBuffer->commmandRunner, std::function<void()>([passInfo, values]{
|
||||||
// glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glBindFramebuffer(GL_FRAMEBUFFER, passInfo.framebuffer->framebuffer->framebuffers[0]);
|
||||||
// glEnable(GL_DEPTH_TEST);
|
glClearColor(values[0].r, values[0].g, values[0].b, values[0].a);
|
||||||
// glViewport(passInfo.offset.x, passInfo.offset.y, passInfo.size.x, passInfo.size.y);
|
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) {
|
GN_CPP_FUNCTION void openglEndRenderPass(gnCommandBuffer buffer) {
|
||||||
openglCommandRunnerBindFunction(buffer->commandBuffer->commmandRunner, std::function<void()>([]{
|
openglCommandRunnerBindFunction(buffer->commandBuffer->commmandRunner, std::function<void()>([]{
|
||||||
// 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);
|
||||||
|
@@ -18,6 +18,6 @@ const char * fragment_shader_source =
|
|||||||
"in vec2 texcoord;\n"
|
"in vec2 texcoord;\n"
|
||||||
"\n"
|
"\n"
|
||||||
"void main() {\n"
|
"void main() {\n"
|
||||||
" //FragColor = texture(tex, texcoord);\n"
|
" FragColor = texture(tex, texcoord);\n"
|
||||||
" FragColor = vec4(texcoord, 0.0, 1.0);\n"
|
" //FragColor = vec4(texcoord, 0.0, 1.0);\n"
|
||||||
"}\n" ;
|
"}\n" ;
|
||||||
|
@@ -24,7 +24,6 @@ gnReturnCode openglCreateFramebuffer(gnFramebuffer framebuffer, gnDevice device,
|
|||||||
});
|
});
|
||||||
return GN_FAILED_CREATE_OBJECT;
|
return GN_FAILED_CREATE_OBJECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return GN_SUCCESS;
|
return GN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@@ -9,33 +9,15 @@ gnReturnCode openglPresent(gnOutputDeviceHandle device, gnPresentInfo info) {
|
|||||||
|
|
||||||
glUseProgram(device->outputDevice->shaderProgram);
|
glUseProgram(device->outputDevice->shaderProgram);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, device->outputDevice->buffer);
|
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);
|
glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glUseProgram(0);
|
glUseProgram(0);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
swapBuffers(info.presentationQueues[i]->info.surface);
|
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++) {
|
// 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 ||
|
// 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) {
|
// info.presentationQueues[i]->info.imageSize.y != info.presentationQueues[i]->info.surface->windowSurface->layer.drawableSize.height) {
|
||||||
|
Reference in New Issue
Block a user