Is it possible to add functionality for drawing vertices?
E.g add simple struct like
and make function (e.g.)
void SDL_RenderDrawVertices(SDL_Texture*, SDL_Vertex*, int count);
where type of primitives will be always TRIANGLES (to cover all backends)
I know that there are a bunch of SDL_GL functions, but I want a cross-platform drawing of triangles (my goal is to add spine support in our project).
Just being able to draw a triangle would be nice. Sigh…
We do have (unstarted) plans to add something like this, but beyond the “it’s not available yet” problem is that we intend to tread into this extremely gently: the 2D render API fulfills extremely basic needs (think, like…Super Nintendo level rendering needs), and our own ventures into 3D are likely to be…Nintendo 64 level. The specific goals would likely be:
- Efficient upload of static geometry to vertex buffers
- Rendering of textured polygons from those buffers
Just like the 2D API, as soon as we ship it, people are going to want more features, which is understandable, but a problem, because after a while we’d just be building OpenGL from scratch.
If you want cross-platform, 3D rendering, my recommendations are this:
- Use OpenGL ES 2.0. Most platforms support it natively (mobile, embedded, some desktop drivers), or can be coerced to mostly look like it (OpenGL Core Profile on desktops, Emscripten cleanly converts it to WebGL for you), or are supported by ANGLE to provide GLES2 and convert it to Direct3D/Vulkan/whatever behind the scenes. This covers the needs of 95% of game developers that don’t need cutting-edge features but still want most of the modern luxuries of GPUs, including vertex buffers and shaders. If your needs are greater, creep carefully towards GLES3, but almost anything reasonable, from supercomputers to a Raspberry Pi, can definitely do GLES2 well at this point.
- Use bgfx. One cross-platform API that targets OpenGL/GLES/Direct3D/Vulkan/Metal/whatever behind the scenes, and exposes all the GPU functionality you’d likely want. It’s C++ but has optional C bindings. Shaders are cooked down for each rendering API, so generally don’t plan to generate custom GLSL at runtime or whatever.
- Probably don’t target Vulkan directly, as support is still growing, and it’s just sort of unpleasant to write for. A wrapper over it (ANGLE or bgfx or whatever) makes a lot of sense in 2020, though, so those with Vulkan-compatible hardware can take advantage of it.
Our policy with the 2D API was “use this if your needs are simple, and if your needs stop being simple, start using OpenGL directly,” but in modern times, I’m thinking that we should start saying “bgfx” instead of “OpenGL” here, but ymmv.
I don’t want any 3d API and I didn’t even think to suggest complicating the API.
I just want to draw textures in more flexible way, than “draw rectangle source to rectangle destination”.
For OpenGL ES 2, DirectX 9, DirectX 11 it looks like it is very easy to add.
For plane OpenGL we need to rewrite the entire backend to modern way (immediate mode in 2k20? ).
The ability to draw simple triangles will allow us to use 2D skeletal animation and spine out of the box, without any additional library, such as ANGLE or bgfx.
For my needs, I can implement OpenGL ES 2 and DirectX 9 myself, but I thought that this functionality would suit all users.
And finally, if in the future I need 3D - I will take one large U-engine.
But if it looks complicated - well, let’s just close the topic.
Oh, you just want a 2D triangle? We can probably swing that more easily.
My understanding has been that although this is trivial for all the accelerated backends, it’s not so easy for the software renderer. Is that still the case (if it ever was)?
We would definitely have to write it, but 2D polygons are a different beast than 3D ones.
To port my last game to Android all I need is to be able to draw a solid triangle in any RGB colour. I don’t need any texture, just all one solid colour is all I need!