how to draw to OpenGL texture

Member
Posts: 73
Joined: 2009.03
Post: #1
I would like to be able to draw to a texture that already exists if possible.

As a secondary option, to create a new image and use it to create an OpenGL texture (I think I could figure out #2 on my own, but prefer #1).

Does anyone have any information about drawing to existing textures?

My immediate goal is to create a mini-map for a randomly generated map, so the mini-map graphics needs to be created dynamically. I'm thinking of only plotting single pixels for the mini-map, not drawing images onto it.

Thanks...
Quote this message in a reply
Moderator
Posts: 613
Joined: 2004.09
Post: #2
Edit: Didn't read closely.

Kyle Richter
DragonForged.com
Twitter: @kylerichter
Quote this message in a reply
Apprentice
Posts: 14
Joined: 2009.04
Post: #3
You could use an FBO (look on this forum for code how to do it), draw your original texture into it on a quad and then draw your dynamically generated graphics on top of it. Do this once and then bind it as a texture.
Quote this message in a reply
Member
Posts: 306
Joined: 2009.03
Post: #4
To draw a mini map pixel by pixel where each pixel is rendered because of how some world map looks, you could have a size 1 polygon with a white texture on it and then use glColor4f to set the color. Then draw that pixel AxB times where a and b are your minimap dimensions. This would create a lot of polygons so I don't know if its a good way to do it or not.
Quote this message in a reply
Member
Posts: 73
Joined: 2009.03
Post: #5
saltwater Wrote:You could use an FBO (look on this forum for code how to do it), draw your original texture into it on a quad and then draw your dynamically generated graphics on top of it. Do this once and then bind it as a texture.

A quick forum search on "FBO" turned up nothing. I don't know what that stands for.

I'll probably end up just creating a graphics context, drawing to it, then making a texture out of it. I was hoping there would be an easy way to draw on an existing texture so I could re-use a small section of an existing larger texture, so I have less textures being used overall.
Quote this message in a reply
Member
Posts: 166
Joined: 2009.04
Post: #6
Gillissie Wrote:A quick forum search on "FBO" turned up nothing. I don't know what that stands for.

I'll probably end up just creating a graphics context, drawing to it, then making a texture out of it. I was hoping there would be an easy way to draw on an existing texture so I could re-use a small section of an existing larger texture, so I have less textures being used overall.

http://en.wikipedia.org/wiki/Framebuffer_Object
Quote this message in a reply
Apprentice
Posts: 14
Joined: 2009.04
Post: #7
Argh, sorry about that, the search on this forum is the worst, it makes you wait 45 seconds between searches and it doesn't find anything.

Anyway I found the post using google and site:idevgames.com:
http://www.idevgames.com/forum/showthread.php?t=17125
There is also an article on gamedev.net explaining it better. It's written for regular OpenGL but replacing the EXT by OES in the function names (in regular OpenGL FBOs are an extension, in OpenGL ES not)
http://www.gamedev.net/reference/article...le2331.asp
Quote this message in a reply
Moderator
Posts: 3,570
Joined: 2003.06
Post: #8
saltwater Wrote:Argh, sorry about that, the search on this forum is the worst, it makes you wait 45 seconds between searches and it doesn't find anything. ...

Don't use the forum search, use Google instead! To localize your Google search to iDevgames, use the "site" command like so:

fbo site:idevgames.com

[edit] Just noticed you already did that.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  opengl es strange 16bit texture scale problem spuckfunkel 6 8,612 Aug 14, 2011 10:44 PM
Last Post: headkaze
  Increasing brightness of texture in OpenGL dsedov 3 5,686 Jul 29, 2009 03:00 PM
Last Post: arekkusu
  How to draw glowing edges in OpenGL ES miq01 9 10,156 Mar 29, 2009 11:42 AM
Last Post: miq01
  OpenGl ES Texture Problems jhbau1000 4 4,042 Mar 24, 2009 02:41 PM
Last Post: AnotherJake
  OpenGL - how to draw background image? SDyer777 1 7,050 Mar 9, 2009 11:17 AM
Last Post: AnotherJake