Going back to your fixed 80*50 grid mesh idea, you can do this with a static mesh buffer, a static texture, and a dynamic buffer of glyph ID's. You make a static mesh, that contains a quad (or two tris) for each grid cell. Every vert can have a static texcoord that identifies which corner of the glyph it represents (e.g. 2D values of [-1,-1],[1,-1],[1,1] or [-1,1] or alternatively simply 1D values of 0,1,2 or 3) and a secondary 1D texcoord that identifies which 'cell' the vert belongs to. If theres 80*50 cells, then this cell-ID ranges from 0-3999. You can fit the corner-ID in a single byte (for the 1D version, or two bytes for the 2D version), the cell-ID in a 16-bit int. Then your dynamic data consists of specifying which glyph should appear in which cell. Assuming you only need 256 glyphs, then this is one byte per cell, or 4000 bytes. All of your glyphs can be stored on a static texture sheet -- e.g. a 256*256 texture gives you 256 glyphs at 16*16 resolution. In the vertex shader, you read the vertex's cell-ID, use that to fetch the glyph-ID that should appear in that cell, convert the glyph-ID into the texture-coordinate at the centre of the glyph. Then once you've got this glyph-centre tex-coord, you use the vertex's corner-ID to offset it to the appropriate corner of the glyph. That sounds like it should work, and should perform fine. If you're struggling with specific implementation details, ask below ;) ---------- [edit] As an alternative implementation: You could have a static grid mesh that only contains positions for the verts and an index buffer so you're not repeating yourself (there's 6 verts per two-tri-quad, but only 4 unique values -- so you write the 4 values into a vertex buffer, and then write 6 indices into an index buffer). Then you make a dynamic vertex buffer for storing the UV coordinates. If your text isn't super-high resolution, then these can be stored as two bytes per UV. On the CPU, you determine which glyph appears in each cell, and write the 4 corner UV's for that glyph into your dynamic vertex buffer. When rendering, you bind both the static position buffer and the dynamic tex-coord buffer. The size of the dynamic data is 80*50*2, or 8KiB, which is still tiny. Most games that I've worked on have use the above implementation, except that both positions and tex-coords are dynamic and are generated by the CPU every frame.
Thank you!
Though i am having a hard time following along with your description (too technical for me, i am still a newbie at D3D, SlimDX and shaders. (Or at least i consider myself to be one)
I will read through it several times to see if i can understand it any better but the first two questions that spring to mind is:
1. How would this look in shader code, should i declare an array and use that to determine which texture coordinates i need in shader code? Please show me an example of what i need to do here since i have no idea at all.
2. An example in code would be nice too, i know there are lots of different types of resources i can update but i am not so sure about arrays. Do i even send arrays? Maybe i just send an 8 bit texture?
Like i said, i am pretty clueless and i figure stuff out as i go.
------
That aside, I've managed to pass a 2048x2048 texture to my GPU and am testing by rebuilding the entire vertex buffer every frame.
Currently i have a 200 x 200 grid of quads that are fed random tu and tv values each update and i am running at 77 FPS. That is beyond expectations for me, i have never been able to run so fast before.
I am using a GeForce GTX580 and an I7 at ~3.6 GHz in case anyone wants to know.
Mind you, this is the first crude testing. I don't intend to update the entire vertex buffer like this but only the texture values (something i still have to figure out how to do unless someone shows me how) and eventually optimize that down to one byte per character.
As of current with some quickie math...
201x201x6 vertices = 242,406 vertices per frame-
vertex data size is 24 so that's 5,817,744 per frame. (or ~5.5 MB per frame)
Running at 77 FPS, that's 427.21 MB/s sent to the GPU. What a waste but this is just how i work, it helps me organize and think ahead since i never actually plan ahead that much.
Edit:
Oh and i think (if it's possible) i am going to have a static char buffer so if it isn't updated at all then it would reuse the old one already present on the GPU. In case it wasn't clear before.
Which brings up another question, say i want to alter a specific row and/or a specific column or region etc in my little console window. It's possible to just update a portion of the char array without having to update the whole buffer/whatever right?
I like performance and say i wanted to make some sort of ASCII animation on the virtual screen without updating the entire thing then that would be possible too right?