nglVideo - an alternative to videoGL (update 2/17/11)
Posted: Thu Jul 01, 2010 5:49 am
(2/17/11)
Now that nglVideo has been integrated into libnds, these separate libraries are no longer needed. The ability to choose to have textures be manually allocated (by when the texture was ready to be copied) was not included, as it not only wasn't something openGL would do (since I wanted this to approximate it), but it also bloated the code a little and forced more processing for very little benefit, if any. Everything else is included.
I'll keep the original post here as a reference.
-----------------------------------------------------------------------------
(1/5/11)
(By request, the source is now available)
Some of you may remember me sending in a modified version of the videoGL.c file to the devkitPro team for review, which included a few bug fixes and my own version of dynamic texture allocation. Well, my brain began spinning once again, and I tried my hand again at an alternative to the videoGL functionality.
What came about from this is the nglVideo library, a separate set of functions which contains most of the functions that videoGL contained, removing some here and adding some there. So, what does this library do that videoGL does not?
- Texture AND texture palette dynamic allocation
- Allocation based on current state of video banks (if a video bank is not allocated to textures or texture palettes, the allocator ignores that bank and moves to the next one)
- Textures can be deleted, so no need to always reset the entire system.
- ALL DS-native formats supported, including GL_COMPRESSED
- Textures can be directly sent to video memory (GL_COMPRESSED textures automatically do), or can be in main memory in preparation for use in video memory when they are needed (manually called atm, but perhaps a change to dynamically later on)
I would consider this an alpha version, because there are still a few things that need to be done, such as if vram banks are not in sequential order (like VRAM_B takes up slot0 and VRAM_A takes slot1).
I've supplied the library and an example below. The functions called, for the most part, have an 'n' appended to the start of the functions, to differentiate themselves from their videoGL counterparts. As for the rest of the gl-like functions found in video.h, they can be used in conjunction with nglVideo because they do not have any direct association with functions in videoGL.
Library [Mirror]
Example [Mirror]
Source [Mirror]
The example project included is basically the Palette Cube example in libnds, but the functions are changed, and it also includes the compressed texture made by kusma (credit goes to him for that and his texture converter that generated the texture).
Note: When using GL_COMPRESSED textures, if the texture 'tiles' and 'header' are separate files, then they need to be combined together, the 'tiles' first, then the 'header', before using the call nglTexImage2D. Also, it is best to load the GL_COMPRESSED texture first unless you do manual video bank assigning to prevent the allocator from using certain banks when loading normal textures first, because if VRAM_B doesn't have enough space or if VRAM_A and VRAM_C don't have enough space, the compressed textures won't be loaded up.
Now that nglVideo has been integrated into libnds, these separate libraries are no longer needed. The ability to choose to have textures be manually allocated (by when the texture was ready to be copied) was not included, as it not only wasn't something openGL would do (since I wanted this to approximate it), but it also bloated the code a little and forced more processing for very little benefit, if any. Everything else is included.
I'll keep the original post here as a reference.
-----------------------------------------------------------------------------
(1/5/11)
(By request, the source is now available)
Some of you may remember me sending in a modified version of the videoGL.c file to the devkitPro team for review, which included a few bug fixes and my own version of dynamic texture allocation. Well, my brain began spinning once again, and I tried my hand again at an alternative to the videoGL functionality.
What came about from this is the nglVideo library, a separate set of functions which contains most of the functions that videoGL contained, removing some here and adding some there. So, what does this library do that videoGL does not?
- Texture AND texture palette dynamic allocation
- Allocation based on current state of video banks (if a video bank is not allocated to textures or texture palettes, the allocator ignores that bank and moves to the next one)
- Textures can be deleted, so no need to always reset the entire system.
- ALL DS-native formats supported, including GL_COMPRESSED
- Textures can be directly sent to video memory (GL_COMPRESSED textures automatically do), or can be in main memory in preparation for use in video memory when they are needed (manually called atm, but perhaps a change to dynamically later on)
I would consider this an alpha version, because there are still a few things that need to be done, such as if vram banks are not in sequential order (like VRAM_B takes up slot0 and VRAM_A takes slot1).
I've supplied the library and an example below. The functions called, for the most part, have an 'n' appended to the start of the functions, to differentiate themselves from their videoGL counterparts. As for the rest of the gl-like functions found in video.h, they can be used in conjunction with nglVideo because they do not have any direct association with functions in videoGL.
Library [Mirror]
Example [Mirror]
Source [Mirror]
The example project included is basically the Palette Cube example in libnds, but the functions are changed, and it also includes the compressed texture made by kusma (credit goes to him for that and his texture converter that generated the texture).
Note: When using GL_COMPRESSED textures, if the texture 'tiles' and 'header' are separate files, then they need to be combined together, the 'tiles' first, then the 'header', before using the call nglTexImage2D. Also, it is best to load the GL_COMPRESSED texture first unless you do manual video bank assigning to prevent the allocator from using certain banks when loading normal textures first, because if VRAM_B doesn't have enough space or if VRAM_A and VRAM_C don't have enough space, the compressed textures won't be loaded up.