<?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 Topics</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 04:05:41 +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/topics" 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-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>DrummerB on "Whole screen starts to flicker and Mac crashes..."</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28335#post-139448</link>
			<pubDate>Fri, 13 Jan 2012 21:47:42 +0000</pubDate>
			<dc:creator>DrummerB</dc:creator>
			<guid isPermaLink="false">139448@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I have this strange issue that I can barely reproduce. It happens during about 10% of the build &#38; runs of my level editor.<br />
Here is a short video:<br />
<a href="http://www.youtube.com/watch?v=L3IuGbQoza4" rel="nofollow">http://www.youtube.com/watch?v=L3IuGbQoza4</a></p>
<p>A big part of the screen suddenly starts flashing in black (like #000000 black, my camera couldn't quite capture that). Sometimes it stops for a few seconds, then continues. Other times it just goes on and on. In some cases my Mac freezes completely (except the mouse) and I have to force shut down.</p>
<p>I'm not even sure this is a bug in my editor. Could this be a video card or motherboard issue? Something in Cocos2D (doubt that)? Anything else?</p>
<p>I'm starting to worry about my HDD, because of all the resets...
</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-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>asinesio on "Rendering a texture-filled polygon"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/8142#post-47400</link>
			<pubDate>Fri, 23 Jul 2010 05:44:40 +0000</pubDate>
			<dc:creator>asinesio</dc:creator>
			<guid isPermaLink="false">47400@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>For my current project, I'm essentially looking for a way to do a texture-filled polygon.  The texture should not stretch or warp, but it should repeat to fill the entire polygon.  The polygon may be concave or convex.</p>
<p>Basically, I want the same thing that ccDrawPoly() does, but instead of just an outline, it would fill with a repeating texture.   I'm an openGL noob, so keep that in mind.</p>
<p>Think of creating a polygon in Photoshop then clicking the paint bucket to fill it with a pattern.</p>
<p>So far, I've tried the following approaches with very little success.</p>
<p>1) Modified CCTexture2D and adding a "drawInPolygon" method, like this:<br />
<pre><code>- (void) drawInPolygon: (CGPoint *) poli points: (int) points
{
	GLfloat	 coordinates[] = {  0.0f,	_maxT,
		_maxS,	_maxT,
		0.0f,	0.0f,
		_maxS,	0.0f  };

	glBindTexture(GL_TEXTURE_2D, _name);
	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
	glVertexPointer(2, GL_FLOAT, 0, poli);
	glTexCoordPointer(2, GL_FLOAT, 0, coordinates);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

	glDrawArrays(GL_TRIANGLE_FAN, 0, points);
}</code></pre>
<p>This has led to the texture being stretched and rotated... and looking awful, and it also requires that the polygon is convex, so I've even got a library that makes a polygon convex by triangulation.</p>
<p>2) Implementing a CCRibbon object as a child of my node that has the vertices.</p>
<p>This kinda works, but it looks ugly.</p>
<p>3) CCRenderTexture, which doesn't work because the levels I'm creating are well over 5000 px wide and it seems silly to create huge textures in memory when it's just made up of one smaller texture repeated and clipped.</p>
<p>---</p>
<p>Does anyone have any advice for me?   Am I missing something obvious here, like maybe just setting the background to be a huge CCSprite that has GL_REPEAT in its texture options and clipping it somehow?</p>
<p>I've searched these forums for a few days now and haven't really had a lot of luck.</p>
<p>Any help you could provide would be greatly appreciated!
</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>
		<item>
			<title>timrwood on "Critter Chaos - by Infinite Beta. Like boogers? Then try this physics puzzler!"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28043#post-137835</link>
			<pubDate>Tue, 03 Jan 2012 22:41:27 +0000</pubDate>
			<dc:creator>timrwood</dc:creator>
			<guid isPermaLink="false">137835@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Critter Chaos - Goo Flinging Fun</p>
<p><a href="http://www.youtube.com/watch?v=kDhLY-T1UjY" rel="nofollow">http://www.youtube.com/watch?v=kDhLY-T1UjY</a></p>
<p>This was the first game I made using Cocos2D. We used Cocos2D mostly for scene management and texture loading, as I found it easier to write my own openGL for things like the gears and background machine wall.</p>
<p>The physics engine is Box2D, and the goo is just a mess of small b2CircleShape bodies and b2DistanceJoints.</p>
<p>I haven’t been posting in the forums much, as I was still new to the library, but now that the game is out and I have a little more experience under my belt, hopefully I can be more active.</p>
<p>Anyway, let me know what you think! Download and rate it if you like it!</p>
<p>Tim Wood<br />
Game Developer - Infinite Beta</p>
<p>--------------</p>
<p>Introduction:<br />
While living their blissful lives, playful woodland critters are thrown into chaos when their prized possessions are mercilessly stolen by a menacing machine. In order to return to their happy way of life, the critters must do battle against the mechanical monstrosity and get their jewels back!!</p>
<p>Critter Chaos Features:</p>
<ul>
<li>Sharp and engaging visuals including 8 unique and adorable forest critters</li>
<li>Beautifully arranged original music featuring live instruments</li>
<li>Clever and fiendish levels, culminating in epic boss battles!</li>
<li>Follow the critter’s saga with captivating animations</li>
<li>Intuitive and natural touch controls</li>
<li>Full range of addicting achievements</li>
<li>Bite-sized levels perfect for quick gaming sessions</li>
</ul>
<p>Here are some great screenshots of Critter Chaos:</p>
<p><img src="http://critterchaos.infinitebeta.com/img/ss/4.jpg" alt="Critter Chaos Screenshots" /></p>
<p><img src="http://critterchaos.infinitebeta.com/img/ss/1.jpg" alt="Critter Chaos Screenshots" /></p>
<p><img src="http://critterchaos.infinitebeta.com/img/ss/2.jpg" alt="Critter Chaos Screenshots" /></p>
<p><img src="http://critterchaos.infinitebeta.com/img/ss/3.jpg" alt="Critter Chaos Screenshots" /></p>
<p><img src="http://critterchaos.infinitebeta.com/img/ss/5.jpg" alt="Critter Chaos Screenshots" /></p>
<p><img src="http://critterchaos.infinitebeta.com/img/ss/6.jpg" alt="Critter Chaos Screenshots" /></p>
<p><img src="http://critterchaos.infinitebeta.com/img/ss/7.jpg" alt="Critter Chaos Screenshots" /></p>
<p><img src="http://critterchaos.infinitebeta.com/img/ss/8.jpg" alt="Critter Chaos Screenshots" /></p>
<p>You can read more about Critter Chaos at Infinite Beta:<br />
<a href="http://critterchaos.infinitebeta.com/" rel="nofollow">http://critterchaos.infinitebeta.com/</a><br />
<a href="http://infinitebeta.com/" rel="nofollow">http://infinitebeta.com/</a></p>
<p>You can download Critter Chaos from iTunes here:<br />
iPhone - <a href="http://itunes.apple.com/us/app/critter-chaos/id480491346?ls=1&#038;mt=8" rel="nofollow">http://itunes.apple.com/us/app/critter-chaos/id480491346?ls=1&#038;mt=8</a><br />
iPad - <a href="http://itunes.apple.com/us/app/critter-chaos-hd/id486467274?ls=1&#038;mt=8" rel="nofollow">http://itunes.apple.com/us/app/critter-chaos-hd/id486467274?ls=1&#038;mt=8</a><br />
Lite Version (FREE) - <a href="http://itunes.apple.com/us/app/critter-chaos-lite/id486467884?ls=1&#038;mt=8" rel="nofollow">http://itunes.apple.com/us/app/critter-chaos-lite/id486467884?ls=1&#038;mt=8</a>
</p></description>
		</item>
		<item>
			<title>Sorien on "Strange cocos2d camera and tilemap issue"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28163#post-138528</link>
			<pubDate>Sat, 07 Jan 2012 15:58:49 +0000</pubDate>
			<dc:creator>Sorien</dc:creator>
			<guid isPermaLink="false">138528@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>For the menu background of Nitroman i am using a tile-map with a moved camera. When i start a game-level the tile-map within the game is working like it should, but if i go back to the main screen the Menu-tile-map is messed up.</p>
<p>Here is the working menu background tilemap:<br />
<img src="http://nitroman.alpapps.com/wp-content/uploads/2012/01/IMG_0179.png" /></p>
<p>And here it the messed up background tilemap:<br />
<img src="http://nitroman.alpapps.com/wp-content/uploads/2012/01/IMG_0180.png" /></p>
<p>The MenuScene is completely new initialized and all the positions and settings are the same like the first initialization.</p>
<p>Also the camera positions for center, eye and up are the same in both.</p>
<p>Here is the code:<br />
<pre><code>- (void) initMap{
    // add Background
    CCLayerColor *color = [CCLayerColor layerWithColor:ccc4(0,0,0,255)];
    [self addChild:color z:-1];
    if([DeviceDetector sharedDeviceDetector].isIPad &#38;&#38; [DeviceDetector sharedDeviceDetector].hasRetinaDisplay){
        map = [TMXTiledMapExtended tiledMapWithTMXFile:DOCUMENTS_RESOURCES_PATH(@&#34;levels/default_levels/tilemaps/MainMenu/iNitroMan_MainMenu-hd.tmx&#34;)];
    } else {
        map = [TMXTiledMapExtended tiledMapWithTMXFile:DOCUMENTS_RESOURCES_PATH(@&#34;levels/default_levels/tilemaps/MainMenu/iNitroMan_MainMenu.tmx&#34;)];
    }&#60;/p&#62;
    [self addChild:map z:1];
    for( CCSpriteBatchNode* child in [map children] ) {
        [[child texture] setAntiAliasTexParameters];
    }
    [map setAnchorPoint:ccp(0, 1)];
    DEBUG_LOG(@&#34;MAP-Scale       (%f,%f)&#34;,map.scaleX,map.scaleY);
    DEBUG_LOG(@&#34;MAP-TileSize    (%f,%f)&#34;,map.tileSize.width,map.tileSize.height);
    DEBUG_LOG(@&#34;MAP-MapSize     (%f,%f)&#34;,map.mapSize.width,map.mapSize.height);
}
- (void) initCamera{
    float x, y, z = -100;
    float eye_x, eye_y, eye_z = 1;
    float up_x, up_y, up_z = 1;
    [[map camera] centerX:&#38;x centerY:&#38;y centerZ:&#38;z];
    [[map camera] upX:&#38;up_x upY:&#38;up_y upZ:&#38;up_z];
    [[map camera] eyeX:&#38;eye_x eyeY:&#38;eye_y eyeZ:&#38;eye_z];
    [map getPixelPositionFromGridPoint:CGPointMake(12,1) pX:&#38;x pY:&#38;y];
    [map getPixelPositionFromGridPoint:CGPointMake(12,7) pX:&#38;eye_x pY:&#38;eye_y];
    if([DeviceDetector sharedDeviceDetector].isIPad){
        [[map camera] setEyeX:eye_x eyeY:eye_y eyeZ:500];
    } else {
        eye_z = 1;
        [[map camera] setEyeX:eye_x eyeY:eye_y eyeZ:1];
    }
    z = -100;
    DEBUG_LOG(@&#34;CAM-Eye     (%f,%f,%f)&#34;,eye_x,eye_y,eye_z);
    DEBUG_LOG(@&#34;CAM-Center  (%f,%f,%f)&#34;,x,y,z);
    DEBUG_LOG(@&#34;CAM-Up      (%f,%f,%f)&#34;,up_x,up_y,up_z);
    [[map camera] setCenterX:x centerY:y centerZ:z];
    [[map camera] setUpX:up_x upY:up_y upZ:up_z];
}</code></pre>
<p>Does anyone know why this happens? </p>
<p>Thanks for your help.
</p></description>
		</item>
		<item>
			<title>marraboy on "Shadow Map"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/28103#post-138165</link>
			<pubDate>Thu, 05 Jan 2012 13:57:37 +0000</pubDate>
			<dc:creator>marraboy</dc:creator>
			<guid isPermaLink="false">138165@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi</p>
<p>Is there anything built into the Cocos3D framework that allows me to apply a shadow map to a second material with it's own UV coords or do I need to delve in to the source code and do some OpenGL?</p>
<p>Thanks</p>
<p>JT
</p></description>
		</item>
		<item>
			<title>calin on "[ERROR] Cocos2d 2.0 Beta - Shaders Errors"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/24800#post-130774</link>
			<pubDate>Fri, 02 Dec 2011 17:19:49 +0000</pubDate>
			<dc:creator>calin</dc:creator>
			<guid isPermaLink="false">130774@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi, I started working with the latest cocos2d 2.0 beta version, it's great!<br />
I have some problems though, regarding shaders.</p>
<p>First, the Shaders Test is not working, except for Blur. None of the others are working, and the following error is given when running them:<br />
- OpenGL error 0x0502 in -[CCSprite draw] 552</p>
<p>Secondly, it appears the templates are missing one shader, "PositionTextureColorAlphaTest.fsh". Is this correct, or am I missing something here?</p>
<p>Third, when running a project on a Retina Display device (or simulator) I see the following warnings:<br />
- CCFileUtils: Warning file not found: Position_uColor-hd.vsh<br />
- CCFileUtils: Warning file not found: Position_uColor-hd.fsh</p>
<p>I am using Xcode 4.2.1 on Mac OS X Lion 10.7.2 with the iOS SDK 5.0 and all cocos default settings for the project.</p>
<p>I searched everywhere and no one appears to be having these issue.<br />
Can someone please help me with this? Thanks for your time.
</p></description>
		</item>
		<item>
			<title>patgoto on "10.5 leopard compatibility issues"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/27877#post-136908</link>
			<pubDate>Mon, 26 Dec 2011 12:56:52 +0000</pubDate>
			<dc:creator>patgoto</dc:creator>
			<guid isPermaLink="false">136908@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi all,</p>
<p>I'm testing my game under lion, SnowLeopard and leopard.<br />
Lion and SL are fine but i'm having a lot of troubles having the app running fine under leopard.</p>
<p>I've set my deployment target to 10.5.</p>
<p>I've solved some issues (like cocosDenshion not running on leopard -&#62; replaced with NSSound) but now i'm stuck...<br />
So I've installed a leopard on a external hard drive and Xcode 3.1.3 (oldschool ;) ).</p>
<p>i first installed a 10.5 and i was able to lauch the game but after a few click of navigation, the UI is freezing  of some texture are not displayed (but still here, i can click the missing button and the calback gets called).</p>
<p>(i'm thinking of textures allocated on a bad thread but  it's fine under lion and SL)</p>
<p>i 've updated to 10.5.8 and now i cannot launch anymore-&#62; The console gives me at runtime:<br />
dyld: Symbol not found: -glGenFramebuffers  ???<br />
what happened to openGl framework in 10.5.8?</p>
<p>i tried on 2 macs on 10.5.8 and same error :dyld: Symbol not found: -glGenFramebuffers </p>
<p>So i'm trying debugging  in xcode but i cannot compile my project., lots a stuff are undefined... </p>
<p>some are opengl related:<br />
GL_MAX_SAMPLES,GL_FRAMEBUFFER_BINDING,GL_FRAMEBUFFER_BINDING,GL_COLOR_ATTACHMENT0...</p>
<p>the others are related to NSXMLParserDelegate</p>
<p>i also tried a sample project done with cocos2d 0.99.5 and same errors.<br />
Did some of you encountered the same issues??</p>
<p>This can be interesting for others who wants 10.5 compatibility.</p>
<p>Please advise, i'm stuck on this for days!<br />
cocos2d is supposed to be compatible with 10.5 so i'm probably doing something wrong !
</p></description>
		</item>
		<item>
			<title>calin on "[OpenGL ES] Depth Test Enabled Without Depth Buffer"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/27800#post-136558</link>
			<pubDate>Thu, 22 Dec 2011 11:40:18 +0000</pubDate>
			<dc:creator>calin</dc:creator>
			<guid isPermaLink="false">136558@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>This is a high severity message I get when running OpenGL ES Analyzer on a cocos 2.0 project with default settings (3d projection, depth test enabled). Details on the log:</p>
<p>Category:</p>
<blockquote><p>Depth Test Enabled Without Depth Buffer</p>
</blockquote>
<p>Summary:</p>
<blockquote><p>Depth testing enabled without an attached depth buffer</p>
</blockquote>
<p>Recommendation:</p>
<blockquote><p>OpenGL ES Analyzer detected rendering with GL_DEPTH_TEST enabled into a framebuffer without an attached depth buffer. To get useful results from depth testing, attach a depth buffer to your FBO.</p>
</blockquote>
<p>Responsible Command:<br />
<pre><code>glDrawElements(GL_TRIANGLES, 18, GL_UNSIGNED_SHORT, NULL)
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4)</code></pre>
<p>What does it mean exactly? Can it affect performance? Thanks</p>
<p>UPDATE:</p>
<p>If setting <code>depthFormat:GL_DEPTH_COMPONENT16_OES</code> instead of <code>depthFormat:0</code> in AppDelegate removes that message from the analyzer, since it successfully creates the depth buffer.<br />
Not sure though why is that set to 0 if depth test is enabled? Probably just a template error..?
</p></description>
		</item>
		<item>
			<title>Primirical on "[PAID JOB] - IOS / cocos2d - iPhone &amp; Mac Developer Programmer - IMMEDIATE hire"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/26192#post-134692</link>
			<pubDate>Tue, 20 Dec 2011 07:46:50 +0000</pubDate>
			<dc:creator>Primirical</dc:creator>
			<guid isPermaLink="false">134692@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>We are a major independent game developer looking for one Senior and one Junior cocos2d app programmer to continue ongoing development of globally released games as well as a myriad of new games that extend our global brand.  </p>
<p>We have an unlimited amount of work and are looking to add a couple more rockstar or soon to be rockstar programmers to our team for our apps that are in 12 different languages in 123 countries.  </p>
<p>Our games include freemium, premium and paid formats so you will be expected to understand a myriad of 3rd party SDK's that support ad mediation, storekits, offerwalls and credit based gaming.  </p>
<p>Our games include Game Center, Competitions, Subscriptions and In App Purchases, Rich Push Notifications and more.  </p>
<p>You should have solid experience in</p>
<p>• IOS OS 4.0+, 5.0+<br />
• Mac OSX<br />
• Cocoa / Touch<br />
• Objective C<br />
• XCode<br />
• iPad and Iphone App targeting framework for multiple releases of identical app<br />
• Localizations<br />
• OpenGL<br />
• Apple’s Human Interface Guidelines (HIG)<br />
• Universal app, SD, Retina and HD Targeting, stand-alone app creation and development<br />
• Memory management<br />
• Java / JSON<br />
• Bonus for HTML, PHP, MySQL and JSON experience as our games also have connections to each of them.  </p>
<p>You will work closely with our Lead Designer and Lead Developer who are gurus at gaming design, framework and architecture that deals with all of the above and more.  We are an easy going fun group of people that have a passion for building the best of the best and our products prove it.  We keep a very low profile on the secrets behind our success of our products and the proprietary nature of what we do with confidentiality agreements so we do not disclose much here but will create an open and comprehensive dialogue with those who response and meet what we are looking for.  </p>
<p>If you want to be part of working on a series of #<a href='http://www.cocos2d-iphone.org/forum/tags/1'>1</a> apps on the App Store, write to us as <a href="mailto:Primirical@gmail.com">Primirical@gmail.com</a> and include a resume, CV and any links to your portfolio or things you think are crucial to determinine why you are so amazing!  (because we know you are out there!)  </p>
<p>Also include a telephone contact or Skype address, your current location, your desired hourly/salaried rate, your availability and how many hours a week you can work because we have more development needs than you could possibly imagine!  </p>
<p>We will respond in very short order!<br />
Cheers!
</p></description>
		</item>
		<item>
			<title>calin on "[BEST PRACTICE] Copying pixels in OpenGL ES and render at another location"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/25726#post-134031</link>
			<pubDate>Sun, 18 Dec 2011 13:03:14 +0000</pubDate>
			<dc:creator>calin</dc:creator>
			<guid isPermaLink="false">134031@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>What's the best practice for copying pixels from a portion of the screen and draw them at another location?</p>
<p>I want to implement a magnifying glass (maybe it will not magnify at all, just show the area as-is).<br />
I saw hm50's post (<a href="http://www.cocos2d-iphone.org/forum/topic/6871" rel="nofollow">http://www.cocos2d-iphone.org/forum/topic/6871</a>) but I wonder if this is the best method of implementing something like this. I would like to also thank araker for his great contribution on that post.</p>
<p>Maybe using <code>glCopyPixels</code> (or <code>glCopyTexSubImage2D</code>) instead of <code>glReadPixels</code> would be better in this case, since there is no transformation we need to perform out of the opengl environment? Also I am considering a mask for the new image (maybe render to a texture is to be used for this - not sure?!).</p>
<p>I'm not familiar with OpenGL. Please if anyone can give me an advice on this issue I would appreciate it. I will post the new Magnifier class here if it will be good enough for other people to use it easily, since I couldn't find anything that is plug and play.</p>
<p>I want to do this using cocos 2.0. Thank you for your time!
</p></description>
		</item>
		<item>
			<title>rpgamer2003 on "Texturemapping or Prerenderig?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/25711#post-133930</link>
			<pubDate>Sat, 17 Dec 2011 17:19:02 +0000</pubDate>
			<dc:creator>rpgamer2003</dc:creator>
			<guid isPermaLink="false">133930@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hey, I'm thinking about implementing growing and shrinking circles or rings, where the inner circle expands until it overlaps with the outer circle and the ring disappears. Sometimes a circle might also have a dotted outline or a combination of sorts so I was thinking to actually only use a static texture (for the dotted outline) with texture mapping and animate the vertices instead of preprendering the animations I want.<br />
Whould that be smart in terms of performance or would it be better to prerender the animations to a texture atlas? If I animated them dynamically there'd be times where quite a bunch of vertices would have to be updated each frame so I don't really know which route to take. thanks!
</p></description>
		</item>
		<item>
			<title>cocoBavan on "GLBlendFunc Basic Question"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/25677#post-133687</link>
			<pubDate>Fri, 16 Dec 2011 09:10:56 +0000</pubDate>
			<dc:creator>cocoBavan</dc:creator>
			<guid isPermaLink="false">133687@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>When it comes to blend functions, each texture is assigned two values of Source and Destination. What are those Source and Destination? If it is Destination alpha, whose alpha is that? I am kinda lost.</p>
<p>As far as I understood, If  you draw a texture on another texture, the top texture calls himself as source and the one under it is called as Destination by it. Is that correct?</p>
<p>Thank you.
</p></description>
		</item>
		<item>
			<title>lvziru on "how to display opengl?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/25633#post-133456</link>
			<pubDate>Thu, 15 Dec 2011 08:16:57 +0000</pubDate>
			<dc:creator>lvziru</dc:creator>
			<guid isPermaLink="false">133456@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>hi guys,</p>
<p>Now, I write a simple opengl code in cocos2d-x project, which function is to realize displaying a triangle.<br />
But it only display the background. </p>
<p>How can I get it?<br />
Thank you very much.</p>
<p>bool HelloWorld::init()<br />
{<br />
	//////////////////////////////<br />
	// 1. super init first<br />
	if ( !CCLayer::init() )<br />
	{<br />
		return false;<br />
	}<br />
	Vertex3D vertex1 = CommonMethod::Vertex3DMake(0.3, 0.5,0.0);<br />
	Vertex3D vertex2 = CommonMethod::Vertex3DMake(0.0, 0.0,0.0);<br />
	Vertex3D vertex3 = CommonMethod::Vertex3DMake(0.6, 0.0,0.0);<br />
	Triangle3D triangle = CommonMethod::Triangle3DMake(vertex1,vertex2,vertex3);</p>
<p>	glLoadIdentity();<br />
	glClearColor(0.7, 0.7, 0.7, 0.5);<br />
	glClear(GL_COLOR_BUFFER_BIT &#124; GL_DEPTH_BUFFER_BIT);<br />
	glEnableClientState(GL_VERTEX_ARRAY);<br />
    glColor4f(1.0, 0.0, 0.0, 1.0);<br />
    glVertexPointer(3, GL_FLOAT, 0, &#38;triangle);<br />
    glDrawArrays(GL_TRIANGLES, 0, 9);<br />
    glDisableClientState(GL_VERTEX_ARRAY);</p>
<p>	return true;<br />
}
</p></description>
		</item>
		<item>
			<title>aftershock on "How to use Float textures in OpenGL ES 2.0 on iOS?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/25621#post-133419</link>
			<pubDate>Thu, 15 Dec 2011 00:46:33 +0000</pubDate>
			<dc:creator>aftershock</dc:creator>
			<guid isPermaLink="false">133419@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>In my iOS OpenGL ES 2.0 program I have to store float values in the textures. Could you please let me know how to do this. I am aware that there is an extension (OES_texture_float?) for that purpose but not sure how to use that extension.
</p></description>
		</item>
		<item>
			<title>pyrosphere on "Code for a custom node with lots of tiny points"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/12108#post-68200</link>
			<pubDate>Fri, 24 Dec 2010 16:27:48 +0000</pubDate>
			<dc:creator>pyrosphere</dc:creator>
			<guid isPermaLink="false">68200@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hello,</p>
<p>I released my second game (first one using cocos2d) so I decided to give back a bit to the community and share some code I made to solve a very specific problem. This might help someone out there with a similar situation but I find it interesting enough as a case study.</p>
<p>The game is Last Fish (more in <a href="http://www.cocos2d-iphone.org/forum/topic/12107" rel="nofollow">http://www.cocos2d-iphone.org/forum/topic/12107</a> ) and uses a minimalist black and white style. To provide the underwater mood I wanted to add lots of tiny white points that would appear, move slowly in a random direction and disappear. Here's a screenshot of the final result (you can see this behavior animated in the trailer):</p>
<p><img src="http://pyrosphere.net/lastfish/press/last_fish_points.png" alt="Last Fish (ambient tiny points only)" /></p>
<p><img src="http://pyrosphere.net/lastfish/press/s1.jpg" alt="Last Fish screenshot" /></p>
<p>To do this I initially considered using a cocos2d particle system, however I couldn't get it to both fade in and fade out. Also I only wanted very small ambient points, and felt that it would be overkill to use individual sprites for each point. So I decided to use OpenGL points.</p>
<p>I created a custom node to override <code>draw</code> and have the points as <code>GL_POINTS</code>.</p>
<p>The node would store three arrays: one with positions, one with speeds, one of colors.</p>
<p>The color array is all white, but starts at opacity 0, goes up to the max opacity, then comes back to 0. It remains unchanged. </p>
<p>At each update the speed is applied to the positions. The place where the position/color array match is also changed on each update to give the illusion that the points are fading in then fading out. Also, at each update, the couple of points with opacity 0 (after fading out) get a new random position and speed to create a new point.</p>
<p>This way allows a minimal number of processing to update points and only needs two sets of calls to <code>glColorPointer()</code>, <code>glVertexPointer()</code>, <code>glDrawArrays()</code> to draw all points. </p>
<p>The method <code>updateWithDelay:</code> can be called manually or on its own scheduler.</p>
<p>I'd like to point out that the following code works only in 480x320 (haven't updated it yet for Retina Display). Please reply about any bug, optimization suggestion, or questions. Thanks.</p>
<p>PointsNode.h</p>
<pre><code>#<a href='http://www.cocos2d-iphone.org/forum/tags/import'>import</a> &#34;cocos2d.h&#34;

@class GameScene;

@interface PointsNode : CCNode {
    float colorStart;
    float *colors;
    float *points;
    float *speed;
}

-(void)updateWithDelay:(ccTime)dt;

@end</code></pre>
<p>PointsNode.m</p>
<pre><code>#<a href='http://www.cocos2d-iphone.org/forum/tags/import'>import</a> &#34;PointsNode.h&#34;

#<a href='http://www.cocos2d-iphone.org/forum/tags/define'>define</a> ARC4RANDOM_MAX 0x100000000LL
#<a href='http://www.cocos2d-iphone.org/forum/tags/define'>define</a> RANDI(min,max) ((arc4random()%(max-min))+min)
#<a href='http://www.cocos2d-iphone.org/forum/tags/define'>define</a> RANDF(min,max) (((double)arc4random() / ARC4RANDOM_MAX) * (max-min) + min)

#<a href='http://www.cocos2d-iphone.org/forum/tags/define'>define</a> POINTS_NUMBER    100
#<a href='http://www.cocos2d-iphone.org/forum/tags/define'>define</a> POINTS_MAX_ALPHA 0.25f
#<a href='http://www.cocos2d-iphone.org/forum/tags/define'>define</a> POINTS_LIFE      10.0f
#<a href='http://www.cocos2d-iphone.org/forum/tags/define'>define</a> POINTS_MAX_SPEED 10.0f

@implementation PointsNode

-(id)init {
    if ((self == [super init])) {

        colorStart = 0;

        colors = (float*)malloc(POINTS_NUMBER * 4 * sizeof(float));
        int i = 0;
        int t = POINTS_NUMBER * 2;
        float c = 0.0f;
        float dc = 2.0f * POINTS_MAX_ALPHA / (float)POINTS_NUMBER;
        while(i &#60; t) {
            colors[i++]=1.0f;
            colors[i++]=1.0f;
            colors[i++]=1.0f;
            colors[i++]=c;
            c+=dc;
        }
        t = POINTS_NUMBER * 4;
        while(i &#60; t) {
            colors[i++]=1.0f;
            colors[i++]=1.0f;
            colors[i++]=1.0f;
            colors[i++]=c;
            c-=dc;
        }

        points = (float*)malloc(POINTS_NUMBER * 2 * sizeof(float));
        i=0;
        t = POINTS_NUMBER * 2;
        while (i &#60; t) {
            points[i++] = RANDF(0.0f, 480.0f);
            points[i++] = RANDF(0.0f, 320.0f);
        }

        speed = (float*)malloc(POINTS_NUMBER * 2 * sizeof(float));
        i=0;
        t = POINTS_NUMBER * 2;
        while (i &#60; t) {
            speed[i++] = RANDF(-1.0f*POINTS_MAX_SPEED, 1.0f*POINTS_MAX_SPEED);
            speed[i++] = RANDF(-1.0f*POINTS_MAX_SPEED, 1.0f*POINTS_MAX_SPEED);
        }

    }
    return self;
}

-(void)dealloc {

    free(colors), colors=0;
    free(points), points=0;
    free(speed), speed=0;

    [super dealloc];
}

-(void)draw {

    glPointSize(2.0f);

    glDisable(GL_TEXTURE_2D);
    glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    glEnableClientState(GL_COLOR_ARRAY);

    glEnable(GL_POINT_SMOOTH);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    int cs = (int)colorStart;
    int ncs = POINTS_NUMBER-cs;

    glColorPointer(4, GL_FLOAT, 0, colors);
    glVertexPointer(2, GL_FLOAT, 0, points + cs * 2);
    glDrawArrays(GL_POINTS, 0, ncs);

    glColorPointer(4, GL_FLOAT, 0, colors + ncs * 4);
    glVertexPointer(2, GL_FLOAT, 0, points);
    glDrawArrays(GL_POINTS, 0, cs);

    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    glEnable(GL_TEXTURE_2D);    

}

-(void)updateWithDelay:(ccTime)dt {

    int c1 = (int)colorStart;
    colorStart += (dt * POINTS_NUMBER) / POINTS_LIFE;
    int c2 = MIN((int)colorStart, POINTS_NUMBER);

    if (colorStart &#62;= POINTS_NUMBER) {
        colorStart = 0.0f;
    }

    int i = 0;
    int t = POINTS_NUMBER * 2;
    while (i &#60; t) {
        points[i] += speed[i] * dt;
        i++;
    }

    if (c1 == c2) {
        return;
    }

    //update points between c1 and c2
    for (i=c1; i&#60;c2; i++) {
        points[i*2] = RANDF(0.0f, 480.0f);
        points[i*2+1] = RANDF(0.0f, 320.0f);
        speed[i*2] = RANDF(-1.0f*POINTS_MAX_SPEED, 1.0f*POINTS_MAX_SPEED);
        speed[i*2+1] = RANDF(-1.0f*POINTS_MAX_SPEED, 1.0f*POINTS_MAX_SPEED);
    }

}

@end</code></pre></description>
		</item>
		<item>
			<title>manucorporat on "Cocos2d screenShot"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/1722#post-10843</link>
			<pubDate>Mon, 07 Sep 2009 00:30:24 +0000</pubDate>
			<dc:creator>manucorporat</dc:creator>
			<guid isPermaLink="false">10843@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Cocos2D should have a function for capture the OpenGL image in screen.<br />
I developed a function for this.</p>
<pre><code>- (Texture2D*) cocos2DScreenShot {
	CGSize size = [self displaySize];

	//Create un buffer for pixels
	int bufferLenght=size.width*size.height*4;
	unsigned char buffer[bufferLenght];

	//Read Pixels from OpenGL
	glReadPixels(0,0,size.width,size.height,GL_RGBA,GL_UNSIGNED_BYTE,&#38;buffer);
	CGDataProviderRef ref = CGDataProviderCreateWithData(NULL, &#38;buffer, bufferLenght, NULL);
	CGImageRef iref = CGImageCreate(size.width,size.height,8,32,size.width*4,CGColorSpaceCreateDeviceRGB(),kCGBitmapByteOrderDefault,ref,NULL,true,kCGRenderingIntentDefault);

	uint32_t *pixels     = (uint32_t *)malloc(bufferLenght);
	CGContextRef context = CGBitmapContextCreate(pixels, [self winSize].width, [self winSize].height, 8, [self winSize].width*4, CGImageGetColorSpace(iref), kCGImageAlphaPremultipliedLast &#124; kCGBitmapByteOrder32Big);

	CGContextTranslateCTM(context,0, size.height);
	CGContextScaleCTM(context, 1.0, -1.0);

	switch (deviceOrientation_) {
		case CCDeviceOrientationPortrait:
			break;
		case CCDeviceOrientationPortraitUpsideDown:
			CGContextRotateCTM(context, CC_DEGREES_TO_RADIANS(180));
			CGContextTranslateCTM(context,-size.width, -size.height);
			break;
		case CCDeviceOrientationLandscapeLeft:
			CGContextRotateCTM(context, CC_DEGREES_TO_RADIANS(-90));
			CGContextTranslateCTM(context,-size.height, 0);
			break;
		case CCDeviceOrientationLandscapeRight:
			CGContextRotateCTM(context, CC_DEGREES_TO_RADIANS(90));
			CGContextTranslateCTM(context,size.width*0.5, -size.height);
			break;
	}
	CGContextDrawImage(context, CGRectMake(0.0, 0.0, size.width, size.height), iref);
	UIImage *outputImage = [UIImage imageWithCGImage:CGBitmapContextCreateImage(context)];
	Texture2D *texture = [[Texture2D alloc] initWithImage:outputImage];

	//Dealloc
	CGDataProviderRelease(ref);
	CGImageRelease(iref);
	CGContextRelease(context);
	free(pixels);

	return texture;
}</code></pre>
<p>I found the original code in: <a href="http://stackoverflow.com/questions/962390/capturing-eaglview-content-with-alpha-channel-on-iphone" rel="nofollow">http://stackoverflow.com/questions/962390/capturing-eaglview-content-with-alpha-channel-on-iphone</a></p>
<p>but I edited it because didn't support orientation and it didn't release the memory.</p>
<p>I open a inssue in the cocos2d-iphone Project:<br />
<a href="http://code.google.com/p/cocos2d-iphone/issues/detail?id=533" rel="nofollow">http://code.google.com/p/cocos2d-iphone/issues/detail?id=533</a>
</p></description>
		</item>
		<item>
			<title>tobscure on "Trying to create a CCRenderTexture in a different thread/OpenGL context"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/17880#post-100391</link>
			<pubDate>Wed, 22 Jun 2011 14:47:35 +0000</pubDate>
			<dc:creator>tobscure</dc:creator>
			<guid isPermaLink="false">100391@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>I'm trying to create a CCRenderTexture on a different thread so I can asynchronously load some resource-heavy dynamic textures. I have the thread stuff all working (using NSOperationQueue), and I'm able to create a solid colour texture (with [renderTexture beginWithClear:...]) and display that successfully.</p>
<p>The problem is, when I try to render anything else to the texture (e.g. a sprite), it's being scaled up waaaay out of proportion for some reason.</p>
<p>Here's my code:</p>
<pre><code>- (void) loadTexture {

    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

    EAGLSharegroup *sharegroup = [[[[CCDirector sharedDirector] openGLView] context] sharegroup];
    EAGLContext *k_context = [[[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1 sharegroup:sharegroup] autorelease];
    [EAGLContext setCurrentContext:k_context];

    CCRenderTexture *rt = [CCRenderTexture renderTextureWithWidth:256 height:256 pixelFormat:kTexture2DPixelFormat_RGBA8888];
    [rt beginWithClear:0 g:0 b:0 a:1];

    CCSprite *test = [CCSprite spriteWithSpriteFrameName:@&#34;sprite.png&#34;];
    test.position = ccp(0, 0);
    [test visit];

    [rt end];
    [EAGLContext setCurrentContext:nil];

    CCSprite *sprite = [CCSprite spriteWithTexture:rt.sprite.texture];
    [self performSelectorOnMainThread:@selector(textureLoaded:) withObject:sprite waitUntilDone:NO]; // adds the texture to the root layer

    [pool release];

}</code></pre>
<p>This is sprite.png:<br />
<img src="http://i.imgur.com/yl8jw.png" alt="" /></p>
<p>And this is what the texture comes out as:<br />
<img src="http://i.imgur.com/yjTlF.png" alt="" /></p>
<p>I believe this is a highly zoomed-up portion of the sprite.</p>
<p>But wait, it gets weirder! If I add:<br />
<code>test.scale = 0.01;</code><br />
before [test visit], I get this:<br />
<img src="http://i.imgur.com/nEPAI.png" alt="" /></p>
<p>This is happening on both the device and simulator.</p>
<p>If I take away the threading stuff and call this function on the main thread (minus the 3 lines of OpenGL context-related code), it works fine.</p>
<p>I don't know enough about OpenGL to have any clue as to what is going on here. My best guess is that the new OpenGL context hasn't been initialized properly or something similar.</p>
<p>Anyone have any ideas?
</p></description>
		</item>
		<item>
			<title>CyberJoe on "Dynamically Modify Sprite or CCLayer with bunch of Sprites in it"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/24537#post-129770</link>
			<pubDate>Mon, 28 Nov 2011 12:18:28 +0000</pubDate>
			<dc:creator>CyberJoe</dc:creator>
			<guid isPermaLink="false">129770@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>So let's say I have a png image, and it is some kind of image or texture.<br />
Or better say there is a bunch of them in one CCLayer.<br />
How can I:<br />
1) Modify HUE and Saturation of that CCLayer, (make it more black and white, or making it more colorful). In Photoshop you can modify colors of entire image by playing with HUE/Saturation sliders, Is there a way to achieve this with code in cocos2d for given CCLayer?<br />
2) Overlay Other texture over CCLayer so their colors would mix like you do in Photoshop when you put a layer on top of another and set Layer properties to overlay.</p>
<p>Is there a way to achieve it with Cocos2D functions only? or it's only possible with playing with render functions of OpenGL, if it is the second option, could you please bring some code samples?</p>
<p>If this kind of stuff would become possible, it would be possible to create really beautiful auto-generated landscapes in ios game, which is an asset.</p>
<p>Thanks.
</p></description>
		</item>
		<item>
			<title>zaaroth on "GL_BGRA_EXT and CCRenderTexture"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/23214#post-127530</link>
			<pubDate>Mon, 21 Nov 2011 19:35:59 +0000</pubDate>
			<dc:creator>zaaroth</dc:creator>
			<guid isPermaLink="false">127530@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>My goal was to capture some frames and drop into the video encoder so I get a nice movie of something. I got this working a while ago on simulator and didnt bother testing on device at the time because I had other stuff to deal with. Now that I tried I see I cant use glReadPixels with GL_BGRA_EXT on the device (even though simulator works fine).</p>
<p>There are 2 threads here that seems to tackle the issue:<br />
<a href="http://www.cocos2d-iphone.org/forum/topic/10178" rel="nofollow">http://www.cocos2d-iphone.org/forum/topic/10178</a><br />
<a href="http://www.cocos2d-iphone.org/forum/topic/21820" rel="nofollow">http://www.cocos2d-iphone.org/forum/topic/21820</a></p>
<p>They both state the guys were able to get this to work, but it wasnt working for me. And most stackoverflow questions stated iPhone does not support the format GL_BGRA (some didnt mention the _EXT that seems to be some extension that changes some format stuff I didnt even bother researching).</p>
<p>Then I found: <a href="http://www.idevgames.com/forums/thread-346-post-69703.html#pid69703" rel="nofollow">http://www.idevgames.com/forums/thread-346-post-69703.html#pid69703</a></p>
<p>Which made me think that the problem was that the texture of CCRenderTexture was configured to use GL_RGBA as format. So, when I tried to read pixels using the format GL_BGRA the pixels returned were transparent dark (0,0,0,0) for some odd reason I dont understand and lots of folks were reporting it.</p>
<p>So I got a new texture format on CCTexture2D that would initialize a texture with:<br />
<pre><code>glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (GLsizei) width, (GLsizei) height, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, data);</code></pre>
<p>Now things work properly. I use this texture type solely with CCRenderTexture and nowhere else. Feels a bit hackish.</p>
<p>Anybody got a better idea?</p>
<p>This guy blames the [CCRenderTexture begin] method on: <a href="http://stackoverflow.com/questions/6951077/opengl-es-on-ios-glreadpixel-doesnt-work-with-bgra-format" rel="nofollow">http://stackoverflow.com/questions/6951077/opengl-es-on-ios-glreadpixel-doesnt-work-with-bgra-format</a></p>
<p>Perhaps @<a href='http://www.cocos2d-iphone.org/forum/profile/11274'>araker</a> has some clue?
</p></description>
		</item>
		<item>
			<title>onedayitwillmake on "Smooth anti-alias lines"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/9188#post-53062</link>
			<pubDate>Tue, 31 Aug 2010 16:47:31 +0000</pubDate>
			<dc:creator>onedayitwillmake</dc:creator>
			<guid isPermaLink="false">53062@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi I am trying to draw a smooth anti alias line in this project I'm working on.<br />
I've implemented a line smoothing algorithm that takes place after the line is drawn, view in simulator so far works great.</p>
<p>However on my ipod touch they still appear jaggy and aliased. What is the proper way to draw an antialias line in opengl-es ( whichever version the ipod touch has )</p>
<p>Is this correct:<br />
<pre><code>-(void) draw
{
	// Default GL states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
	glDisable(GL_TEXTURE_2D);
	glDisableClientState(GL_COLOR_ARRAY);
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
	// line stuff
	glLineWidth(1.5);
	glEnable (GL_LINE_SMOOTH);
	glEnable(GL_BLEND);
	glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glHint (GL_LINE_SMOOTH_HINT, GL_NICEST);
	int i = 0;
	for (Boat* boat in _boats)
	{
		PointOnPath* firstPointOnPath = (PointOnPath*) [boat._path objectAtIndex:0];
		CGPoint	start = firstPointOnPath.position;	

		// Set the color and draw
		glColor4f(0.784, 0.02f, 0.341f, 0.9f);

		for(PointOnPath* path in boat._path)
		{
			CGPoint vertices[2];
			vertices[0] = start;
			vertices[1] = path.position;

			glVertexPointer(2, GL_FLOAT, 0, vertices);
			glDrawArrays(GL_LINES, 0, 2);
			start = path.position;
		}

		i++;
	}

	// restore default GL states
	glColor4f(1.0, 1.0, 1.0, 1.0);
	glEnable(GL_TEXTURE_2D);
	glEnableClientState(GL_COLOR_ARRAY);
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);

}</code></pre>
<p>Also just in case anyone wants to use it - this is the line smoothing algorithm in objective-c that i implemented (taken from an AS3 one) takes an array of points as the parameter</p>
<pre><code>+(NSMutableArray*) smoothPoints:(NSMutableArray*)points
{
	int len = [points count];
	int minAmount = 5;
	NSMutableArray* smoothedPoints = [NSMutableArray arrayWithCapacity: len];
	if(len &#60; minAmount) return points;

	int j = 0;
	int i = len;
	int smoothingAverage = 5;
	while (i--)
	{
		PointOnPath* currentPoint = [points objectAtIndex:i];

		if( i == len - 1 &#124;&#124; i == len - 2 &#124;&#124; i == 1 &#124;&#124; i == 0) {
			[ smoothedPoints addObject: currentPoint ];
		} else {
			j = minAmount;
			CGPoint average = ccp(0.0f, 0.0f);
			while (j--)
			{
				PointOnPath* futurePoint = (PointOnPath*) [points objectAtIndex: i + 2 - j];
				average.x += futurePoint.position.x;
				average.y += futurePoint.position.y;
			}

			average.x /= (float) smoothingAverage;
			average.y /= (float) smoothingAverage;

			PointOnPath* clone = [[PointOnPath alloc] initWithCGPoint: ccp( (currentPoint.position.x + average.x) * 0.5f , (currentPoint.position.y + average.y) * 0.5f )
															   withTime:currentPoint.time];
			[smoothedPoints addObject: clone];
			[clone release];
		}
	}

	return smoothedPoints;
}</code></pre>
<p>As a final note, i just noticed i'm not calling '[super draw]' on my scene, yet it's still being drawn - which is what I want, but im wondering how its being drawn if i didn't call super.
</p></description>
		</item>
		<item>
			<title>Yann on "Colored sprite edges like strategy games"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/22295#post-123724</link>
			<pubDate>Sun, 30 Oct 2011 21:35:12 +0000</pubDate>
			<dc:creator>Yann</dc:creator>
			<guid isPermaLink="false">123724@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi everybody,<br />
I am currently adding the finish touches to my game and I would like to add a dynamic colored border to a sprite which can change randomly.<br />
To be more precise: you can see this effect in Age of Empires 2 when your units are behind buildings, their silhouettes are shown so you can know where they are.</p>
<p>Does anyone has already made or used something like that? If so, what was your process to do it?</p>
<p>Thanks to all ;)
</p></description>
		</item>
		<item>
			<title>ffede81 on "CCMotionStreak or OpenGL for Line Drawing Game?"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/19184#post-107559</link>
			<pubDate>Thu, 28 Jul 2011 10:33:24 +0000</pubDate>
			<dc:creator>ffede81</dc:creator>
			<guid isPermaLink="false">107559@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hi guys,</p>
<p>As many of you have already tried to do, I'm studying the SIMPLEST way to create a Line Drawing Game, considering that:</p>
<p>- I'm quite new to Cocos2D<br />
- I don't like and don't want to use C<br />
- I don't want to use Core Animation<br />
- OpenGL may be an option but if possible I would like to avoid it</p>
<p>Now... after a couple of days of work and research on this and other forums and reading books (thanks Steffen and Ray), I made a working version of a Line Drawing Game using CCMotionStreak and I'm posting a link with the project below. It's made of 3 classes:</p>
<p>- GameScene<br />
- Player (a CCSprite)<br />
- Line (a CCNode)</p>
<p>Here it is:</p>
<p><a href="http://dl.dropbox.com/u/8191872/LineDrawingSample.zip" rel="nofollow">http://dl.dropbox.com/u/8191872/LineDrawingSample.zip</a></p>
<p>As you will notice it has a couple of (BIG) problems:</p>
<p>1) Rotation is messing up the line texture. After the first movement, if the player is not rotated as it was at the beginning, the line is drawn elsewhere, though the points collected in the points array are correct: the player will follow the line that you trace with your mouse (or touch), not the green line that you see. And that's ok, but I don't get why the line is drawn elsewhere...</p>
<p>2) if the player is moving, by touching it you can stop it and draw another path (with the same problems as in point 1), but sometimes the line gets duplicated and more lines start from the player, even though the player will always correctly follow the line you want him to follow..</p>
<p>I guess for point 1 the problem is the rotation. If I disable it from the code, it's not happening anymore, while for the 2nd problem I have no clue...</p>
<p>So I tried to look at OpenGL as I think everyone is using it for Line Drawing Games... the problem is that if I implement it in the Line class excluding the CCMotionStreak, I get a strange behaviour from the player... I'll try to wrap up a new project with the code I'm talking about, but in the meantime what do you think of the above code using CCMotionStreak? And how would you implement it in a different way to solve the problems mentioned? Also if you have a suggestion regarding OpenGL you are very welcome... :)
</p></description>
		</item>
		<item>
			<title>riq on "[devel] OpenGL ES 2.0 support"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/6074#post-35827</link>
			<pubDate>Thu, 29 Apr 2010 21:40:26 +0000</pubDate>
			<dc:creator>riq</dc:creator>
			<guid isPermaLink="false">35827@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>Hey,</p>
<p>The idea is to use this thread to discuss how to implement OpenGL ES 2.0 support without the need to write a shader for each <code>CCNode</code>.<br />
The idea is that if the <code>CCNode</code> contains a shader, then it should use it, otherwise it should continue rendering itself using the GL ES 1.0 code.</p>
<p>How: I believe that it is possible to mix OpenGL ES 2.0 with ES 1.0 code on the iPhone 3GS (and iPad).</p>
<p>If this is true, then <code>CCNode</code> could have a new ivar called <code>program</code> (or <code>shader</code>... ):</p>
<pre><code>// pseudo code
class CCNode
{
    // program to use
    GLuint program;

   def draw( self ):
       if( program ) {
          glUseProgram( program );

          // update uniforms...
       }

     // continue with the draw loop
}</code></pre>
<p>DISCLAIMER: I've not tested this idea yet, but I think it might work.
</p></description>
		</item>

	</channel>
</rss>

