added enable/disable vsync

This commit is contained in:
Sandro Sobczyński
2020-11-04 16:03:53 +01:00
parent aa6b2d314b
commit ef16f1dbe2
4 changed files with 8 additions and 5 deletions
+5 -2
View File
@@ -30,10 +30,13 @@ public:
~Renderer(); ~Renderer();
framebuffer_t frameBuffers[2]; framebuffer_t frameBuffers[2];
u8 context; u8 context; // TODO
zbuffer_t zBuffer; zbuffer_t zBuffer;
prim_t prim; prim_t prim;
void enableVSync() { isVSyncEnabled = true; }
void disableVSync() { isVSyncEnabled = false; }
/** PATH3 Many + lighting */ /** PATH3 Many + lighting */
void drawByPath3(Mesh *t_meshes, u16 t_amount, LightBulb *t_bulbs, u16 t_bulbsCount); void drawByPath3(Mesh *t_meshes, u16 t_amount, LightBulb *t_bulbs, u16 t_bulbsCount);
/** PATH3 Single + lighting */ /** PATH3 Single + lighting */
@@ -62,7 +65,7 @@ private:
void changeTexture(const Mesh &t_mesh, u32 t_materialId); void changeTexture(const Mesh &t_mesh, u32 t_materialId);
u32 lastTextureId; u32 lastTextureId;
texbuffer_t textureBuffer; texbuffer_t textureBuffer;
u8 isTextureVRAMAllocated; u8 isTextureVRAMAllocated, isVSyncEnabled;
void allocateTextureBuffer(u16 t_width, u16 t_height); void allocateTextureBuffer(u16 t_width, u16 t_height);
void deallocateTextureBuffer(); void deallocateTextureBuffer();
void flipBuffers(); void flipBuffers();
-2
View File
@@ -183,8 +183,6 @@ void Mesh::animate()
} }
} }
// TODO think about that, because in Ari sample it eats 88 FPS :O
u32 Mesh::getDrawData(u32 t_materialIndex, VECTOR *o_vertices, VECTOR *o_normals, VECTOR *o_coordinates, Vector3 &t_cameraPos) u32 Mesh::getDrawData(u32 t_materialIndex, VECTOR *o_vertices, VECTOR *o_normals, VECTOR *o_coordinates, Vector3 &t_cameraPos)
{ {
VECTOR ONE_VEC = {1.0F, 1.0F, 1.0F, 1.0F}; VECTOR ONE_VEC = {1.0F, 1.0F, 1.0F, 1.0F};
+2 -1
View File
@@ -37,6 +37,7 @@ Renderer::Renderer(u32 t_packetSize, ScreenSettings *t_screen)
dma_channel_fast_waits(DMA_CHANNEL_GIF); dma_channel_fast_waits(DMA_CHANNEL_GIF);
context = 0; context = 0;
isTextureVRAMAllocated = false; isTextureVRAMAllocated = false;
isVSyncEnabled = true;
isFrameEmpty = false; isFrameEmpty = false;
lastTextureId = 0; lastTextureId = 0;
flipPacket = packet_init(3, PACKET_UCAB); // Uncached accelerated flipPacket = packet_init(3, PACKET_UCAB); // Uncached accelerated
@@ -264,7 +265,7 @@ void Renderer::endFrame(float fps)
{ {
if (!isFrameEmpty) if (!isFrameEmpty)
{ {
if (fps > 49.0F) if (fps > 49.0F && isVSyncEnabled)
graph_wait_vsync(); graph_wait_vsync();
flipBuffers(); flipBuffers();
} }
+1
View File
@@ -34,6 +34,7 @@ void Ari::onInit()
{ {
engine->renderer->setCameraDefinitions(&camera.worldView, &camera.unitCirclePosition, camera.planes); engine->renderer->setCameraDefinitions(&camera.worldView, &camera.unitCirclePosition, camera.planes);
engine->renderer->disableVSync();
engine->audio.init(0); engine->audio.init(0);
engine->audio.setVolume(40); engine->audio.setVolume(40);
engine->audio.loadSong("MOV-CIRC.WAV"); engine->audio.loadSong("MOV-CIRC.WAV");