Note that there are some explanatory texts on larger screens.

plurals
  1. POOpenGL texture vs FBO
    primarykey
    data
    text
    <p>I am pretty new to OpenGL and just want some quick advice. I want to draw a tiled background for a game. I guess this means drawing a whole bunch of sprite like objects to the screen. I have about 48 columns to 30 rows, therefore 1440 tiles (tiles change depending on the game, so I can't pre-render the entire grid).</p> <p>Currently on start up I create 6 different FBO (using the <a href="http://ofxfenster.undef.ch/doc/classofFbo.html" rel="nofollow noreferrer">ofFbo</a> class from OpenFrameworks) that act as 6 different tiles. I then draw these buffers, up to a maximum of 1400 times, selecting one for each tile. So there are only ever 6 fbos, just being draw a lot of times. (The buffers are drawn to on start up, and are never changed once created).</p> <pre><code>for (int x=0; x&lt;columns; x++) { for (int y=0; y&lt;rows; y++) { // Get tile type and rotation from tile struct. tileNum = tile.form rotNum = tile.rot // Draw image/texture/fbo that's stored in a std vector. tileSet-&gt;draw(x*TILESIZE, y*TILESIZE, TILESIZE, TILESIZE); } } </code></pre> <p>I think I am going about this the wrong way, and was wondering if anyone new the best / optimal way to do this. Think something like an old school 8 bit video game background. Here is an image of my work in progress. </p> <p><img src="https://i.stack.imgur.com/KIQ8n.png" alt="work in progress"></p> <p>The structures in the background are the sprites i'm talking about, the different pieces are the inny corner, outty (concave) corner, square fill, and straight edge. Sorry for messing around with question.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COI think you must be confusing terms, or you don't understand what a FBO is for. You do not want to have 1440 FBOs in one scene, even more so as you will still have to bring the images on screen somehow (drawing into a FBO only draws into a non-visible surface unless it is incidentially the default FBO). Textured quads are what you want. Also, 5,000 microseconds is 5ms, which is quite acceptable as frame time (corresponding to about 200fps).
      singulars
    2. COYou have edited your question, but you're still not undestanding what an FBO is. And no, a texture is always stroed in video memory and doesn't have to be transfered every time. And yes, you're mistaken, in that I am completely unable to understand your question. Are you maybe talking about VBOs? If you are not sure, look up what these concepts are about and rephrase your question.
      singulars
    3. COHey, thanks for the feedback, I thought that might be the case. I don't have 1440 fbos, sorry I misworded that. I actually have 6, that are drawn out up to maximum of 1440 times. While 5,000 microseconds is quite good, I still am looking to speed it up a little. The game (with the characters and tile grid full) gets down to 30 fps, which is ok, but I wouldn't mind optimizing. The grid is the slowest part, so I thought it should be the first think I look into. I reworded question, thanks again.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload