Citro2d textures/vram/image-type/etc
Posted: Tue May 25, 2021 11:42 pm
I'd like to create a basic drawing app (just for fun) on the 3DS utilizing citro2d. I looked at many of the examples in devkitpro, and some examples on these forums. The one that is most intriguing is viewtopic.php?f=39&t=9071#p16777
I have several questions in regards to this code and code that uses these objects:
So from what I can gather, we create a subtexture, initialize vram for a 512x256 block in RGBA8 format and get back a pointer, create a target (which can be written to?) for that area in memory, and then... create an image from it with the subtexture describing it?
So my questions are:
I have several questions in regards to this code and code that uses these objects:
Code: Select all
const Tex3DS_SubTexture subtex = {
512, 256,
0.0f, 1.0f, 1.0f, 0.0f
};
C3D_Tex tex;
C3D_TexInitVRAM(&tex, 512, 256, GPU_RGBA8);
C3D_RenderTarget* target = C3D_RenderTargetCreateFromTex(&tex, GPU_TEXFACE_2D, 0, -1);
C2D_Image img = {&tex, &subtex};
So my questions are:
- Looking at the source code for "Tex3DS_SubTexture" makes it seem like it's just a struct that describes a region, is this correct?
- Initializing vram produces a texture, but this texture is... what, unusable in the current state, or not easily usable through the 2D library? Is that why we have to create a render target?
- What's the purpose of then creating an 'image' from the texture (but not the target) using the subtexture info? Looking at the code in the linked post, it looks to me like the render target is what I can write into, and the image is a different kind of "view" into the texture which can be used to draw the texture to the screen.
- I know resources are limited on the 3ds, but I was wondering if there are either practical or hard limits on contiguous textures? I noticed the fields for Tex3DS_SubTexture for width/height are 16 bit unsigned. If I'm not going to be putting basically ANYTHING else into vram (save for perhaps some smaller buffers), would it be possible for me to create a contiguous texture region that's, say, 320px wide by 4000px tall (RGBA8)?
- If the previous is possible, will it be completely inefficient to draw just a screen-sized region of this big texture onto the lower screen, or does the size of the texture not matter too much because I can specify a small region? Imagine the screen is a vertical sliding window on the 320x4000 texture.