You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Apologies if this is a dumb question, but I'm using SDL for window management and OpenGL for rendering, and I want to use SDL for texture loading rather than adding another dependency for something SDL is already capable of.
I know I should be able to use Texture.gl_bind_texture() to actually use the texture, but how can I load the texture in the first place if it requires a TextureCreator which in turn requires a Canvas? Would I really need to create a canvas I'm not going to use in order to accomplish this, or am I missing something?
I found mention of this here which makes me think it's possible, but I'm not sure how to accomplish it:
I am just using SDL2 to manage the window and the textures, while all the rendering is done with my own renderer that is using OpenGL ES 2 with no SDL2 involved at that stage except for retrieving the handle to the actual texture.
Again sorry if it's not a great question - it's just difficult finding documentation for this specific combination.
The text was updated successfully, but these errors were encountered:
So I only know the theory but I haven't actually used gl_bind_texture myself.
In short it depends what you mean by "rendering".
A Canvas is necessary to create a Texture, because texture does not make sense without one. It's simply a pointer to a specific implementation of hardware-accelerated texture inside your graphic card (so OpenGL texture, DirectX texture, ...). You can't just load a Texture by itself, because without a Canvas it doesn't know what backend to target.
If your "rendering" part is simply your custom vertex/fragment shaders, then you can initialize a Canvas via SDL2, then use TextureCreator to create textures, call gl_bind_texture whenever necessary and it should mostly work. I think you are "tied" to whatever version of OpenGL SDL2 uses for you, but you may have ways to configure that via https://docs.rs/sdl2/0.34.5/sdl2/video/gl_attr/index.html .
If you absolutely want to initialize your context then use a Canvas on top of that, then I don't think it is possible.
But honestly this is thin ice, I would advise you to simply not bother with the rendering side of SDL2 if you already have your implementation, and use a crate like image for texture loading, if you already know OpenGL with ~50 lines of code you can make something basic that still works very well.
Apologies if this is a dumb question, but I'm using SDL for window management and OpenGL for rendering, and I want to use SDL for texture loading rather than adding another dependency for something SDL is already capable of.
I know I should be able to use
Texture.gl_bind_texture()
to actually use the texture, but how can I load the texture in the first place if it requires aTextureCreator
which in turn requires aCanvas
? Would I really need to create a canvas I'm not going to use in order to accomplish this, or am I missing something?I found mention of this here which makes me think it's possible, but I'm not sure how to accomplish it:
Again sorry if it's not a great question - it's just difficult finding documentation for this specific combination.
The text was updated successfully, but these errors were encountered: