Jump to content

  • Log In with Google      Sign In   
  • Create Account


Rendering to a texture (not for post-processing fx)


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 reaperrar   Members   -  Reputation: 133

Like
0Likes
Like

Posted 22 January 2013 - 05:58 PM

Trying to set up a class which renders text to a texture (specifically in 2D). I have text rendering atm but obviously if the string never changes I could save on performance a lot by rendering the static text into a single texture.

 

I got it working to some degree, though I have another post about that issue which I think is unrelated to this post...

http://www.gamedev.net/topic/637666-render-target-alpha-blending/

 

I'm posting this to ask if these are the normal steps you would take to acheive this:

  1. Disable depth & stencil testing (2D)
  2. Enable alpha blending
  3. Set up projection to accomodate text block dimensions
  4. Set up render target texture2D to accomodate text block dimensions
  5. Set up viewport to accomodate text block dimensions
  6. EDIT: Clear render target (forgot to mention that, ty L.Spiro for reminding me)
  7. Render text into texture
  8. Set back to default projection, view port and render target

One thing I forgot when following these steps was that textures dimensions are supposed to a power of 2. Though it appeared to render undistorted (text block dimensions were not a power of 2 or even close).


Edited by reaperrar, 22 January 2013 - 08:17 PM.


Sponsor:

#2 L. Spiro   Crossbones+   -  Reputation: 12334

Like
1Likes
Like

Posted 22 January 2013 - 06:20 PM

You should also clear the render target before rendering onto it.  Making sure that the clear color is 0x00000000 (0 alpha).

And as long as you are not using mipmaps your textures do not need to be a power of 2 unless you decide for personal reasons they should be.

 

 

L. Spiro


It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#3 kauna   Crossbones+   -  Reputation: 2167

Like
0Likes
Like

Posted 22 January 2013 - 09:08 PM

And as long as you are not using mipmaps your textures do not need to be a power of 2 unless you decide for personal reasons they should be.

 

Can you elaborate this? I don't see an immediate issue with non-power-of-two mipmapped texture or render target. 

 

Cheers!



#4 L. Spiro   Crossbones+   -  Reputation: 12334

Like
0Likes
Like

Posted 23 January 2013 - 01:51 AM

It is just a restriction on a few API’s/older hardware.  These days you will likely not see a problem with non-power-of-2 mip-mapped textures.

I didn’t mean that mip-mapped textures won’t work unless power-of-2, but that if you aren’t using mip-maps you won’t run into any problems on any hardware/API’s.  It’s just a safety check.

 

 

L. Spiro


It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS