Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17825

Is the interface of my api agnostic rendering layer well designed?

$
0
0
Hey guys, I hope this is an appropriate question. Well, I tried to design a little part of my rendering layer. bgfx oriented. Question: Is this good design? And what changes would you suggest? vboID CreateDynamicVertexBuffer(VertexBatch, Duration); vboID CreateStaticVertexBuffer(VertexBatch, Duration); void UpdateVertexBuffer(vboID); void DeleteVertexBuffer(vboID); - My interface works with IDs that are structs for type safety . An ID maps to something the corresponding method(s) can interpret. It doesn't necessarily map to OpenGL handles etc. A create* method yields a valid ID. If the creation fails an exception is thrown. - VertexBatch is responsible for capturing the vertex data. It provides convenient OpenGL Intermediate Mode syntax. It has no virtual methods because it needs to be fast. - Duration is an enum that lets you specify how long the data will remain on the GPU memory. The reason is that I can batch static level geometry together in one big Vertex Buffer and just return the offset into this buffer. Other types of memory can be handled differently, but I don't know how... Question: How do you normally handle this scenario and what is with data that frequently changes? - Dynamic Vertex Buffer cannot be updated, StaticVertexBuffer can. - If a vboID is deleted I may or may not destroy the underlying resource. Depends on the type of memory (frequently changing etc.) If this question somehow doesn't belong here, it's okay Thank you Jan

Viewing all articles
Browse latest Browse all 17825

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>