giawa / opengl4csharp

OpenGL 4 Bindings (partially based on OpenTK) for C#
Other
232 stars 61 forks source link

Texture Atlas #49

Closed ghost closed 4 years ago

ghost commented 4 years ago

Added a simple texture atlas to the Constructs folder as a child class of Texture.

TheAIBot commented 4 years ago

I can't quite understand how the Atlas is meant to work from just looking at the code so if you could elaborate then that would be great.

From the constructor i can see that it takes a pointer to a texture. Presumeably that's a pointer to the atlas texture pixel data. The Atlas texture has a width and height, but i don't quite understand the nor/NumberOfRows and what it's used for. Is it important that NumberOfRows is initialized to 1? I also don't understand what XOffset and YOffset compute and how i would use then in conjunction with my Atlas.

If possible could you show a short example of how you envision the Atlas to be used?

ghost commented 4 years ago

I can't quite understand how the Atlas is meant to work from just looking at the code so if you could elaborate then that would be great.

From the constructor i can see that it takes a pointer to a texture. Presumeably that's a pointer to the atlas texture pixel data. The Atlas texture has a width and height, but i don't quite understand the nor/NumberOfRows and what it's used for. Is it important that NumberOfRows is initialized to 1? I also don't understand what XOffset and YOffset compute and how i would use then in conjunction with my Atlas.

If possible could you show a short example of how you envision the Atlas to be used?

I am going to close this, as my class is pretty incomplete, but I am new to game development, and just recently learned about texture atlases. I am going to improve it and do another pull request later.