mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-21 21:05:50 +12:00
initialize and clear color
This commit is contained in:
parent
f0547d1a71
commit
e0fcfb44a8
1 changed files with 24 additions and 2 deletions
|
@ -1,5 +1,7 @@
|
||||||
#include "renderer_mtl/renderer_mtl.hpp"
|
#include "renderer_mtl/renderer_mtl.hpp"
|
||||||
|
|
||||||
|
#include "SDL_metal.h"
|
||||||
|
|
||||||
RendererMTL::RendererMTL(GPU& gpu, const std::array<u32, regNum>& internalRegs, const std::array<u32, extRegNum>& externalRegs)
|
RendererMTL::RendererMTL(GPU& gpu, const std::array<u32, regNum>& internalRegs, const std::array<u32, extRegNum>& externalRegs)
|
||||||
: Renderer(gpu, internalRegs, externalRegs) {}
|
: Renderer(gpu, internalRegs, externalRegs) {}
|
||||||
RendererMTL::~RendererMTL() {}
|
RendererMTL::~RendererMTL() {}
|
||||||
|
@ -9,11 +11,31 @@ void RendererMTL::reset() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RendererMTL::display() {
|
void RendererMTL::display() {
|
||||||
// TODO: implement
|
CA::MetalDrawable* drawable = metalLayer->nextDrawable();
|
||||||
|
|
||||||
|
MTL::CommandBuffer* commandBuffer = commandQueue->commandBuffer();
|
||||||
|
|
||||||
|
MTL::RenderPassDescriptor* renderPassDescriptor = MTL::RenderPassDescriptor::alloc()->init();
|
||||||
|
MTL::RenderPassColorAttachmentDescriptor* colorAttachment = renderPassDescriptor->colorAttachments()->object(0);
|
||||||
|
colorAttachment->setTexture(drawable->texture());
|
||||||
|
colorAttachment->setLoadAction(MTL::LoadActionClear);
|
||||||
|
colorAttachment->setClearColor(MTL::ClearColor{1.0f, 0.0f, 0.0f, 1.0f});
|
||||||
|
colorAttachment->setStoreAction(MTL::StoreActionStore);
|
||||||
|
|
||||||
|
MTL::RenderCommandEncoder* renderCommandEncoder = commandBuffer->renderCommandEncoder(renderPassDescriptor);
|
||||||
|
renderCommandEncoder->endEncoding();
|
||||||
|
|
||||||
|
commandBuffer->presentDrawable(drawable);
|
||||||
|
commandBuffer->commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RendererMTL::initGraphicsContext(SDL_Window* window) {
|
void RendererMTL::initGraphicsContext(SDL_Window* window) {
|
||||||
// TODO: implement
|
// TODO: what should be the type of the view?
|
||||||
|
void* view = SDL_Metal_CreateView(window);
|
||||||
|
metalLayer = (CA::MetalLayer*)SDL_Metal_GetLayer(view);
|
||||||
|
device = MTL::CreateSystemDefaultDevice();
|
||||||
|
metalLayer->setDevice(device);
|
||||||
|
commandQueue = device->newCommandQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RendererMTL::clearBuffer(u32 startAddress, u32 endAddress, u32 value, u32 control) {
|
void RendererMTL::clearBuffer(u32 startAddress, u32 endAddress, u32 value, u32 control) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue