<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>OpenGL, copy screen to texture</title>
		<link>http://www.allegro.cc/forums/view/597340</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Wed, 13 Aug 2008 19:51:33 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I want to create some shaking/rotating and transition effects using OpenGl and the first thing I need is to get a copy of the screen and store it into a texture.</p><p>In other words, I basically want to take a screenshot and save it into a texture, once I get it I could easily draw it to the screen with some additional effects.</p><p>I am using AllegroGL, and just learning OpenGL, so I don&#39;t really have idea how to do this, any help is appreciated.</p><p>Thanks in advance.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Paul whoknows)</author>
		<pubDate>Mon, 11 Aug 2008 01:42:10 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I recommend <a href="http://www.opengl.org/registry/specs/EXT/framebuffer_object.txt">framebuffer objects</a>. You just need a small bit of easily-wrappable boilerplate code and they Just Work<sup>TM</sup> (and fast, too).<br />Short tutorial: <a href="http://www.gamedev.net/reference/articles/article2331.asp">http://www.gamedev.net/reference/articles/article2331.asp</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (gnolam)</author>
		<pubDate>Mon, 11 Aug 2008 01:59:43 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thanks gnolam!, but I prefer to use only basic OpenGL functions at the moment.<br />Well, searching in the forum I&#39;ve found this is an easy way to do it:</p><div class="source-code snippet"><div class="inner"><pre>glBindTexture<span class="k2">(</span>GL_TEXTURE_2D, background<span class="k2">)</span><span class="k2">;</span>
glCopyTexImage2D<span class="k2">(</span>GL_TEXTURE_2D,<span class="n">0</span>,GL_RGB,<span class="n">0</span>,<span class="n">0</span>,<span class="n">512</span>,<span class="n">512</span>,<span class="n">0</span><span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

Now, the problem is that my game screen is 800x600 but I can only use power of two  sized textures <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Paul whoknows)</author>
		<pubDate>Mon, 11 Aug 2008 02:58:15 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Note that for offscreen rendering, using an aux buffer instead of the back/front-buffer would be preferred (though FBOs would be preferred above those).
</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Now, the problem is that my game screen is 800x600 but I can only use power of two sized textures
</p></div></div><p>
glViewport is your friend. Though you&#39;ll still be limitted to texture sizes that are the next lower power-of-2 (unless you have GL_ARB_texture_non_power_of_two, then it can be whatever size). That&#39;s just the price you pay for using an old offscreen rendering method.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kitty Cat)</author>
		<pubDate>Mon, 11 Aug 2008 12:47:14 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Now, the problem is that my game screen is 800x600 but I can only use power of two sized textures
</p></div></div><p>
Maybe CopyTexSubImage2D to a 1024x1024 texture? With a fallback to copy to [however many smaller textures are necessary] if your card can&#39;t handle a texture that size (which would probably mean that it&#39;s a decade old)?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Harte)</author>
		<pubDate>Mon, 11 Aug 2008 13:52:34 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Already solved the problem using this:</p><div class="source-code snippet"><div class="inner"><pre><span class="c">/* Set viewport so it matches the size of our texture*/</span>
glViewport<span class="k2">(</span><span class="n">0</span>,<span class="n">0</span>,<span class="n">1024</span>,<span class="n">1024</span><span class="k2">)</span><span class="k2">;</span>  
<span class="c">/* Target texture */</span>
glBindTexture<span class="k2">(</span>GL_TEXTURE_2D, tex<span class="k2">)</span><span class="k2">;</span>
<span class="c">/* Copy screen to a 1024x1024 texture */</span>
glCopyTexImage2D<span class="k2">(</span>GL_TEXTURE_2D,<span class="n">0</span>,GL_RGB,<span class="n">0</span>,<span class="n">0</span>,<span class="n">1024</span>,<span class="n">1024</span>,<span class="n">0</span><span class="k2">)</span><span class="k2">;</span>
<span class="c">/* Restore viewport (in our case to 800x600)*/</span>
glViewport<span class="k2">(</span><span class="n">0</span>,<span class="n">0</span>,<span class="n">800</span>,<span class="n">600</span><span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

This is amazing! I can copy the screen and blit it with different effects more than 15 times per frame(at 60Hz) without any drop in the frame rate in my cheap FX5700LE <img src="http://www.allegro.cc/forums/smileys/shocked.gif" alt=":o" /></p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Note that for offscreen rendering, using an aux buffer instead of the back/front-buffer would be preferred (though FBOs would be preferred above those).
</p></div></div><p>

Sorry if this is a stupid question but what is FBO? I mean is another library?, an add-on? is it compatible with old video cards? <br />	
</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Maybe CopyTexSubImage2D to a 1024x1024 texture? With a fallback to copy to [however many smaller textures are necessary] if your card can&#39;t handle a texture that size (which would probably mean that it&#39;s a decade old)?
</p></div></div><p>

My game now needs to able to create at least one 1024x1024 texture, that means that it will not run in old graphics cards. It is really important to me to know which video cards doesn&#39;t support this texture size, is there a list or something where I can find this information?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Paul whoknows)</author>
		<pubDate>Mon, 11 Aug 2008 20:44:35 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
what is FBO?
</p></div></div><p>
<a href="http://opengl.org/registry/specs/EXT/framebuffer_object.txt">Framebuffer Objects</a>. It allows you to render to a user-specified renderbuffer, or directly to a texture.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
It is really important to me to know which video cards doesn&#39;t support this texture size
</p></div></div><p>
<span class="source-code">glGetIntegerv<span class="k2">(</span>GL_MAX_TEXTURE_SIZE, <span class="k3">&amp;</span>size<span class="k2">)</span><span class="k2">;</span></span><br />Will give the maximum texture size the card can support.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kitty Cat)</author>
		<pubDate>Mon, 11 Aug 2008 21:24:55 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &amp;size);<br />Will give the maximum texture size the card can support.
</p></div></div><p>
According to the docs, it&#39;ll only give &quot;a rough estimate of the largest texture that the GL can handle&quot;.
</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
My game now needs to able to create at least one 1024x1024 texture, that means that it will not run in old graphics cards. It is really important to me to know which video cards doesn&#39;t support this texture size, is there a list or something where I can find this information?
</p></div></div><p>
I&#39;ve seen at least one, but for the life of me I can&#39;t find it now. <a href="http://www.gamedev.net/community/forums/topic.asp?topic_id=91446">This olde GameDev thread</a> reveals the following pertinent facts though:
</p><ul><li><p> The NVidia Riva TNT 2 has a maximum texture size of 2048×2048</p></li><li><p> The ATI Rage Fury Pro has a maximum texture size of 1024×1024</p></li><li><p> The Matrox Millennium G200 has a maximum texture size of 2048×2048</p></li><li><p> The Voodoo5 5500 has a maximum texture size of 2048×2048</p></li></ul><p>
So I really think you&#39;re going to be okay.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Harte)</author>
		<pubDate>Tue, 12 Aug 2008 01:01:37 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Bob said:</div><div class="quote"><p>

Quote:<br />Can [the usual video card of today] do 1024 x 1024 textures?<br />Every GPU ever built, except the Voodoo 1 to 3.
</p></div></div><p>

from</p><p><a href="http://www.allegro.cc/forums/thread/524349">http://www.allegro.cc/forums/thread/524349</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Wed, 13 Aug 2008 19:51:33 +0000</pubDate>
	</item>
</rss>
