Permalink
Browse files

RenderTexture: compiles on Mac

  • Loading branch information...
ricardoquesada committed Apr 26, 2012
1 parent 1b50f64 commit 1b69028d6c0cf23e357577902505821a12188b95
View
@@ -67,6 +67,9 @@ People/companies who were/are contributing code to cocos2d for iPhone (alphabeti
Added tests for LabelTTF vertical alignment
Added tetts for Scheduler/ActionManager resume/pause all actions
Director doesn't raise assert when startAnimation is called twice
+
+* Krzysztof Zablocki (http://merowing.info):
+ Added support for Depth Stencil in RenderTexture
* Lam Pham (http://www.fancyratstudios.com/)
CCProgressTimer: Improved API
View
@@ -1,5 +1,7 @@
version 2.0-rc2 XX-May-2012
. [NEW] Added Javascript test using JSCocoa (Mac only)
+. [NEW] RenderTexture: Added support for Depth Stencil
+. [FIX] Macros: CCLOG doesn't log the function name. Only CCLOGERROR.
version 2.0-rc1 19-Apr-2012
. [NEW] v1.1 Forward-ported changes:
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
<data>
- <int key="IBDocument.SystemTarget">1060</int>
- <string key="IBDocument.SystemVersion">10K549</string>
- <string key="IBDocument.InterfaceBuilderVersion">1938</string>
- <string key="IBDocument.AppKitVersion">1038.36</string>
- <string key="IBDocument.HIToolboxVersion">461.00</string>
+ <int key="IBDocument.SystemTarget">1070</int>
+ <string key="IBDocument.SystemVersion">11D50</string>
+ <string key="IBDocument.InterfaceBuilderVersion">2182</string>
+ <string key="IBDocument.AppKitVersion">1138.32</string>
+ <string key="IBDocument.HIToolboxVersion">568.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="NS.object.0">1938</string>
+ <string key="NS.object.0">2182</string>
</object>
<object class="NSArray" key="IBDocument.IntegratedClassDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -295,6 +295,7 @@
<string key="NSWindowTitle">cocos2dmac</string>
<string key="NSWindowClass">NSWindow</string>
<nil key="NSViewClass"/>
+ <nil key="NSUserInterfaceItemIdentifier"/>
<object class="NSView" key="NSWindowView" id="439893737">
<reference key="NSNextResponder"/>
<int key="NSvFlags">256</int>
@@ -307,7 +308,6 @@
<string key="NSFrame">{{0, 20}, {580, 396}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
- <reference key="NSNextKeyView"/>
<int key="NSViewLayerContentsRedrawPolicy">2</int>
<object class="NSOpenGLPixelFormat" key="NSPixelFormat">
<object class="NSMutableData" key="NSPixelAttributes">
@@ -322,7 +322,8 @@
<reference key="NSNextKeyView" ref="335206536"/>
</object>
<string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
- <string key="NSMaxSize">{1e+13, 1e+13}</string>
+ <string key="NSMaxSize">{10000000000000, 10000000000000}</string>
+ <bool key="NSWindowIsRestorable">YES</bool>
</object>
<object class="NSCustomObject" id="976324537">
<string key="NSClassName">AppController</string>
@@ -737,7 +738,7 @@
<string>58.IBPluginDependency</string>
<string>92.IBPluginDependency</string>
</object>
- <object class="NSMutableArray" key="dict.values">
+ <object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -825,7 +826,7 @@
<string>glView</string>
<string>window</string>
</object>
- <object class="NSMutableArray" key="dict.values">
+ <object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>CCGLView</string>
<string>NSWindow</string>
@@ -838,7 +839,7 @@
<string>glView</string>
<string>window</string>
</object>
- <object class="NSMutableArray" key="dict.values">
+ <object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBToOneOutletInfo">
<string key="name">glView</string>
@@ -880,10 +881,10 @@
<string>NSMenuCheckmark</string>
<string>NSMenuMixedState</string>
</object>
- <object class="NSMutableArray" key="dict.values">
+ <object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
- <string>{9, 8}</string>
- <string>{7, 2}</string>
+ <string>{11, 11}</string>
+ <string>{10, 3}</string>
</object>
</object>
</data>
@@ -1,85 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<Scheme
- version = "1.3">
- <BuildAction
- parallelizeBuildables = "YES"
- buildImplicitDependencies = "YES">
- <BuildActionEntries>
- <BuildActionEntry
- buildForTesting = "YES"
- buildForRunning = "YES"
- buildForProfiling = "YES"
- buildForArchiving = "YES"
- buildForAnalyzing = "YES">
- <BuildableReference
- BuildableIdentifier = "primary"
- BlueprintIdentifier = "A034160515487C3C00AE4D93"
- BuildableName = "SpriteTest copy.app"
- BlueprintName = "JavascriptTest"
- ReferencedContainer = "container:cocos2d-mac.xcodeproj">
- </BuildableReference>
- </BuildActionEntry>
- </BuildActionEntries>
- </BuildAction>
- <TestAction
- selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
- selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
- shouldUseLaunchSchemeArgsEnv = "YES"
- buildConfiguration = "Debug">
- <Testables>
- </Testables>
- <MacroExpansion>
- <BuildableReference
- BuildableIdentifier = "primary"
- BlueprintIdentifier = "A034160515487C3C00AE4D93"
- BuildableName = "SpriteTest copy.app"
- BlueprintName = "JavascriptTest"
- ReferencedContainer = "container:cocos2d-mac.xcodeproj">
- </BuildableReference>
- </MacroExpansion>
- </TestAction>
- <LaunchAction
- selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB"
- selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
- launchStyle = "0"
- useCustomWorkingDirectory = "NO"
- buildConfiguration = "Debug"
- ignoresPersistentStateOnLaunch = "NO"
- debugDocumentVersioning = "YES"
- allowLocationSimulation = "YES">
- <BuildableProductRunnable>
- <BuildableReference
- BuildableIdentifier = "primary"
- BlueprintIdentifier = "A034160515487C3C00AE4D93"
- BuildableName = "SpriteTest copy.app"
- BlueprintName = "JavascriptTest"
- ReferencedContainer = "container:cocos2d-mac.xcodeproj">
- </BuildableReference>
- </BuildableProductRunnable>
- <AdditionalOptions>
- </AdditionalOptions>
- </LaunchAction>
- <ProfileAction
- shouldUseLaunchSchemeArgsEnv = "YES"
- savedToolIdentifier = ""
- useCustomWorkingDirectory = "NO"
- buildConfiguration = "Release"
- debugDocumentVersioning = "YES">
- <BuildableProductRunnable>
- <BuildableReference
- BuildableIdentifier = "primary"
- BlueprintIdentifier = "A034160515487C3C00AE4D93"
- BuildableName = "SpriteTest copy.app"
- BlueprintName = "JavascriptTest"
- ReferencedContainer = "container:cocos2d-mac.xcodeproj">
- </BuildableReference>
- </BuildableProductRunnable>
- </ProfileAction>
- <AnalyzeAction
- buildConfiguration = "Debug">
- </AnalyzeAction>
- <ArchiveAction
- buildConfiguration = "Release"
- revealArchiveInOrganizer = "YES">
- </ArchiveAction>
-</Scheme>
View
@@ -79,7 +79,7 @@ -(id)initWithWidth:(int)w height:(int)h pixelFormat:(CCTexture2DPixelFormat) for
// XXX multithread
if( [director runningThread] != [NSThread currentThread] )
- CCLOG(@"cocos2d: WARNING. CCRenderTexture is running on its own thread. Make sure that an OpenGL context is being used on this thread!");
+ CCLOGWARN(@"cocos2d: WARNING. CCRenderTexture is running on its own thread. Make sure that an OpenGL context is being used on this thread!");
w *= CC_CONTENT_SCALE_FACTOR();
@@ -106,29 +106,27 @@ -(id)initWithWidth:(int)w height:(int)h pixelFormat:(CCTexture2DPixelFormat) for
texture_ = [[CCTexture2D alloc] initWithData:data pixelFormat:pixelFormat_ pixelsWide:powW pixelsHigh:powH contentSize:CGSizeMake(w, h)];
free( data );
- GLint oldRBO;
- glGetIntegerv(GL_RENDERBUFFER_BINDING, &oldRBO);
+ GLint oldRBO;
+ glGetIntegerv(GL_RENDERBUFFER_BINDING, &oldRBO);
- // generate FBO
+ // generate FBO
glGenFramebuffers(1, &fbo_);
glBindFramebuffer(GL_FRAMEBUFFER, fbo_);
// associate texture with FBO
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture_.name, 0);
- if (depthStencilFormat != 0) {
- //create and attach depth buffer
- glGenRenderbuffers(1, &depthRenderBufffer_);
- glBindRenderbuffer(GL_RENDERBUFFER, depthRenderBufffer_);
- glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, powW, powH);
- glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthRenderBufffer_);
+ if (depthStencilFormat != 0) {
+ //create and attach depth buffer
+ glGenRenderbuffers(1, &depthRenderBufffer_);
+ glBindRenderbuffer(GL_RENDERBUFFER, depthRenderBufffer_);
+ glRenderbufferStorage(GL_RENDERBUFFER, CC_GL_DEPTH24_STENCIL8, powW, powH);
+ glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthRenderBufffer_);
- // if depth format is the one with stencil part, bind same render buffer as stencil attachment
- if (depthStencilFormat == GL_DEPTH24_STENCIL8_OES) {
- glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
- GL_RENDERBUFFER, depthRenderBufffer_);
- }
- }
+ // if depth format is the one with stencil part, bind same render buffer as stencil attachment
+ if (depthStencilFormat == CC_GL_DEPTH24_STENCIL8)
+ glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, depthRenderBufffer_);
+ }
// check if it worked (probably worth doing :) )
NSAssert( glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE, @"Could not attach texture to framebuffer");
@@ -144,7 +142,7 @@ -(id)initWithWidth:(int)w height:(int)h pixelFormat:(CCTexture2DPixelFormat) for
// issue #937
[sprite_ setBlendFunc:(ccBlendFunc){GL_ONE, GL_ONE_MINUS_SRC_ALPHA}];
- glBindRenderbuffer(GL_RENDERBUFFER, oldRBO);
+ glBindRenderbuffer(GL_RENDERBUFFER, oldRBO);
glBindFramebuffer(GL_FRAMEBUFFER, oldFBO_);
}
return self;
@@ -153,9 +151,9 @@ -(id)initWithWidth:(int)w height:(int)h pixelFormat:(CCTexture2DPixelFormat) for
-(void)dealloc
{
glDeleteFramebuffers(1, &fbo_);
- if (depthRenderBufffer_) {
- glDeleteRenderbuffers(1, &depthRenderBufffer_);
- }
+ if (depthRenderBufffer_)
+ glDeleteRenderbuffers(1, &depthRenderBufffer_);
+
[super dealloc];
}
View
@@ -50,9 +50,13 @@
#define glGenVertexArrays glGenVertexArraysOES
#define glBindVertexArray glBindVertexArrayOES
+#define CC_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_OES
+
// Mac
#elif __CC_PLATFORM_MAC
+#define CC_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8
+
#if 1
#define glDeleteVertexArrays glDeleteVertexArraysAPPLE
#define glGenVertexArrays glGenVertexArraysAPPLE
View
@@ -66,17 +66,17 @@ NSLog(@"%@",[NSString stringWithFormat:(s), ##__VA_ARGS__])
#if !defined(COCOS2D_DEBUG) || COCOS2D_DEBUG == 0
#define CCLOG(...) do {} while (0)
+#define CCLOGWARN(...) do {} while (0)
#define CCLOGINFO(...) do {} while (0)
-#define CCLOGERROR(...) do {} while (0)
#elif COCOS2D_DEBUG == 1
#define CCLOG(...) __CCLOG(__VA_ARGS__)
-#define CCLOGERROR(...) __CCLOGWITHFUNCTION(__VA_ARGS__)
+#define CCLOGWARN(...) __CCLOGWITHFUNCTION(__VA_ARGS__)
#define CCLOGINFO(...) do {} while (0)
#elif COCOS2D_DEBUG > 1
#define CCLOG(...) __CCLOG(__VA_ARGS__)
-#define CCLOGERROR(...) __CCLOGWITHFUNCTION(__VA_ARGS__)
+#define CCLOGWARN(...) __CCLOGWITHFUNCTION(__VA_ARGS__)
#define CCLOGINFO(...) __CCLOG(__VA_ARGS__)
#endif // COCOS2D_DEBUG
@@ -650,7 +650,7 @@ -(id) init
CCSprite *sprite = [CCSprite spriteWithFile:@"fire.png"];
sprite.position = ccp(s.width * 0.25f, 0);
sprite.scale = 10;
- CCRenderTexture *rend = [CCRenderTexture renderTextureWithWidth:s.width height:s.height pixelFormat:kCCTexture2DPixelFormat_RGBA4444 depthStencilFormat:GL_DEPTH24_STENCIL8_OES];
+ CCRenderTexture *rend = [CCRenderTexture renderTextureWithWidth:s.width height:s.height pixelFormat:kCCTexture2DPixelFormat_RGBA4444 depthStencilFormat:CC_GL_DEPTH24_STENCIL8];
glStencilMask(0xFF);
[rend beginWithClear:0 g:0 b:0 a:0 depth:0 stencil:0];
@@ -659,7 +659,7 @@ -(id) init
glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_ALWAYS, 1, 0xFF);
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
- glColorMask(0, 0, 0, 0);
+ glColorMask(0, 0, 0, 1);
[sprite visit];
//! move sprite half width and height, and draw only where not marked

0 comments on commit 1b69028

Please sign in to comment.