<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>cocos2d for iPhone &#187; Tag: OpenGL - Recent Posts</title>
		<link>http://www.cocos2d-iphone.org/forum/tags/opengl</link>
		<description>A fast, easy to use, free, and community supported 2D game engine</description>
		<language>en-US</language>
		<pubDate>Fri, 10 Feb 2012 02:36:08 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.1</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://www.cocos2d-iphone.org/forum/search.php</link>
		</textInput>
		<atom:link href="http://www.cocos2d-iphone.org/forum/rss/tags/opengl" rel="self" type="application/rss+xml" />

		<item>
			<title>NOG on "Where is the black background coming from?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28996#post-142945</link>
			<pubDate>Mon, 06 Feb 2012 22:13:52 +0000</pubDate>
			<dc:creator>NOG</dc:creator>
			<guid isPermaLink="false">142945@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Ahhh... you got me. You got me good Cocos2D! kCCTexture2DPixelFormat_RGBA4444 is not 32 bit.. not transparency. Needs to be kEAGLColorFormatRGBA8.
</p></description>
		</item>
		<item>
			<title>NOG on "Where is the black background coming from?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28996#post-142934</link>
			<pubDate>Mon, 06 Feb 2012 21:36:48 +0000</pubDate>
			<dc:creator>NOG</dc:creator>
			<guid isPermaLink="false">142934@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I read a cocos2d tutorial (which I think is old) and a forum post saying how to do this. The tutorial ( <a href="http://www.cocos2d-iphone.org/wiki/doku.php/tips:director_transparentview" rel="nofollow">http://www.cocos2d-iphone.org/wiki/doku.php/tips:director_transparentview</a> ) mentions initGLDefaultValues, but all I could find was setGLDefaultsValues.  Which gave me this:</p>
<pre><code>-(void) setGLDefaultValues
{
	// This method SHOULD be called only after openGLView_ was initialized
	NSAssert( openGLView_, @&#34;openGLView_ must be initialized&#34;);

	[self setAlphaBlending: YES];
	[self setDepthTest: YES];
	[self setProjection: projection_];

	// set other opengl default values
    openGLView_.opaque = NO;
	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

#<a href='http://www.cocos2d-iphone.org/forum/tags/if'>if</a> CC_DIRECTOR_FAST_FPS
    if (!FPSLabel_) {
		CCTexture2DPixelFormat currentFormat = [CCTexture2D defaultAlphaPixelFormat];
		[CCTexture2D setDefaultAlphaPixelFormat:kCCTexture2DPixelFormat_RGBA4444];
		FPSLabel_ = [[CCLabelAtlas labelWithString:@&#34;00.0&#34; charMapFile:@&#34;fps_images.png&#34; itemWidth:16 itemHeight:24 startCharMap:&#039;.&#039;] retain];
        FPSLabel_.position = ccp(200, 200);
		[CCTexture2D setDefaultAlphaPixelFormat:currentFormat];
	}
#endif	// CC_DIRECTOR_FAST_FPS
}</code></pre>
<p>Also under [director setOpenGLView:glView]; I put:</p>
<pre><code>[CCDirector sharedDirector].openGLView.backgroundColor = [UIColor clearColor];
glView.opaque = NO;
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);</code></pre>
<p>Anyone have an idea where this could be coming from?</p>
<p>FAKE EDIT: also I've tested this out by putting a view behind it.  I can see the view if I set the alpha lower on glView.
</p></description>
		</item>
		<item>
			<title>SizzlerWA on "Whole screen starts to flicker and Mac crashes..."</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28335#post-142532</link>
			<pubDate>Fri, 03 Feb 2012 18:05:38 +0000</pubDate>
			<dc:creator>SizzlerWA</dc:creator>
			<guid isPermaLink="false">142532@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>@riq:</p>
<p>Sure, I would be happy to create a small XCode project to repro the issue if I can.  I'll try that this weekend.  Part of the problem is that the issue doesn't happen all the time, only say once every 10 times, but when it does happen, it locks up the whole machine for 20 seconds.  So it takes some luck to repro.</p>
<p>I will try the "gles20" branch first to see if that fixes the issue.  I'd be happy to test this.</p>
<p>Thanks for the quick response, I really appreciate your help!
</p></description>
		</item>
		<item>
			<title>riq on "Whole screen starts to flicker and Mac crashes..."</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28335#post-142465</link>
			<pubDate>Fri, 03 Feb 2012 07:34:17 +0000</pubDate>
			<dc:creator>riq</dc:creator>
			<guid isPermaLink="false">142465@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>update:<br />
@<a href='http://www.cocos2d-iphone.org/forum/profile/29075'>SizzlerWA</a>: If possible, please try latest version from "gles20" branch. I think that I fixed a possible nasty crash on mac + cocos2d + opengl contexts
</p></description>
		</item>
		<item>
			<title>aramk on "Using GL_MODULATE and Multitexturing"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28871#post-142462</link>
			<pubDate>Fri, 03 Feb 2012 07:08:16 +0000</pubDate>
			<dc:creator>aramk</dc:creator>
			<guid isPermaLink="false">142462@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Thanks Birkemose, I've scoured the internet and found a solution.</p>
<p><a href="http://stackoverflow.com/questions/9116494/opengl-gl-modulate-and-multitexturing/9123721#9123721" rel="nofollow">http://stackoverflow.com/questions/9116494/opengl-gl-modulate-and-multitexturing/9123721#9123721</a>
</p></description>
		</item>
		<item>
			<title>riq on "Whole screen starts to flicker and Mac crashes..."</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28335#post-142403</link>
			<pubDate>Thu, 02 Feb 2012 22:53:04 +0000</pubDate>
			<dc:creator>riq</dc:creator>
			<guid isPermaLink="false">142403@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>@<a href='http://www.cocos2d-iphone.org/forum/profile/29075'>SizzlerWA</a>:<br />
If possible, could you create a small Xcode project that reproduces the issue and attach it into the issue tracker ? thanks.
</p></description>
		</item>
		<item>
			<title>SizzlerWA on "Whole screen starts to flicker and Mac crashes..."</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28335#post-142378</link>
			<pubDate>Thu, 02 Feb 2012 19:55:58 +0000</pubDate>
			<dc:creator>SizzlerWA</dc:creator>
			<guid isPermaLink="false">142378@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi Riq,</p>
<p>Thanks for looking into this!</p>
<p>I see a similar issue.  I have an NSDocument-based OS X app that uses cocos2d to preview some animations in a window.  Sometimes when I try to close the window containing cocos2d (and cleanup cocos2d as I exit) and return to my main document window, my whole system freezes.</p>
<p>This seems to be related to OpenGL, because when this happens:</p>
<p>1. I am cleaning up cocos2d.<br />
2. I see the following log entries in my mac's console log:</p>
<p>2/2/12 11:34:58 AM	MyApp[252]	Cocos2d Preview Window resigning key<br />
2/2/12 11:34:58 AM	MyApp[252]	Main Document window becoming key<br />
2/2/12 11:34:58 AM	kernel	NVDA(OpenGL): Channel exception! exception type = 0x6 = Fifo: Parse Error<br />
2/2/12 11:35:18 AM	kernel	NVDA(OpenGL): Channel timeout!<br />
2/2/12 11:35:18 AM	kernel	00000069</p>
<p>The freeze seems to happen between 11:34:58 and 11:35:18 --- for 20 seconds, my Mac is totally frozen and it seems to be due to the interaction between cocos2d, Cocoa and OpenGL as far as I can tell.</p>
<p>I am running my app in release mode, totally outside of XCode.  I am on OS X 10.6.8 with a May 2010 MBP.  My video card is NVIDIA GeForce GT 330M.</p>
<p>I am cleaning up my cocos2d in windowDidResignKey like follows:</p>
<p>- (void)cleanupCocos2d<br />
{<br />
    if (cocos2dActive) {<br />
        NSLog(@"CLEAN");<br />
        CCDirectorMac *director = (CCDirectorMac*) [CCDirector sharedDirector];<br />
        [director end];</p>
<p>        [glView removeFromSuperview];<br />
        [glView release];<br />
        glView = nil;</p>
<p>        cocos2dActive = NO;<br />
    }<br />
}</p>
<p>I need to totally remove the glView because the main document window that I return to may need to show cocos2d views in a different context and currently cocos2d for Mac only allows a single active cocos2d view/director at a time.</p>
<p>Note that in the the cocos2d view, I was showing CC quad particle systems, as well as doing CCActions on sprites and playing some sounds via CocosDenshion.  Not sure if that helps.</p>
<p>I would be very happy to help debug this in any way I can --- if you need me to re-run or test patches or log other helpful diagnostics, please let me know!</p>
<p>Thanks!
</p></description>
		</item>
		<item>
			<title>Birkemose on "Using GL_MODULATE and Multitexturing"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28871#post-142345</link>
			<pubDate>Thu, 02 Feb 2012 17:45:33 +0000</pubDate>
			<dc:creator>Birkemose</dc:creator>
			<guid isPermaLink="false">142345@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>There is no reason why you should not be able to use the second texture unit.<br />
You have to be really really careful with what you change in OpenGL, as everything must be retuned to original state. You at least need to reset glTexEnvi for TEXTURE0<br />
<pre><code>glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );</code></pre></description>
		</item>
		<item>
			<title>aramk on "Using GL_MODULATE and Multitexturing"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28871#post-142341</link>
			<pubDate>Thu, 02 Feb 2012 17:02:29 +0000</pubDate>
			<dc:creator>aramk</dc:creator>
			<guid isPermaLink="false">142341@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Also posted the question here: <a href="http://stackoverflow.com/questions/9116494/opengl-gl-modulate-and-multitexturing" rel="nofollow">http://stackoverflow.com/questions/9116494/opengl-gl-modulate-and-multitexturing</a>
</p></description>
		</item>
		<item>
			<title>aramk on "Using GL_MODULATE and Multitexturing"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28871#post-142325</link>
			<pubDate>Thu, 02 Feb 2012 14:44:10 +0000</pubDate>
			<dc:creator>aramk</dc:creator>
			<guid isPermaLink="false">142325@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Ok, I've done some tinkering and managed to sort some stuff out. I've managed to realise I can flip the texture coordinates so that it draws my texture upside down in opengl but looks normal since the texture was read in upside down due to discrepancies in origins between opengl and cocos2d. Anyway, I call this in draw() of TestNode.</p>
<pre><code>-(void) drawTexturedSquare {
	glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	const CGPoint vertices[] = {
		ccp(0,0),
		ccp(100,0),
		ccp(0,100),
		ccp(100,100),
	};

	// This will flip the image for us as well
	const CGPoint coordinates[] = {
		ccp(0,1),
		ccp(1,1),
		ccp(0,0),
		ccp(1,0),
	};

	// Config multitextures
	glActiveTexture(GL_TEXTURE0);
	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, icon.name);
	glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
	glTexCoordPointer(2, GL_FLOAT, 0, coordinates);

	glActiveTexture(GL_TEXTURE1);
	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, white.name);
	glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
	glTexCoordPointer(2, GL_FLOAT, 0, coordinates);

	GLubyte points = 4;

	// Draw the square
	glVertexPointer(2, GL_FLOAT, 0, vertices);
	glDrawArrays(GL_TRIANGLE_STRIP, 0, points);

	glDisable(GL_TEXTURE_2D);
	glActiveTexture(GL_TEXTURE0);
	glEnable(GL_TEXTURE_2D);
}</code></pre>
<p>Cocos2d doesn't seem to like the idea of me using GL_TEXTURE1 and I think the parameters have been set to clamp or something, because while it overlays GL_TEXTURE0, it appears totally red, meaning it's only reading in the first part of my "overlay.png" image. Here's the result:</p>
<p><img src="http://dl.dropbox.com/u/33811812/cocos2d/multi.png" /></p>
<p>GL_TEXTURE1 is being overlayed on the next GL_TEXTURE0 - which I'm guessing is the FPS text. I've activated this texture at the end, otherwise the FPS would not draw at all (since GL_TEXTURE1 was still active) so I've no idea what to try next but I'll keep looking for a solution.</p>
<p>Here are the textures I'm using:</p>
<p>Icon.png:<br />
<img src="http://dl.dropbox.com/u/33811812/cocos2d/Icon.png" /></p>
<p>overlay.png:<br />
<img src="http://dl.dropbox.com/u/33811812/cocos2d/overlay.png" /></p>
<p>Has anyone ever tried to use GL_TEXTURE1 or GL_MODULATE or anything remotely in the realm of texturing in OpenGL in cocos2d? So that you guys can help out and see my result, I've attached my project in Xcode. The only thing it does is create a TestNode, so check the draw method in that for the code above.</p>
<p><a href="http://dl.dropbox.com/u/33811812/cocos2d/OpenGLTest.zip" rel="nofollow">http://dl.dropbox.com/u/33811812/cocos2d/OpenGLTest.zip</a></p>
<p>Thanks in advance for even reading this far guys.</p>
<p>EDIT:<br />
I've prevented the FPS from going red by disabling, enabling and setting the texture to 0;
</p></description>
		</item>
		<item>
			<title>aramk on "Using GL_MODULATE and Multitexturing"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28871#post-142283</link>
			<pubDate>Thu, 02 Feb 2012 10:11:47 +0000</pubDate>
			<dc:creator>aramk</dc:creator>
			<guid isPermaLink="false">142283@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Thanks, will keep that in mind. I was too frustrated at the time to worry about efficiency :P. I'll post back here once I get the original topic sorted out, rather than going through tedious drawing.
</p></description>
		</item>
		<item>
			<title>Nexus6 on "Using GL_MODULATE and Multitexturing"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28871#post-142274</link>
			<pubDate>Thu, 02 Feb 2012 09:30:15 +0000</pubDate>
			<dc:creator>Nexus6</dc:creator>
			<guid isPermaLink="false">142274@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Anyway don't load your texture in the draw method, do it in your Init.
</p></description>
		</item>
		<item>
			<title>aramk on "Using GL_MODULATE and Multitexturing"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28871#post-142265</link>
			<pubDate>Thu, 02 Feb 2012 08:26:58 +0000</pubDate>
			<dc:creator>aramk</dc:creator>
			<guid isPermaLink="false">142265@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Got it working, will post soon.
</p></description>
		</item>
		<item>
			<title>aramk on "Using GL_MODULATE and Multitexturing"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28871#post-142260</link>
			<pubDate>Thu, 02 Feb 2012 07:20:21 +0000</pubDate>
			<dc:creator>aramk</dc:creator>
			<guid isPermaLink="false">142260@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I've been digging into opengl for the past few days and while I've mastered drawing primitives and blending to some extent I am having pains and no gains with texturing. I ultimately plan to have two textures drawn onto the same primitive with one using GL_REPLACE and the other using GL_MODULATE to create an overlay effect like in Photoshop. In the meantime I want to get used to working with textures and here's some code to just draw a simple texture onto a triangle:</p>
<pre><code>-(void) draw {
	CGPoint vertices[] = {
		ccp(0,0),
		ccp(50,100),
		ccp(100,0),
	};

	// Create textures
	CCTexture2D *icon = [[CCTextureCache sharedTextureCache] addImage:@&#34;Icon.png&#34;];

	// Load texture
	glEnable(GL_TEXTURE0);
	glBindTexture(GL_TEXTURE_2D, icon.name);
	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

	// Draw the triangle
	glLineWidth(2);
	glVertexPointer(2, GL_FLOAT, 0, vertices);
	glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
}</code></pre>
<p>I'm sure I'm not taking something into account, because the texture is drawn but it wobbles every time the FPS text on the bottom left hits 60. Clearly the texture in my CCNode is being affected by the texture drawn on the FPS counter... Anyone care to help?</p>
<p><img src="http://dl.dropbox.com/u/33811812/cocos2d/fps.png" /></p>
<p><img src="http://dl.dropbox.com/u/33811812/cocos2d/fps2.png" />
</p></description>
		</item>
		<item>
			<title>clynamen on "OpenGL guide."</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28771#post-141771</link>
			<pubDate>Sun, 29 Jan 2012 19:51:11 +0000</pubDate>
			<dc:creator>clynamen</dc:creator>
			<guid isPermaLink="false">141771@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I have to draw a lot of animation which I cannot reproduce with sprites, so I need to use directly openGL.<br />
I saw that openGL may be used overloading the draw method of a cocon node, but I didn't get where to find reference for opengl (which one should I use? the reference of the first version?). May you reccomend some tutorial, guide for the version of openGL used in cocon2d?
</p></description>
		</item>
		<item>
			<title>aramk on "Draw CCParticleSystem on CCRenderTexture"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28707#post-141528</link>
			<pubDate>Fri, 27 Jan 2012 14:03:22 +0000</pubDate>
			<dc:creator>aramk</dc:creator>
			<guid isPermaLink="false">141528@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Yep, I got it. The difference is that a normal particle drawn on the screen with <code>GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA</code> will cut out from the black background, whereas if that background was alpha = 0, then it wouldn't have anything to cut out of and would appear as only the coloured parts of the particle, missing all the black. You can see this in my screenshot.</p>
<p>The trick was to first grab this black by making a CCRenderTexture and drawing the particles on it with <code>GL_SRC_ALPHA, GL_ZERO</code>. This would leave just the background and remove all the alpha that the particles would take up. I made this a green texture with <code>[rt1 beginWithClear:0 g:1 b:0 a:1];</code> just for fun, since it'll be used to get rid of the unused black and nothing else.</p>
<p><img src="http://dl.dropbox.com/u/33811812/cocos2d/texture3.png" /></p>
<p>I then created another texture with <code>[rt2 beginWithClear:0 g:0 b:0 a:0];</code> and drew the particles on it with the usual <code>GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA</code> of alpha blending.</p>
<p><img src="http://dl.dropbox.com/u/33811812/cocos2d/texture4.png" /></p>
<p>Then I created my main texture with <code>[rt beginWithClear:0 g:0 b:0 a:1]</code> and drew this black texture onto it. I then drew the green one with <code>GL_ZERO, GL_ONE_MINUS_SRC_ALPHA</code> and I got the same result as usual.</p>
<p><img src="http://dl.dropbox.com/u/33811812/cocos2d/texture5.png" /></p>
<p>However, I only did this because the reason behind it was bugging me. Now that I've figured that out, I can get back to making the effect I was after: an additive blend flame particle but without blending it into the background :)</p>
<p><img src="http://dl.dropbox.com/u/33811812/cocos2d/texture6.png" /></p>
<p>Thanks a lot for your help!
</p></description>
		</item>
		<item>
			<title>Birkemose on "Draw CCParticleSystem on CCRenderTexture"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28707#post-141519</link>
			<pubDate>Fri, 27 Jan 2012 12:45:59 +0000</pubDate>
			<dc:creator>Birkemose</dc:creator>
			<guid isPermaLink="false">141519@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>No. When you render the particles, in normal blending, they blend with the underlaying image. If that image has alpha = 0, it will look different from an image with alpha = 1.<br />
In additive blending, you just add the color + alpha of the particle system. This often causes particle systems like fire to "whiten out" because every pixel finally adds to full white, full opacity.
</p></description>
		</item>
		<item>
			<title>aramk on "Draw CCParticleSystem on CCRenderTexture"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28707#post-141514</link>
			<pubDate>Fri, 27 Jan 2012 12:03:09 +0000</pubDate>
			<dc:creator>aramk</dc:creator>
			<guid isPermaLink="false">141514@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I sort of understand that the transparency is causing an issue, but don't I render the particles first and then add then onto a transparent surface? Wouldn't this leave the resulting texture the same as the one on the left?
</p></description>
		</item>
		<item>
			<title>Birkemose on "Draw CCParticleSystem on CCRenderTexture"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28707#post-141512</link>
			<pubDate>Fri, 27 Jan 2012 11:43:12 +0000</pubDate>
			<dc:creator>Birkemose</dc:creator>
			<guid isPermaLink="false">141512@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I guess it is because you render particles on a surface with no alpha. I think, that if you changed particle blending to additive, that it would look more the same.<br />
I am not sure how you can avoid that.
</p></description>
		</item>
		<item>
			<title>aramk on "Draw CCParticleSystem on CCRenderTexture"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28707#post-141506</link>
			<pubDate>Fri, 27 Jan 2012 10:31:49 +0000</pubDate>
			<dc:creator>aramk</dc:creator>
			<guid isPermaLink="false">141506@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Even weirder than that, I can even add an Icon.png into the CCRenderTexture, and it looks fine:</p>
<p><img src="http://dl.dropbox.com/u/33811812/cocos2d/texture2.png" /></p>
<p>So what else could cause the particle to be different when adding it to a texture :S</p>
<p>EDIT: reading a bit further into this, could it be a premultiplied alpha problem?
</p></description>
		</item>
		<item>
			<title>aramk on "Draw CCParticleSystem on CCRenderTexture"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28707#post-141505</link>
			<pubDate>Fri, 27 Jan 2012 10:29:01 +0000</pubDate>
			<dc:creator>aramk</dc:creator>
			<guid isPermaLink="false">141505@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I had to use <code>[child onEnter]</code> to trigger the particle into rendering. I don't know why, since <code>.active == YES</code>. Also, I call <code>[rt beginWithClear:0 g:0 b:0 a:0];</code>. So I have a similar setup to what you've outlined and I've now got this:</p>
<p><img src="http://dl.dropbox.com/u/33811812/cocos2d/texture.png" /></p>
<p>Both are the same particle. The left one is a child of the layer. The right one is first drawn onto the CCRenderTexture and then this is added to a CCNode, which is added to the layer. For some reason, the right one differs. Both particles use the same blend function and I have also tried adding the same particle into the CCNode and it looks identically to the left particle. So something is not quite right with drawing the particle onto the CCRenderTexture. Would you have any idea what could cause it?
</p></description>
		</item>
		<item>
			<title>Birkemose on "Draw CCParticleSystem on CCRenderTexture"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28707#post-141504</link>
			<pubDate>Fri, 27 Jan 2012 10:15:24 +0000</pubDate>
			<dc:creator>Birkemose</dc:creator>
			<guid isPermaLink="false">141504@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>It isnt nearly as complicated as you think :)<br />
The particle system will obey the coordinate system of the render texture. If you have a render texture of 100 * 100, setting the position of the particle system to 50, 50, will place it in the center.<br />
You do not visit the render texture. To draw it, you simply add it as a child to ex your layer.<br />
You do also not create the render texture each frame, or call visit inside a draw method. This is very bad for performance. In stead you create a single instance of the render texture, and place rendering in you scheduled frame tick.</p>
<p>Something like this<br />
<pre><code>// init of class

rte = [ CCRenderTexture renderTextureWithWidth:200 height:300 ];
rte.position = RTE_POSITION;
[ self addChild: rte ]; 

// manually retain the particles as you dont add them to a container
particles = [ [ CCParticleSystemQuad particleWithFile:PARTICLE_FILE ] retain ];</code></pre>
<p>And in update<br />
<pre><code>-( void )update:( ccTime )dt {

  [ particles update:dt ];

  [ rte beginWithClear ];
  [ particles visit ];
  [ rte end ];

}</code></pre></description>
		</item>
		<item>
			<title>aramk on "Draw CCParticleSystem on CCRenderTexture"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28707#post-141488</link>
			<pubDate>Fri, 27 Jan 2012 06:48:58 +0000</pubDate>
			<dc:creator>aramk</dc:creator>
			<guid isPermaLink="false">141488@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>How would one go about adding a CCRenderTexture into a CCParticleSystem and draw the CCParticleSystem into the CCRenderTexture, then draw this texture instead of the CCParticleSystem. This will allow a blend function to be used between the CCParticleSystem and the CCRenderTexture. The reason being this:</p>
<p><a href="http://gamedev.stackexchange.com/questions/22989/how-can-i-achieve-a-good-fire-effect-with-alpha-blending-and-particles/22990#22990" rel="nofollow">http://gamedev.stackexchange.com/questions/22989/how-can-i-achieve-a-good-fire-effect-with-alpha-blending-and-particles/22990#22990</a></p>
<p>Here's what I have in the draw: of CCParticleSystem:</p>
<pre>
<code>
-(void) draw {
	CCRenderTexture *rte = [CCRenderTexture renderTextureWithWidth:200 height:300];
	[rte beginWithClear:0 g:0 b:0 a:0.5];
	[super draw];
	[rte end];
	[rte visit];
}
</code>
</pre>
<p>Whatever I'm doing is slightly wrong, because the CCParticleSystem texture drawn onto the CCRenderTexture is moving across the CCParticleSystem as the CCParticleSystem moves around. This is probably something to do with draw and how it works with positions. Is there a way to still do all this inside the CCParticleSystem (so I can still keep it all in one object), or do I have to make a second class to store both the CCRenderTexture and also the CCParticleSystem?
</p></description>
		</item>
		<item>
			<title>whalec on "Alpha masking a texture2d at CGPoints."</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28581#post-140766</link>
			<pubDate>Mon, 23 Jan 2012 03:37:36 +0000</pubDate>
			<dc:creator>whalec</dc:creator>
			<guid isPermaLink="false">140766@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hey all,<br />
I'm writing an app at the moment, where you touch the screen to remove parts of an image and reveal the image underneath.<br />
My question is, what is the best approach with cocos2d for doing this? At the moment, I'm subclassing CCSprite, and over-riding the fragment shader(I'm using the openGL ES 2.0 beta BTW) and obviously I can mask the image with another texture, however I'd like to mask the image at certain points(x,y).</p>
<p>Suppose my question is, is a fragment shader the place to do this, and if so, how do you hand that point data to a fragment shader? Or is this approach all wrong.<br />
One of my issues here is performance, I also need to render Particles at the same time as the touch, so I'm thinking a fragment shader would give me the best performance.</p>
<p>I'm quite new to openGL, though I'm a reasonably seasoned iOS developer(apps etc), and have used cocos2d a bit already.</p>
<p>Thanks again for a great framework, and thanks in advance for any advise.</p>
<p>whalec
</p></description>
		</item>
		<item>
			<title>calin on "Rendering a texture-filled polygon"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/8142/page/3#post-140699</link>
			<pubDate>Sun, 22 Jan 2012 20:10:29 +0000</pubDate>
			<dc:creator>calin</dc:creator>
			<guid isPermaLink="false">140699@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Anyone managed to have this code working with cocos 2.0 ?</p>
<p>I'm not sure what would go into the -(void)draw method beside this, as stated in the migration guide:</p>
<p>cocos 1.0 -(void)draw:<br />
<pre><code>-(void) draw {

	// we have a pointer to vertex points so enable client state
	glBindTexture(GL_TEXTURE_2D, texture.name);

	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);

	glVertexPointer(2, GL_FLOAT, 0, areaTrianglePoints);
	glTexCoordPointer(2, GL_FLOAT, 0, textureCoordinates);

	glDrawArrays(GL_TRIANGLES, 0, areaTrianglePointCount);
	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

	//Restore texture matrix and switch back to modelview matrix
	glEnableClientState(GL_COLOR_ARRAY);
}</code></pre>
<p>cocos 2.0 -(void)draw: ???<br />
<pre><code>-(void) draw {

	// we have a pointer to vertex points so enable client state
	ccGLBindTexture2D( [texture name] );

	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);

	glVertexPointer(2, GL_FLOAT, 0, areaTrianglePoints);
	glTexCoordPointer(2, GL_FLOAT, 0, textureCoordinates);

	glDrawArrays(GL_TRIANGLES, 0, areaTrianglePointCount);
	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

	//Restore texture matrix and switch back to modelview matrix
	glEnableClientState(GL_COLOR_ARRAY);  // maybe we don&#039;t need this ??
}</code></pre>
<p>When running any of the above code, I get this error:<br />
<strong>OpenGL error 0x0502 in -[CCTextureAtlas drawNumberOfQuads:fromIndex:] 472</strong></p>
<p>Can someone guide me in the right direction? I tried everything I could find but nothing is working.
</p></description>
		</item>
		<item>
			<title>HannKett on "iOS Game Developer"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28456#post-140081</link>
			<pubDate>Wed, 18 Jan 2012 19:24:19 +0000</pubDate>
			<dc:creator>HannKett</dc:creator>
			<guid isPermaLink="false">140081@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>is it you again NORAD? no one will help you build that horrible and evil wargame Matthew Broderick almost killed teh worlds with :(
</p></description>
		</item>
		<item>
			<title>CodeMonkey on "iOS Game Developer"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28456#post-140075</link>
			<pubDate>Wed, 18 Jan 2012 18:52:11 +0000</pubDate>
			<dc:creator>CodeMonkey</dc:creator>
			<guid isPermaLink="false">140075@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>He said stealth mobile gaming studio.  ;o)
</p></description>
		</item>
		<item>
			<title>slembcke on "iOS Game Developer"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28456#post-140070</link>
			<pubDate>Wed, 18 Jan 2012 18:37:18 +0000</pubDate>
			<dc:creator>slembcke</dc:creator>
			<guid isPermaLink="false">140070@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>You didn't leave any contact information or any information about who you are.</p>
<p>If <a href="http://mirpartners.com/">this is your website</a> it doesn't say much about you either.
</p></description>
		</item>
		<item>
			<title>MIR Partners on "iOS Game Developer"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28456#post-140068</link>
			<pubDate>Wed, 18 Jan 2012 18:28:40 +0000</pubDate>
			<dc:creator>MIR Partners</dc:creator>
			<guid isPermaLink="false">140068@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>We are a stealth mobile gaming studio focused on changing the casual gaming landscape.  Our team’s goal is to build a 100 year company that makes products our grandchildren will remember.  Life is too short not to create products that are insanely great.  </p>
<p>Our 20 person team includes some of the best artist, designers, and developers in the industry, with experience releasing over 50 top 25 applications with over 35 million installations.  We are looking for junior and senior iOS developers who are interested in creating beautiful products that get better with time.  We want to meet you if you are passionate about gaming and are interested in being part of an A+ team that values excellence, quality, and taste.  </p>
<p>Responsibilities<br />
-Building iPhone games from start to finish<br />
-Solving cutting-edge technical challenges<br />
-Maintaining high code quality and maintainability</p>
<p>Requirements<br />
-Fluency in Objective-C through commercial experience, a university course, or independent iPhone application development<br />
-Deep understanding of Computer Science fundamentals (OOP, data structures, algorithms)<br />
-A long-term thinker who is committed to excellence, team work, and intellectual honesty</p>
<p>This is a full time position based in downtown San Francisco.<br />
Please contact us <a href="mailto:jobs@mirpartners.com">jobs@mirpartners.com</a>
</p></description>
		</item>
		<item>
			<title>madfatcat on "Autorotation, layoutSubviews and CGAffineTransform"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28433#post-139948</link>
			<pubDate>Wed, 18 Jan 2012 02:30:34 +0000</pubDate>
			<dc:creator>madfatcat</dc:creator>
			<guid isPermaLink="false">139948@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi,</p>
<p>Here's another problem I've spent many hours on but with no success.<br />
In order to adopt my game for iPad, I've scaled up my openGL view using CGAffineTransformScale. Everything works fine, but when I rotate the device, the transformation matrix is resetting and I get unscaled openGL view which occupies only 1/4 of the screen. I found out that this happens when EAGLView layoutSubviews is called. Does anyone know how to solve this?<br />
Thanks!
</p></description>
		</item>

	</channel>
</rss>

