mirror of https://github.com/axmolengine/axmol.git
Merge pull request #7701 from dabingnn/v3_renderPrimitive
V3 render primitive
This commit is contained in:
commit
46cdd6f8dd
|
@ -1252,6 +1252,7 @@
|
||||||
50ABC0671926664800A911A9 /* CCPlatformDefine.h in Headers */ = {isa = PBXBuildFile; fileRef = 50ABBF541926664700A911A9 /* CCPlatformDefine.h */; };
|
50ABC0671926664800A911A9 /* CCPlatformDefine.h in Headers */ = {isa = PBXBuildFile; fileRef = 50ABBF541926664700A911A9 /* CCPlatformDefine.h */; };
|
||||||
50ABC0691926664800A911A9 /* CCStdC.h in Headers */ = {isa = PBXBuildFile; fileRef = 50ABBF551926664700A911A9 /* CCStdC.h */; };
|
50ABC0691926664800A911A9 /* CCStdC.h in Headers */ = {isa = PBXBuildFile; fileRef = 50ABBF551926664700A911A9 /* CCStdC.h */; };
|
||||||
A07A4CAF1783777C0073F6A7 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1551A342158F2AB200E66CFE /* Foundation.framework */; };
|
A07A4CAF1783777C0073F6A7 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1551A342158F2AB200E66CFE /* Foundation.framework */; };
|
||||||
|
B2165EEA19921124000BE3E6 /* CCPrimitiveCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B257B45E198A353E00D9A687 /* CCPrimitiveCommand.cpp */; };
|
||||||
B217703C1977ECB4009EE11B /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B217703B1977ECB4009EE11B /* IOKit.framework */; };
|
B217703C1977ECB4009EE11B /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B217703B1977ECB4009EE11B /* IOKit.framework */; };
|
||||||
B21770401977ECE6009EE11B /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B217703F1977ECE6009EE11B /* OpenGL.framework */; };
|
B21770401977ECE6009EE11B /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B217703F1977ECE6009EE11B /* OpenGL.framework */; };
|
||||||
B21770421977ECF8009EE11B /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B21770411977ECF8009EE11B /* ApplicationServices.framework */; };
|
B21770421977ECF8009EE11B /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B21770411977ECF8009EE11B /* ApplicationServices.framework */; };
|
||||||
|
@ -1275,6 +1276,20 @@
|
||||||
B24AA98A195A675C007B4522 /* CCFastTMXTiledMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B24AA983195A675C007B4522 /* CCFastTMXTiledMap.cpp */; };
|
B24AA98A195A675C007B4522 /* CCFastTMXTiledMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B24AA983195A675C007B4522 /* CCFastTMXTiledMap.cpp */; };
|
||||||
B24AA98B195A675C007B4522 /* CCFastTMXTiledMap.h in Headers */ = {isa = PBXBuildFile; fileRef = B24AA984195A675C007B4522 /* CCFastTMXTiledMap.h */; };
|
B24AA98B195A675C007B4522 /* CCFastTMXTiledMap.h in Headers */ = {isa = PBXBuildFile; fileRef = B24AA984195A675C007B4522 /* CCFastTMXTiledMap.h */; };
|
||||||
B24AA98C195A675C007B4522 /* CCFastTMXTiledMap.h in Headers */ = {isa = PBXBuildFile; fileRef = B24AA984195A675C007B4522 /* CCFastTMXTiledMap.h */; };
|
B24AA98C195A675C007B4522 /* CCFastTMXTiledMap.h in Headers */ = {isa = PBXBuildFile; fileRef = B24AA984195A675C007B4522 /* CCFastTMXTiledMap.h */; };
|
||||||
|
B257B44E1989D5E800D9A687 /* CCPrimitive.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B257B44C1989D5E800D9A687 /* CCPrimitive.cpp */; };
|
||||||
|
B257B44F1989D5E800D9A687 /* CCPrimitive.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B257B44C1989D5E800D9A687 /* CCPrimitive.cpp */; };
|
||||||
|
B257B4501989D5E800D9A687 /* CCPrimitive.h in Headers */ = {isa = PBXBuildFile; fileRef = B257B44D1989D5E800D9A687 /* CCPrimitive.h */; };
|
||||||
|
B257B4511989D5E800D9A687 /* CCPrimitive.h in Headers */ = {isa = PBXBuildFile; fileRef = B257B44D1989D5E800D9A687 /* CCPrimitive.h */; };
|
||||||
|
B257B460198A353E00D9A687 /* CCPrimitiveCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B257B45E198A353E00D9A687 /* CCPrimitiveCommand.cpp */; };
|
||||||
|
B257B461198A353E00D9A687 /* CCPrimitiveCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = B257B45F198A353E00D9A687 /* CCPrimitiveCommand.h */; };
|
||||||
|
B276EF5F1988D1D500CD400F /* CCVertexIndexData.h in Headers */ = {isa = PBXBuildFile; fileRef = B276EF5B1988D1D500CD400F /* CCVertexIndexData.h */; };
|
||||||
|
B276EF601988D1D500CD400F /* CCVertexIndexData.h in Headers */ = {isa = PBXBuildFile; fileRef = B276EF5B1988D1D500CD400F /* CCVertexIndexData.h */; };
|
||||||
|
B276EF611988D1D500CD400F /* CCVertexIndexData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B276EF5C1988D1D500CD400F /* CCVertexIndexData.cpp */; };
|
||||||
|
B276EF621988D1D500CD400F /* CCVertexIndexData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B276EF5C1988D1D500CD400F /* CCVertexIndexData.cpp */; };
|
||||||
|
B276EF631988D1D500CD400F /* CCVertexIndexBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = B276EF5D1988D1D500CD400F /* CCVertexIndexBuffer.h */; };
|
||||||
|
B276EF641988D1D500CD400F /* CCVertexIndexBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = B276EF5D1988D1D500CD400F /* CCVertexIndexBuffer.h */; };
|
||||||
|
B276EF651988D1D500CD400F /* CCVertexIndexBuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B276EF5E1988D1D500CD400F /* CCVertexIndexBuffer.cpp */; };
|
||||||
|
B276EF661988D1D500CD400F /* CCVertexIndexBuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B276EF5E1988D1D500CD400F /* CCVertexIndexBuffer.cpp */; };
|
||||||
B27AEE0219768934008BD575 /* libwebsockets.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AAF5384180E35A3000584C8 /* libwebsockets.a */; };
|
B27AEE0219768934008BD575 /* libwebsockets.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AAF5384180E35A3000584C8 /* libwebsockets.a */; };
|
||||||
B282B4801980E08F00666787 /* CCEditBoxImplMac.h in Headers */ = {isa = PBXBuildFile; fileRef = B282B47D1980E02B00666787 /* CCEditBoxImplMac.h */; };
|
B282B4801980E08F00666787 /* CCEditBoxImplMac.h in Headers */ = {isa = PBXBuildFile; fileRef = B282B47D1980E02B00666787 /* CCEditBoxImplMac.h */; };
|
||||||
B282B4811980E0A300666787 /* CCEditBoxImplMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = B282B47C1980E02B00666787 /* CCEditBoxImplMac.mm */; };
|
B282B4811980E0A300666787 /* CCEditBoxImplMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = B282B47C1980E02B00666787 /* CCEditBoxImplMac.mm */; };
|
||||||
|
@ -3009,6 +3024,14 @@
|
||||||
B24EEA7619775ECE004493CC /* libcocosbuilder iOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libcocosbuilder iOS.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
B24EEA7619775ECE004493CC /* libcocosbuilder iOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libcocosbuilder iOS.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
B24EEA7E19775EE1004493CC /* libspine iOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libspine iOS.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
B24EEA7E19775EE1004493CC /* libspine iOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libspine iOS.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
B24EEA8619775EF3004493CC /* libnetwork iOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libnetwork iOS.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
B24EEA8619775EF3004493CC /* libnetwork iOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libnetwork iOS.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
B257B44C1989D5E800D9A687 /* CCPrimitive.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCPrimitive.cpp; sourceTree = "<group>"; };
|
||||||
|
B257B44D1989D5E800D9A687 /* CCPrimitive.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPrimitive.h; sourceTree = "<group>"; };
|
||||||
|
B257B45E198A353E00D9A687 /* CCPrimitiveCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCPrimitiveCommand.cpp; sourceTree = "<group>"; };
|
||||||
|
B257B45F198A353E00D9A687 /* CCPrimitiveCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPrimitiveCommand.h; sourceTree = "<group>"; };
|
||||||
|
B276EF5B1988D1D500CD400F /* CCVertexIndexData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCVertexIndexData.h; sourceTree = "<group>"; };
|
||||||
|
B276EF5C1988D1D500CD400F /* CCVertexIndexData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCVertexIndexData.cpp; sourceTree = "<group>"; };
|
||||||
|
B276EF5D1988D1D500CD400F /* CCVertexIndexBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCVertexIndexBuffer.h; sourceTree = "<group>"; };
|
||||||
|
B276EF5E1988D1D500CD400F /* CCVertexIndexBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCVertexIndexBuffer.cpp; sourceTree = "<group>"; };
|
||||||
B282B47C1980E02B00666787 /* CCEditBoxImplMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CCEditBoxImplMac.mm; sourceTree = "<group>"; };
|
B282B47C1980E02B00666787 /* CCEditBoxImplMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CCEditBoxImplMac.mm; sourceTree = "<group>"; };
|
||||||
B282B47D1980E02B00666787 /* CCEditBoxImplMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEditBoxImplMac.h; sourceTree = "<group>"; };
|
B282B47D1980E02B00666787 /* CCEditBoxImplMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEditBoxImplMac.h; sourceTree = "<group>"; };
|
||||||
B29594AF1926D5D9003EEF37 /* ccShader_3D_Color.frag */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_3D_Color.frag; sourceTree = "<group>"; };
|
B29594AF1926D5D9003EEF37 /* ccShader_3D_Color.frag */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_3D_Color.frag; sourceTree = "<group>"; };
|
||||||
|
@ -4899,6 +4922,10 @@
|
||||||
500DC89819105D41007B91BF /* renderer */ = {
|
500DC89819105D41007B91BF /* renderer */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
B276EF5B1988D1D500CD400F /* CCVertexIndexData.h */,
|
||||||
|
B276EF5C1988D1D500CD400F /* CCVertexIndexData.cpp */,
|
||||||
|
B276EF5D1988D1D500CD400F /* CCVertexIndexBuffer.h */,
|
||||||
|
B276EF5E1988D1D500CD400F /* CCVertexIndexBuffer.cpp */,
|
||||||
50ABBD641925AB4100A911A9 /* CCBatchCommand.cpp */,
|
50ABBD641925AB4100A911A9 /* CCBatchCommand.cpp */,
|
||||||
50ABBD651925AB4100A911A9 /* CCBatchCommand.h */,
|
50ABBD651925AB4100A911A9 /* CCBatchCommand.h */,
|
||||||
50ABBD661925AB4100A911A9 /* CCCustomCommand.cpp */,
|
50ABBD661925AB4100A911A9 /* CCCustomCommand.cpp */,
|
||||||
|
@ -4932,6 +4959,10 @@
|
||||||
50ABBD801925AB4100A911A9 /* CCTextureAtlas.h */,
|
50ABBD801925AB4100A911A9 /* CCTextureAtlas.h */,
|
||||||
50ABBD811925AB4100A911A9 /* CCTextureCache.cpp */,
|
50ABBD811925AB4100A911A9 /* CCTextureCache.cpp */,
|
||||||
50ABBD821925AB4100A911A9 /* CCTextureCache.h */,
|
50ABBD821925AB4100A911A9 /* CCTextureCache.h */,
|
||||||
|
B257B44C1989D5E800D9A687 /* CCPrimitive.cpp */,
|
||||||
|
B257B44D1989D5E800D9A687 /* CCPrimitive.h */,
|
||||||
|
B257B45E198A353E00D9A687 /* CCPrimitiveCommand.cpp */,
|
||||||
|
B257B45F198A353E00D9A687 /* CCPrimitiveCommand.h */,
|
||||||
5034CA5D191D591900CE6051 /* shaders */,
|
5034CA5D191D591900CE6051 /* shaders */,
|
||||||
);
|
);
|
||||||
name = renderer;
|
name = renderer;
|
||||||
|
@ -5260,6 +5291,7 @@
|
||||||
B375107B1823AC9F00B3BA6A /* CCPhysicsWorldInfo_chipmunk.h in Headers */,
|
B375107B1823AC9F00B3BA6A /* CCPhysicsWorldInfo_chipmunk.h in Headers */,
|
||||||
46A170F01807CECA005B8026 /* CCPhysicsWorld.h in Headers */,
|
46A170F01807CECA005B8026 /* CCPhysicsWorld.h in Headers */,
|
||||||
50ABBEC11925AB6F00A911A9 /* CCValue.h in Headers */,
|
50ABBEC11925AB6F00A911A9 /* CCValue.h in Headers */,
|
||||||
|
B276EF631988D1D500CD400F /* CCVertexIndexBuffer.h in Headers */,
|
||||||
50ABBE871925AB6F00A911A9 /* ccMacros.h in Headers */,
|
50ABBE871925AB6F00A911A9 /* ccMacros.h in Headers */,
|
||||||
50ABBE731925AB6F00A911A9 /* CCEventListenerMouse.h in Headers */,
|
50ABBE731925AB6F00A911A9 /* CCEventListenerMouse.h in Headers */,
|
||||||
1A570063180BC5A10088DEC7 /* CCAction.h in Headers */,
|
1A570063180BC5A10088DEC7 /* CCAction.h in Headers */,
|
||||||
|
@ -5270,6 +5302,7 @@
|
||||||
5034CA3B191D591100CE6051 /* ccShader_PositionColor.vert in Headers */,
|
5034CA3B191D591100CE6051 /* ccShader_PositionColor.vert in Headers */,
|
||||||
1A570077180BC5A10088DEC7 /* CCActionGrid3D.h in Headers */,
|
1A570077180BC5A10088DEC7 /* CCActionGrid3D.h in Headers */,
|
||||||
1A57007B180BC5A10088DEC7 /* CCActionInstant.h in Headers */,
|
1A57007B180BC5A10088DEC7 /* CCActionInstant.h in Headers */,
|
||||||
|
B276EF5F1988D1D500CD400F /* CCVertexIndexData.h in Headers */,
|
||||||
1A57007F180BC5A10088DEC7 /* CCActionInterval.h in Headers */,
|
1A57007F180BC5A10088DEC7 /* CCActionInterval.h in Headers */,
|
||||||
1A01C69A18F57BE800EFE3A6 /* CCSet.h in Headers */,
|
1A01C69A18F57BE800EFE3A6 /* CCSet.h in Headers */,
|
||||||
1A570083180BC5A10088DEC7 /* CCActionManager.h in Headers */,
|
1A570083180BC5A10088DEC7 /* CCActionManager.h in Headers */,
|
||||||
|
@ -5399,6 +5432,7 @@
|
||||||
5034CA35191D591100CE6051 /* ccShader_PositionTexture.frag in Headers */,
|
5034CA35191D591100CE6051 /* ccShader_PositionTexture.frag in Headers */,
|
||||||
50ABBE6F1925AB6F00A911A9 /* CCEventListenerKeyboard.h in Headers */,
|
50ABBE6F1925AB6F00A911A9 /* CCEventListenerKeyboard.h in Headers */,
|
||||||
50ABBE9D1925AB6F00A911A9 /* CCRefPtr.h in Headers */,
|
50ABBE9D1925AB6F00A911A9 /* CCRefPtr.h in Headers */,
|
||||||
|
B257B461198A353E00D9A687 /* CCPrimitiveCommand.h in Headers */,
|
||||||
5034CA31191D591100CE6051 /* ccShader_PositionTexture_uColor.vert in Headers */,
|
5034CA31191D591100CE6051 /* ccShader_PositionTexture_uColor.vert in Headers */,
|
||||||
50ABBE7B1925AB6F00A911A9 /* CCEventMouse.h in Headers */,
|
50ABBE7B1925AB6F00A911A9 /* CCEventMouse.h in Headers */,
|
||||||
503DD8F91926B0DB00CD74DD /* CCIMEDispatcher.h in Headers */,
|
503DD8F91926B0DB00CD74DD /* CCIMEDispatcher.h in Headers */,
|
||||||
|
@ -5406,6 +5440,7 @@
|
||||||
50ABBE8F1925AB6F00A911A9 /* CCPlatformConfig.h in Headers */,
|
50ABBE8F1925AB6F00A911A9 /* CCPlatformConfig.h in Headers */,
|
||||||
50ABBE291925AB6F00A911A9 /* CCAutoreleasePool.h in Headers */,
|
50ABBE291925AB6F00A911A9 /* CCAutoreleasePool.h in Headers */,
|
||||||
50ABBE471925AB6F00A911A9 /* CCEvent.h in Headers */,
|
50ABBE471925AB6F00A911A9 /* CCEvent.h in Headers */,
|
||||||
|
B257B4501989D5E800D9A687 /* CCPrimitive.h in Headers */,
|
||||||
50ABBE6B1925AB6F00A911A9 /* CCEventListenerFocus.h in Headers */,
|
50ABBE6B1925AB6F00A911A9 /* CCEventListenerFocus.h in Headers */,
|
||||||
50ABBDA51925AB4100A911A9 /* CCQuadCommand.h in Headers */,
|
50ABBDA51925AB4100A911A9 /* CCQuadCommand.h in Headers */,
|
||||||
50ABBD3A1925AB0000A911A9 /* CCAffineTransform.h in Headers */,
|
50ABBD3A1925AB0000A911A9 /* CCAffineTransform.h in Headers */,
|
||||||
|
@ -5630,6 +5665,7 @@
|
||||||
5034CA40191D591100CE6051 /* ccShader_Position_uColor.vert in Headers */,
|
5034CA40191D591100CE6051 /* ccShader_Position_uColor.vert in Headers */,
|
||||||
50ABBEC21925AB6F00A911A9 /* CCValue.h in Headers */,
|
50ABBEC21925AB6F00A911A9 /* CCValue.h in Headers */,
|
||||||
50ABBECA1925AB6F00A911A9 /* firePngData.h in Headers */,
|
50ABBECA1925AB6F00A911A9 /* firePngData.h in Headers */,
|
||||||
|
B257B4511989D5E800D9A687 /* CCPrimitive.h in Headers */,
|
||||||
50ABBE401925AB6F00A911A9 /* CCDataVisitor.h in Headers */,
|
50ABBE401925AB6F00A911A9 /* CCDataVisitor.h in Headers */,
|
||||||
1A570064180BC5A10088DEC7 /* CCAction.h in Headers */,
|
1A570064180BC5A10088DEC7 /* CCAction.h in Headers */,
|
||||||
503DD8EC1926736A00CD74DD /* CCGLViewImpl.h in Headers */,
|
503DD8EC1926736A00CD74DD /* CCGLViewImpl.h in Headers */,
|
||||||
|
@ -5804,6 +5840,7 @@
|
||||||
50ABBDBC1925AB4100A911A9 /* CCTextureAtlas.h in Headers */,
|
50ABBDBC1925AB4100A911A9 /* CCTextureAtlas.h in Headers */,
|
||||||
50ABBE541925AB6F00A911A9 /* CCEventDispatcher.h in Headers */,
|
50ABBE541925AB6F00A911A9 /* CCEventDispatcher.h in Headers */,
|
||||||
1A12775A18DFCC4F0005F345 /* CCTweenFunction.h in Headers */,
|
1A12775A18DFCC4F0005F345 /* CCTweenFunction.h in Headers */,
|
||||||
|
B276EF601988D1D500CD400F /* CCVertexIndexData.h in Headers */,
|
||||||
50ABBD5F1925AB0000A911A9 /* Vec3.h in Headers */,
|
50ABBD5F1925AB0000A911A9 /* Vec3.h in Headers */,
|
||||||
50ABBE921925AB6F00A911A9 /* CCPlatformMacros.h in Headers */,
|
50ABBE921925AB6F00A911A9 /* CCPlatformMacros.h in Headers */,
|
||||||
50ABBE821925AB6F00A911A9 /* CCEventType.h in Headers */,
|
50ABBE821925AB6F00A911A9 /* CCEventType.h in Headers */,
|
||||||
|
@ -5821,6 +5858,7 @@
|
||||||
1A01C6A718F58F7500EFE3A6 /* CCNotificationCenter.h in Headers */,
|
1A01C6A718F58F7500EFE3A6 /* CCNotificationCenter.h in Headers */,
|
||||||
50ABBEDA1925AB6F00A911A9 /* ZipUtils.h in Headers */,
|
50ABBEDA1925AB6F00A911A9 /* ZipUtils.h in Headers */,
|
||||||
50ABBDC01925AB4100A911A9 /* CCTextureCache.h in Headers */,
|
50ABBDC01925AB4100A911A9 /* CCTextureCache.h in Headers */,
|
||||||
|
B276EF641988D1D500CD400F /* CCVertexIndexBuffer.h in Headers */,
|
||||||
ED9C6A9718599AD8000A5232 /* CCNodeGrid.h in Headers */,
|
ED9C6A9718599AD8000A5232 /* CCNodeGrid.h in Headers */,
|
||||||
50ABC0201926664800A911A9 /* CCThread.h in Headers */,
|
50ABC0201926664800A911A9 /* CCThread.h in Headers */,
|
||||||
1A01C69318F57BE800EFE3A6 /* CCDouble.h in Headers */,
|
1A01C69318F57BE800EFE3A6 /* CCDouble.h in Headers */,
|
||||||
|
@ -6760,6 +6798,7 @@
|
||||||
1A570065180BC5A10088DEC7 /* CCActionCamera.cpp in Sources */,
|
1A570065180BC5A10088DEC7 /* CCActionCamera.cpp in Sources */,
|
||||||
50ABBEAB1925AB6F00A911A9 /* ccTypes.cpp in Sources */,
|
50ABBEAB1925AB6F00A911A9 /* ccTypes.cpp in Sources */,
|
||||||
1A570069180BC5A10088DEC7 /* CCActionCatmullRom.cpp in Sources */,
|
1A570069180BC5A10088DEC7 /* CCActionCatmullRom.cpp in Sources */,
|
||||||
|
B257B44E1989D5E800D9A687 /* CCPrimitive.cpp in Sources */,
|
||||||
1A57006D180BC5A10088DEC7 /* CCActionEase.cpp in Sources */,
|
1A57006D180BC5A10088DEC7 /* CCActionEase.cpp in Sources */,
|
||||||
1A570071180BC5A10088DEC7 /* CCActionGrid.cpp in Sources */,
|
1A570071180BC5A10088DEC7 /* CCActionGrid.cpp in Sources */,
|
||||||
B37510761823AC9F00B3BA6A /* CCPhysicsJointInfo_chipmunk.cpp in Sources */,
|
B37510761823AC9F00B3BA6A /* CCPhysicsJointInfo_chipmunk.cpp in Sources */,
|
||||||
|
@ -6778,6 +6817,7 @@
|
||||||
3E9E80E9198639EF00FA95D0 /* CCAttachNode.cpp in Sources */,
|
3E9E80E9198639EF00FA95D0 /* CCAttachNode.cpp in Sources */,
|
||||||
1A570098180BC5C10088DEC7 /* CCAtlasNode.cpp in Sources */,
|
1A570098180BC5C10088DEC7 /* CCAtlasNode.cpp in Sources */,
|
||||||
1A57009E180BC5D20088DEC7 /* CCNode.cpp in Sources */,
|
1A57009E180BC5D20088DEC7 /* CCNode.cpp in Sources */,
|
||||||
|
B257B460198A353E00D9A687 /* CCPrimitiveCommand.cpp in Sources */,
|
||||||
50ABBE651925AB6F00A911A9 /* CCEventListenerCustom.cpp in Sources */,
|
50ABBE651925AB6F00A911A9 /* CCEventListenerCustom.cpp in Sources */,
|
||||||
B37510781823AC9F00B3BA6A /* CCPhysicsShapeInfo_chipmunk.cpp in Sources */,
|
B37510781823AC9F00B3BA6A /* CCPhysicsShapeInfo_chipmunk.cpp in Sources */,
|
||||||
50ABBE391925AB6F00A911A9 /* CCData.cpp in Sources */,
|
50ABBE391925AB6F00A911A9 /* CCData.cpp in Sources */,
|
||||||
|
@ -6822,6 +6862,7 @@
|
||||||
1A570210180BCBF40088DEC7 /* CCProgressTimer.cpp in Sources */,
|
1A570210180BCBF40088DEC7 /* CCProgressTimer.cpp in Sources */,
|
||||||
50ABBDB51925AB4100A911A9 /* CCTexture2D.cpp in Sources */,
|
50ABBDB51925AB4100A911A9 /* CCTexture2D.cpp in Sources */,
|
||||||
1A570214180BCBF40088DEC7 /* CCRenderTexture.cpp in Sources */,
|
1A570214180BCBF40088DEC7 /* CCRenderTexture.cpp in Sources */,
|
||||||
|
B276EF651988D1D500CD400F /* CCVertexIndexBuffer.cpp in Sources */,
|
||||||
50ABBE411925AB6F00A911A9 /* CCDirector.cpp in Sources */,
|
50ABBE411925AB6F00A911A9 /* CCDirector.cpp in Sources */,
|
||||||
1A570221180BCC1A0088DEC7 /* CCParticleBatchNode.cpp in Sources */,
|
1A570221180BCC1A0088DEC7 /* CCParticleBatchNode.cpp in Sources */,
|
||||||
1A570225180BCC1A0088DEC7 /* CCParticleExamples.cpp in Sources */,
|
1A570225180BCC1A0088DEC7 /* CCParticleExamples.cpp in Sources */,
|
||||||
|
@ -6876,6 +6917,7 @@
|
||||||
50ABBD481925AB0000A911A9 /* Mat4.cpp in Sources */,
|
50ABBD481925AB0000A911A9 /* Mat4.cpp in Sources */,
|
||||||
50ABBD8F1925AB4100A911A9 /* CCGLProgramCache.cpp in Sources */,
|
50ABBD8F1925AB4100A911A9 /* CCGLProgramCache.cpp in Sources */,
|
||||||
50ABBD441925AB0000A911A9 /* CCVertex.cpp in Sources */,
|
50ABBD441925AB0000A911A9 /* CCVertex.cpp in Sources */,
|
||||||
|
B276EF611988D1D500CD400F /* CCVertexIndexData.cpp in Sources */,
|
||||||
503DD8F71926B0DB00CD74DD /* CCIMEDispatcher.cpp in Sources */,
|
503DD8F71926B0DB00CD74DD /* CCIMEDispatcher.cpp in Sources */,
|
||||||
50ABBE751925AB6F00A911A9 /* CCEventListenerTouch.cpp in Sources */,
|
50ABBE751925AB6F00A911A9 /* CCEventListenerTouch.cpp in Sources */,
|
||||||
50ABBE511925AB6F00A911A9 /* CCEventDispatcher.cpp in Sources */,
|
50ABBE511925AB6F00A911A9 /* CCEventDispatcher.cpp in Sources */,
|
||||||
|
@ -7065,20 +7107,24 @@
|
||||||
1A01C6A518F58F7500EFE3A6 /* CCNotificationCenter.cpp in Sources */,
|
1A01C6A518F58F7500EFE3A6 /* CCNotificationCenter.cpp in Sources */,
|
||||||
ED9C6A9518599AD8000A5232 /* CCNodeGrid.cpp in Sources */,
|
ED9C6A9518599AD8000A5232 /* CCNodeGrid.cpp in Sources */,
|
||||||
1A01C68F18F57BE800EFE3A6 /* CCDictionary.cpp in Sources */,
|
1A01C68F18F57BE800EFE3A6 /* CCDictionary.cpp in Sources */,
|
||||||
|
B276EF621988D1D500CD400F /* CCVertexIndexData.cpp in Sources */,
|
||||||
50ABBE561925AB6F00A911A9 /* CCEventFocus.cpp in Sources */,
|
50ABBE561925AB6F00A911A9 /* CCEventFocus.cpp in Sources */,
|
||||||
503DD8E11926736A00CD74DD /* CCApplication.mm in Sources */,
|
503DD8E11926736A00CD74DD /* CCApplication.mm in Sources */,
|
||||||
50ABC01A1926664800A911A9 /* CCSAXParser.cpp in Sources */,
|
50ABC01A1926664800A911A9 /* CCSAXParser.cpp in Sources */,
|
||||||
B2CC507C19776DD10041958E /* CCPhysicsJoint.cpp in Sources */,
|
B2CC507C19776DD10041958E /* CCPhysicsJoint.cpp in Sources */,
|
||||||
|
B2165EEA19921124000BE3E6 /* CCPrimitiveCommand.cpp in Sources */,
|
||||||
503DD8EE1926736A00CD74DD /* CCImage.mm in Sources */,
|
503DD8EE1926736A00CD74DD /* CCImage.mm in Sources */,
|
||||||
3EA47871195478E00068D9D1 /* CCBundleReader.cpp in Sources */,
|
3EA47871195478E00068D9D1 /* CCBundleReader.cpp in Sources */,
|
||||||
B37510811823ACA100B3BA6A /* CCPhysicsJointInfo_chipmunk.cpp in Sources */,
|
B37510811823ACA100B3BA6A /* CCPhysicsJointInfo_chipmunk.cpp in Sources */,
|
||||||
46A170FC1807CECB005B8026 /* CCPhysicsBody.cpp in Sources */,
|
46A170FC1807CECB005B8026 /* CCPhysicsBody.cpp in Sources */,
|
||||||
50ABBD941925AB4100A911A9 /* CCGLProgramState.cpp in Sources */,
|
50ABBD941925AB4100A911A9 /* CCGLProgramState.cpp in Sources */,
|
||||||
|
B257B44F1989D5E800D9A687 /* CCPrimitive.cpp in Sources */,
|
||||||
50ABBE281925AB6F00A911A9 /* CCAutoreleasePool.cpp in Sources */,
|
50ABBE281925AB6F00A911A9 /* CCAutoreleasePool.cpp in Sources */,
|
||||||
46A170FE1807CECB005B8026 /* CCPhysicsContact.cpp in Sources */,
|
46A170FE1807CECB005B8026 /* CCPhysicsContact.cpp in Sources */,
|
||||||
1A570062180BC5A10088DEC7 /* CCAction.cpp in Sources */,
|
1A570062180BC5A10088DEC7 /* CCAction.cpp in Sources */,
|
||||||
1A570066180BC5A10088DEC7 /* CCActionCamera.cpp in Sources */,
|
1A570066180BC5A10088DEC7 /* CCActionCamera.cpp in Sources */,
|
||||||
3E9E80F2198639EF00FA95D0 /* CCSubMeshState.cpp in Sources */,
|
3E9E80F2198639EF00FA95D0 /* CCSubMeshState.cpp in Sources */,
|
||||||
|
B276EF661988D1D500CD400F /* CCVertexIndexBuffer.cpp in Sources */,
|
||||||
1A57006A180BC5A10088DEC7 /* CCActionCatmullRom.cpp in Sources */,
|
1A57006A180BC5A10088DEC7 /* CCActionCatmullRom.cpp in Sources */,
|
||||||
1A57006E180BC5A10088DEC7 /* CCActionEase.cpp in Sources */,
|
1A57006E180BC5A10088DEC7 /* CCActionEase.cpp in Sources */,
|
||||||
50ABBD8C1925AB4100A911A9 /* CCGLProgram.cpp in Sources */,
|
50ABBD8C1925AB4100A911A9 /* CCGLProgram.cpp in Sources */,
|
||||||
|
|
|
@ -121,8 +121,10 @@ TMXLayer::TMXLayer()
|
||||||
, _useAutomaticVertexZ(false)
|
, _useAutomaticVertexZ(false)
|
||||||
, _dirty(true)
|
, _dirty(true)
|
||||||
, _quadsDirty(true)
|
, _quadsDirty(true)
|
||||||
|
, _vertexBuffer(nullptr)
|
||||||
|
, _vData(nullptr)
|
||||||
|
, _indexBuffer(nullptr)
|
||||||
{
|
{
|
||||||
_buffersVBO[0] = _buffersVBO[1] = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TMXLayer::~TMXLayer()
|
TMXLayer::~TMXLayer()
|
||||||
|
@ -130,15 +132,10 @@ TMXLayer::~TMXLayer()
|
||||||
CC_SAFE_RELEASE(_tileSet);
|
CC_SAFE_RELEASE(_tileSet);
|
||||||
CC_SAFE_RELEASE(_texture);
|
CC_SAFE_RELEASE(_texture);
|
||||||
CC_SAFE_DELETE_ARRAY(_tiles);
|
CC_SAFE_DELETE_ARRAY(_tiles);
|
||||||
if(glIsBuffer(_buffersVBO[0]))
|
CC_SAFE_RELEASE(_vData);
|
||||||
{
|
CC_SAFE_RELEASE(_vertexBuffer);
|
||||||
glDeleteBuffers(1, &_buffersVBO[0]);
|
CC_SAFE_RELEASE(_indexBuffer);
|
||||||
}
|
|
||||||
|
|
||||||
if(glIsBuffer(_buffersVBO[1]))
|
|
||||||
{
|
|
||||||
glDeleteBuffers(1, &_buffersVBO[1]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TMXLayer::draw(Renderer *renderer, const Mat4& transform, uint32_t flags)
|
void TMXLayer::draw(Renderer *renderer, const Mat4& transform, uint32_t flags)
|
||||||
|
@ -156,43 +153,37 @@ void TMXLayer::draw(Renderer *renderer, const Mat4& transform, uint32_t flags)
|
||||||
|
|
||||||
updateTiles(rect);
|
updateTiles(rect);
|
||||||
updateIndexBuffer();
|
updateIndexBuffer();
|
||||||
|
updatePrimitives();
|
||||||
_dirty = false;
|
_dirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_renderCommands.size() < _indicesVertexZNumber.size())
|
if(_renderCommands.size() < _primitives.size())
|
||||||
{
|
{
|
||||||
_renderCommands.resize(_indicesVertexZNumber.size());
|
_renderCommands.resize(_primitives.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for(const auto& iter : _indicesVertexZNumber)
|
for(const auto& iter : _primitives)
|
||||||
{
|
{
|
||||||
auto& cmd = _renderCommands[index++];
|
if(iter.second->getCount() > 0)
|
||||||
|
{
|
||||||
cmd.init(iter.first);
|
auto& cmd = _renderCommands[index++];
|
||||||
cmd.func = CC_CALLBACK_0(TMXLayer::onDraw, this, _indicesVertexZOffsets[iter.first], iter.second);
|
cmd.init(iter.first, _texture->getName(), getGLProgramState(), BlendFunc::ALPHA_NON_PREMULTIPLIED, iter.second, _modelViewTransform);
|
||||||
renderer->addCommand(&cmd);
|
renderer->addCommand(&cmd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TMXLayer::onDraw(int offset, int count)
|
void TMXLayer::onDraw(Primitive *primitive)
|
||||||
{
|
{
|
||||||
GL::bindTexture2D(_texture->getName());
|
GL::bindTexture2D(_texture->getName());
|
||||||
getGLProgramState()->apply(_modelViewTransform);
|
getGLProgramState()->apply(_modelViewTransform);
|
||||||
|
|
||||||
GL::bindVAO(0);
|
GL::bindVAO(0);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]);
|
primitive->draw();
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]);
|
|
||||||
|
|
||||||
GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
|
|
||||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, sizeof(V3F_C4B_T2F), (GLvoid*)0);
|
|
||||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V3F_C4B_T2F), (GLvoid*)offsetof(V3F_C4B_T2F, colors));
|
|
||||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, sizeof(V3F_C4B_T2F), (GLvoid*)offsetof(V3F_C4B_T2F, texCoords));
|
|
||||||
glDrawElements(GL_TRIANGLES, (GLsizei)count * 6, GL_UNSIGNED_INT, (GLvoid*)(offset * 6 * sizeof(int)));
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||||
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, count * 4);
|
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, primitive->getCount() * 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TMXLayer::updateTiles(const Rect& culledRect)
|
void TMXLayer::updateTiles(const Rect& culledRect)
|
||||||
|
@ -291,25 +282,32 @@ void TMXLayer::updateTiles(const Rect& culledRect)
|
||||||
void TMXLayer::updateVertexBuffer()
|
void TMXLayer::updateVertexBuffer()
|
||||||
{
|
{
|
||||||
GL::bindVAO(0);
|
GL::bindVAO(0);
|
||||||
if(!glIsBuffer(_buffersVBO[0]))
|
if(nullptr == _vData)
|
||||||
{
|
{
|
||||||
glGenBuffers(1, &_buffersVBO[0]);
|
_vertexBuffer = VertexBuffer::create(sizeof(V3F_C4B_T2F), (int)_totalQuads.size() * 4);
|
||||||
|
_vData = VertexData::create();
|
||||||
|
_vData->setStream(_vertexBuffer, VertexStreamAttribute(0, GLProgram::VERTEX_ATTRIB_POSITION, GL_FLOAT, 3));
|
||||||
|
_vData->setStream(_vertexBuffer, VertexStreamAttribute(offsetof(V3F_C4B_T2F, colors), GLProgram::VERTEX_ATTRIB_COLOR, GL_UNSIGNED_BYTE, 4, true));
|
||||||
|
_vData->setStream(_vertexBuffer, VertexStreamAttribute(offsetof(V3F_C4B_T2F, texCoords), GLProgram::VERTEX_ATTRIB_TEX_COORD, GL_FLOAT, 2));
|
||||||
|
CC_SAFE_RETAIN(_vData);
|
||||||
|
CC_SAFE_RETAIN(_vertexBuffer);
|
||||||
|
}
|
||||||
|
if(_vertexBuffer)
|
||||||
|
{
|
||||||
|
_vertexBuffer->updateVertices((void*)&_totalQuads[0], (int)_totalQuads.size() * 4, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]);
|
|
||||||
glBufferData(GL_ARRAY_BUFFER, sizeof(V3F_C4B_T2F_Quad) * _totalQuads.size(), (GLvoid*)&_totalQuads[0], GL_STATIC_DRAW);
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TMXLayer::updateIndexBuffer()
|
void TMXLayer::updateIndexBuffer()
|
||||||
{
|
{
|
||||||
if(!glIsBuffer(_buffersVBO[1]))
|
if(nullptr == _indexBuffer)
|
||||||
{
|
{
|
||||||
glGenBuffers(1, &_buffersVBO[1]);
|
_indexBuffer = IndexBuffer::create(IndexBuffer::IndexType::INDEX_TYPE_UINT_32, (int)_indices.size());
|
||||||
|
CC_SAFE_RETAIN(_indexBuffer);
|
||||||
}
|
}
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]);
|
_indexBuffer->updateIndices(&_indices[0], (int)_indices.size(), 0);
|
||||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(int) * _indices.size(), &_indices[0], GL_DYNAMIC_DRAW);
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FastTMXLayer - setup Tiles
|
// FastTMXLayer - setup Tiles
|
||||||
|
@ -405,6 +403,29 @@ Mat4 TMXLayer::tileToNodeTransform()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TMXLayer::updatePrimitives()
|
||||||
|
{
|
||||||
|
for(const auto& iter : _indicesVertexZNumber)
|
||||||
|
{
|
||||||
|
int start = _indicesVertexZOffsets.at(iter.first);
|
||||||
|
|
||||||
|
auto primitiveIter= _primitives.find(iter.first);
|
||||||
|
if(primitiveIter == _primitives.end())
|
||||||
|
{
|
||||||
|
auto primitive = Primitive::create(_vData, _indexBuffer, GL_TRIANGLES);
|
||||||
|
primitive->setCount(iter.second * 6);
|
||||||
|
primitive->setStart(start * 6);
|
||||||
|
|
||||||
|
_primitives.insert(iter.first, primitive);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
primitiveIter->second->setCount(iter.second * 6);
|
||||||
|
primitiveIter->second->setStart(start * 6);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TMXLayer::updateTotalQuads()
|
void TMXLayer::updateTotalQuads()
|
||||||
{
|
{
|
||||||
if(_quadsDirty)
|
if(_quadsDirty)
|
||||||
|
|
|
@ -32,6 +32,7 @@ THE SOFTWARE.
|
||||||
#include "CCNode.h"
|
#include "CCNode.h"
|
||||||
#include "renderer/CCCustomCommand.h"
|
#include "renderer/CCCustomCommand.h"
|
||||||
#include "renderer/CCQuadCommand.h"
|
#include "renderer/CCQuadCommand.h"
|
||||||
|
#include "renderer/CCPrimitiveCommand.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
@ -199,12 +200,12 @@ protected:
|
||||||
//
|
//
|
||||||
void updateTotalQuads();
|
void updateTotalQuads();
|
||||||
|
|
||||||
void onDraw(int offset, int count);
|
void onDraw(Primitive* primitive);
|
||||||
|
|
||||||
inline int getTileIndexByPos(int x, int y) const { return x + y * (int) _layerSize.width; }
|
inline int getTileIndexByPos(int x, int y) const { return x + y * (int) _layerSize.width; }
|
||||||
|
|
||||||
void updateVertexBuffer();
|
void updateVertexBuffer();
|
||||||
void updateIndexBuffer();
|
void updateIndexBuffer();
|
||||||
|
void updatePrimitives();
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
//! name of the layer
|
//! name of the layer
|
||||||
|
@ -228,7 +229,7 @@ protected:
|
||||||
/** container for sprite children. map<index, pair<sprite, gid> > */
|
/** container for sprite children. map<index, pair<sprite, gid> > */
|
||||||
std::map<int, std::pair<Sprite*, int> > _spriteContainer;
|
std::map<int, std::pair<Sprite*, int> > _spriteContainer;
|
||||||
|
|
||||||
GLuint _buffersVBO[2]; //0: vertex, 1: indices
|
//GLuint _buffersVBO; //0: vertex, 1: indices
|
||||||
|
|
||||||
Size _screenGridSize;
|
Size _screenGridSize;
|
||||||
Rect _screenGridRect;
|
Rect _screenGridRect;
|
||||||
|
@ -246,9 +247,17 @@ protected:
|
||||||
std::vector<int> _indices;
|
std::vector<int> _indices;
|
||||||
std::map<int/*vertexZ*/, int/*offset to _indices by quads*/> _indicesVertexZOffsets;
|
std::map<int/*vertexZ*/, int/*offset to _indices by quads*/> _indicesVertexZOffsets;
|
||||||
std::unordered_map<int/*vertexZ*/, int/*number to quads*/> _indicesVertexZNumber;
|
std::unordered_map<int/*vertexZ*/, int/*number to quads*/> _indicesVertexZNumber;
|
||||||
std::vector<CustomCommand> _renderCommands;
|
std::vector<PrimitiveCommand> _renderCommands;
|
||||||
bool _dirty;
|
bool _dirty;
|
||||||
|
|
||||||
|
VertexBuffer* _vertexBuffer;
|
||||||
|
|
||||||
|
VertexData* _vData;
|
||||||
|
|
||||||
|
IndexBuffer* _indexBuffer;
|
||||||
|
|
||||||
|
Map<int , Primitive*> _primitives;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** Possible orientations of the TMX map */
|
/** Possible orientations of the TMX map */
|
||||||
static const int FAST_TMX_ORIENTATION_ORTHO;
|
static const int FAST_TMX_ORIENTATION_ORTHO;
|
||||||
|
|
|
@ -287,6 +287,8 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou
|
||||||
<ClCompile Include="..\renderer\ccGLStateCache.cpp" />
|
<ClCompile Include="..\renderer\ccGLStateCache.cpp" />
|
||||||
<ClCompile Include="..\renderer\CCGroupCommand.cpp" />
|
<ClCompile Include="..\renderer\CCGroupCommand.cpp" />
|
||||||
<ClCompile Include="..\renderer\CCMeshCommand.cpp" />
|
<ClCompile Include="..\renderer\CCMeshCommand.cpp" />
|
||||||
|
<ClCompile Include="..\renderer\CCPrimitive.cpp" />
|
||||||
|
<ClCompile Include="..\renderer\CCPrimitiveCommand.cpp" />
|
||||||
<ClCompile Include="..\renderer\CCQuadCommand.cpp" />
|
<ClCompile Include="..\renderer\CCQuadCommand.cpp" />
|
||||||
<ClCompile Include="..\renderer\CCRenderCommand.cpp" />
|
<ClCompile Include="..\renderer\CCRenderCommand.cpp" />
|
||||||
<ClCompile Include="..\renderer\CCRenderer.cpp" />
|
<ClCompile Include="..\renderer\CCRenderer.cpp" />
|
||||||
|
@ -294,6 +296,8 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou
|
||||||
<ClCompile Include="..\renderer\CCTexture2D.cpp" />
|
<ClCompile Include="..\renderer\CCTexture2D.cpp" />
|
||||||
<ClCompile Include="..\renderer\CCTextureAtlas.cpp" />
|
<ClCompile Include="..\renderer\CCTextureAtlas.cpp" />
|
||||||
<ClCompile Include="..\renderer\CCTextureCache.cpp" />
|
<ClCompile Include="..\renderer\CCTextureCache.cpp" />
|
||||||
|
<ClCompile Include="..\renderer\CCVertexIndexBuffer.cpp" />
|
||||||
|
<ClCompile Include="..\renderer\CCVertexIndexData.cpp" />
|
||||||
<ClCompile Include="..\storage\local-storage\LocalStorage.cpp" />
|
<ClCompile Include="..\storage\local-storage\LocalStorage.cpp" />
|
||||||
<ClCompile Include="CCAction.cpp" />
|
<ClCompile Include="CCAction.cpp" />
|
||||||
<ClCompile Include="CCActionCamera.cpp" />
|
<ClCompile Include="CCActionCamera.cpp" />
|
||||||
|
@ -499,6 +503,8 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou
|
||||||
<ClInclude Include="..\renderer\ccGLStateCache.h" />
|
<ClInclude Include="..\renderer\ccGLStateCache.h" />
|
||||||
<ClInclude Include="..\renderer\CCGroupCommand.h" />
|
<ClInclude Include="..\renderer\CCGroupCommand.h" />
|
||||||
<ClInclude Include="..\renderer\CCMeshCommand.h" />
|
<ClInclude Include="..\renderer\CCMeshCommand.h" />
|
||||||
|
<ClInclude Include="..\renderer\CCPrimitive.h" />
|
||||||
|
<ClInclude Include="..\renderer\CCPrimitiveCommand.h" />
|
||||||
<ClInclude Include="..\renderer\CCQuadCommand.h" />
|
<ClInclude Include="..\renderer\CCQuadCommand.h" />
|
||||||
<ClInclude Include="..\renderer\CCRenderCommand.h" />
|
<ClInclude Include="..\renderer\CCRenderCommand.h" />
|
||||||
<ClInclude Include="..\renderer\CCRenderCommandPool.h" />
|
<ClInclude Include="..\renderer\CCRenderCommandPool.h" />
|
||||||
|
@ -507,6 +513,8 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou
|
||||||
<ClInclude Include="..\renderer\CCTexture2D.h" />
|
<ClInclude Include="..\renderer\CCTexture2D.h" />
|
||||||
<ClInclude Include="..\renderer\CCTextureAtlas.h" />
|
<ClInclude Include="..\renderer\CCTextureAtlas.h" />
|
||||||
<ClInclude Include="..\renderer\CCTextureCache.h" />
|
<ClInclude Include="..\renderer\CCTextureCache.h" />
|
||||||
|
<ClInclude Include="..\renderer\CCVertexIndexBuffer.h" />
|
||||||
|
<ClInclude Include="..\renderer\CCVertexIndexData.h" />
|
||||||
<ClInclude Include="..\storage\local-storage\LocalStorage.h" />
|
<ClInclude Include="..\storage\local-storage\LocalStorage.h" />
|
||||||
<ClInclude Include="CCAction.h" />
|
<ClInclude Include="CCAction.h" />
|
||||||
<ClInclude Include="CCActionCamera.h" />
|
<ClInclude Include="CCActionCamera.h" />
|
||||||
|
|
|
@ -613,6 +613,18 @@
|
||||||
<ClCompile Include="..\base\CCCamera.cpp">
|
<ClCompile Include="..\base\CCCamera.cpp">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\renderer\CCPrimitive.cpp">
|
||||||
|
<Filter>renderer</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\renderer\CCPrimitiveCommand.cpp">
|
||||||
|
<Filter>renderer</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\renderer\CCVertexIndexBuffer.cpp">
|
||||||
|
<Filter>renderer</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\renderer\CCVertexIndexData.cpp">
|
||||||
|
<Filter>renderer</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\physics\CCPhysicsBody.h">
|
<ClInclude Include="..\physics\CCPhysicsBody.h">
|
||||||
|
@ -1246,6 +1258,18 @@
|
||||||
<ClInclude Include="..\base\CCCamera.h">
|
<ClInclude Include="..\base\CCCamera.h">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\renderer\CCPrimitive.h">
|
||||||
|
<Filter>renderer</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\renderer\CCPrimitiveCommand.h">
|
||||||
|
<Filter>renderer</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\renderer\CCVertexIndexBuffer.h">
|
||||||
|
<Filter>renderer</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\renderer\CCVertexIndexData.h">
|
||||||
|
<Filter>renderer</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="..\math\Mat4.inl">
|
<None Include="..\math\Mat4.inl">
|
||||||
|
|
|
@ -167,6 +167,10 @@ renderer/CCTextureAtlas.cpp \
|
||||||
renderer/CCTextureCache.cpp \
|
renderer/CCTextureCache.cpp \
|
||||||
renderer/ccGLStateCache.cpp \
|
renderer/ccGLStateCache.cpp \
|
||||||
renderer/ccShaders.cpp \
|
renderer/ccShaders.cpp \
|
||||||
|
renderer/CCVertexIndexBuffer.cpp \
|
||||||
|
renderer/CCVertexIndexData.cpp \
|
||||||
|
renderer/CCPrimitive.cpp \
|
||||||
|
renderer/CCPrimitiveCommand.cpp \
|
||||||
deprecated/CCArray.cpp \
|
deprecated/CCArray.cpp \
|
||||||
deprecated/CCSet.cpp \
|
deprecated/CCSet.cpp \
|
||||||
deprecated/CCString.cpp \
|
deprecated/CCString.cpp \
|
||||||
|
|
|
@ -0,0 +1,108 @@
|
||||||
|
/****************************************************************************
|
||||||
|
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
||||||
|
|
||||||
|
http://www.cocos2d-x.org
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "renderer/CCPrimitive.h"
|
||||||
|
|
||||||
|
NS_CC_BEGIN
|
||||||
|
|
||||||
|
Primitive* Primitive::create(VertexData* verts, IndexBuffer* indices, int type)
|
||||||
|
{
|
||||||
|
auto result = new (std::nothrow) Primitive();
|
||||||
|
if( result && result->init(verts, indices, type))
|
||||||
|
{
|
||||||
|
result->autorelease();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
CC_SAFE_DELETE(result);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
const VertexData* Primitive::getVertexData() const
|
||||||
|
{
|
||||||
|
return _verts;
|
||||||
|
}
|
||||||
|
|
||||||
|
const IndexBuffer* Primitive::getIndexData() const
|
||||||
|
{
|
||||||
|
return _indices;
|
||||||
|
}
|
||||||
|
|
||||||
|
Primitive::Primitive()
|
||||||
|
: _verts(nullptr)
|
||||||
|
, _indices(nullptr)
|
||||||
|
, _type(GL_POINTS)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Primitive::~Primitive()
|
||||||
|
{
|
||||||
|
CC_SAFE_RELEASE_NULL(_verts);
|
||||||
|
CC_SAFE_RELEASE_NULL(_indices);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Primitive::init(VertexData* verts, IndexBuffer* indices, int type)
|
||||||
|
{
|
||||||
|
if( nullptr == verts ) return false;
|
||||||
|
if(verts != _verts)
|
||||||
|
{
|
||||||
|
CC_SAFE_RELEASE(_verts);
|
||||||
|
CC_SAFE_RETAIN(verts);
|
||||||
|
_verts = verts;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(indices != _indices)
|
||||||
|
{
|
||||||
|
CC_SAFE_RETAIN(indices);
|
||||||
|
CC_SAFE_RELEASE(_indices);
|
||||||
|
_indices = indices;
|
||||||
|
}
|
||||||
|
|
||||||
|
_type = type;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Primitive::draw()
|
||||||
|
{
|
||||||
|
if(_verts && _indices)
|
||||||
|
{
|
||||||
|
_verts->use();
|
||||||
|
if(_indices!= nullptr)
|
||||||
|
{
|
||||||
|
GLenum type = (_indices->getType() == IndexBuffer::IndexType::INDEX_TYPE_SHORT_16) ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT;
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _indices->getVBO());
|
||||||
|
glDrawElements((GLenum)_type, _count, type, (GLvoid*)(_start * _indices->getSizePerIndex()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
glDrawArrays((GLenum)_type, _count, _start);
|
||||||
|
}
|
||||||
|
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_CC_END
|
|
@ -0,0 +1,67 @@
|
||||||
|
/****************************************************************************
|
||||||
|
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
||||||
|
|
||||||
|
http://www.cocos2d-x.org
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __CC_PRIMITIVE_H__
|
||||||
|
#define __CC_PRIMITIVE_H__
|
||||||
|
|
||||||
|
#include "renderer/CCVertexIndexData.h"
|
||||||
|
|
||||||
|
NS_CC_BEGIN
|
||||||
|
|
||||||
|
class CC_DLL Primitive : public Ref
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static Primitive* create(VertexData* verts, IndexBuffer* indices, int type);
|
||||||
|
|
||||||
|
const VertexData* getVertexData() const;
|
||||||
|
|
||||||
|
const IndexBuffer* getIndexData() const;
|
||||||
|
|
||||||
|
int getType() const { return _type; }
|
||||||
|
|
||||||
|
//called by rendering framework
|
||||||
|
void draw();
|
||||||
|
|
||||||
|
int getStart() const { return _start; }
|
||||||
|
int getCount() const { return _count; }
|
||||||
|
void setStart(int start) { _start = start; }
|
||||||
|
void setCount(int count) { _count = count; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Primitive();
|
||||||
|
virtual ~Primitive();
|
||||||
|
|
||||||
|
bool init(VertexData* verts, IndexBuffer* indices, int type);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
VertexData* _verts;
|
||||||
|
IndexBuffer* _indices;
|
||||||
|
int _start;
|
||||||
|
int _count;
|
||||||
|
int _type;
|
||||||
|
};
|
||||||
|
|
||||||
|
NS_CC_END
|
||||||
|
|
||||||
|
#endif //__CC_PRIMITIVE_H__
|
|
@ -0,0 +1,82 @@
|
||||||
|
/****************************************************************************
|
||||||
|
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
||||||
|
|
||||||
|
http://www.cocos2d-x.org
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "renderer/CCPrimitiveCommand.h"
|
||||||
|
|
||||||
|
#include "renderer/ccGLStateCache.h"
|
||||||
|
#include "renderer/CCGLProgram.h"
|
||||||
|
#include "renderer/CCGLProgramState.h"
|
||||||
|
#include "xxhash.h"
|
||||||
|
|
||||||
|
NS_CC_BEGIN
|
||||||
|
|
||||||
|
PrimitiveCommand::PrimitiveCommand()
|
||||||
|
: _materialID(0)
|
||||||
|
, _textureID(0)
|
||||||
|
, _glProgramState(nullptr)
|
||||||
|
, _blendType(BlendFunc::DISABLE)
|
||||||
|
, _primitive(nullptr)
|
||||||
|
{
|
||||||
|
_type = RenderCommand::Type::PRIMITIVE_COMMAND;
|
||||||
|
}
|
||||||
|
|
||||||
|
PrimitiveCommand::~PrimitiveCommand()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrimitiveCommand::init(float globalOrder, GLuint textureID, GLProgramState* glProgramState, BlendFunc blendType, Primitive* primitive,const Mat4& mv)
|
||||||
|
{
|
||||||
|
CCASSERT(glProgramState, "Invalid GLProgramState");
|
||||||
|
CCASSERT(glProgramState->getVertexAttribsFlags() == 0, "No custom attributes are supported in PrimitiveCommand");
|
||||||
|
CCASSERT(primitive != nullptr, "Could not render null primitive");
|
||||||
|
|
||||||
|
_globalOrder = globalOrder;
|
||||||
|
|
||||||
|
_primitive = primitive;
|
||||||
|
|
||||||
|
_mv = mv;
|
||||||
|
|
||||||
|
if( _textureID != textureID || _blendType.src != blendType.src || _blendType.dst != blendType.dst || _glProgramState != glProgramState) {
|
||||||
|
|
||||||
|
_textureID = textureID;
|
||||||
|
_blendType = blendType;
|
||||||
|
_glProgramState = glProgramState;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrimitiveCommand::execute() const
|
||||||
|
{
|
||||||
|
//Set texture
|
||||||
|
GL::bindTexture2D(_textureID);
|
||||||
|
|
||||||
|
//set blend mode
|
||||||
|
GL::blendFunc(_blendType.src, _blendType.dst);
|
||||||
|
|
||||||
|
_glProgramState->apply(_mv);
|
||||||
|
|
||||||
|
_primitive->draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_CC_END
|
|
@ -0,0 +1,60 @@
|
||||||
|
/****************************************************************************
|
||||||
|
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
||||||
|
|
||||||
|
http://www.cocos2d-x.org
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef _CC_PRIMITIVE_COMMAND_H__
|
||||||
|
#define _CC_PRIMITIVE_COMMAND_H__
|
||||||
|
|
||||||
|
#include "renderer/CCPrimitive.h"
|
||||||
|
#include "renderer/CCRenderCommand.h"
|
||||||
|
|
||||||
|
NS_CC_BEGIN
|
||||||
|
class GLProgramState;
|
||||||
|
class CC_DLL PrimitiveCommand : public RenderCommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PrimitiveCommand();
|
||||||
|
~PrimitiveCommand();
|
||||||
|
|
||||||
|
void init(float globalOrder, GLuint textureID, GLProgramState* glProgramState, BlendFunc blendType, Primitive* primitive,const Mat4& mv);
|
||||||
|
|
||||||
|
inline uint32_t getMaterialID() const { return _materialID; }
|
||||||
|
inline GLuint getTextureID() const { return _textureID; }
|
||||||
|
inline GLProgramState* getGLProgramState() const { return _glProgramState; }
|
||||||
|
inline BlendFunc getBlendType() const { return _blendType; }
|
||||||
|
inline const Mat4& getModelView() const { return _mv; }
|
||||||
|
|
||||||
|
void execute() const;
|
||||||
|
protected:
|
||||||
|
|
||||||
|
uint32_t _materialID;
|
||||||
|
GLuint _textureID;
|
||||||
|
GLProgramState* _glProgramState;
|
||||||
|
BlendFunc _blendType;
|
||||||
|
Primitive* _primitive;
|
||||||
|
Mat4 _mv;
|
||||||
|
};
|
||||||
|
|
||||||
|
NS_CC_END
|
||||||
|
|
||||||
|
#endif //_CC_PRIMITIVE_COMMAND_H__
|
|
@ -49,6 +49,7 @@ public:
|
||||||
BATCH_COMMAND,
|
BATCH_COMMAND,
|
||||||
GROUP_COMMAND,
|
GROUP_COMMAND,
|
||||||
MESH_COMMAND,
|
MESH_COMMAND,
|
||||||
|
PRIMITIVE_COMMAND,
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Get Render Command Id */
|
/** Get Render Command Id */
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "renderer/CCBatchCommand.h"
|
#include "renderer/CCBatchCommand.h"
|
||||||
#include "renderer/CCCustomCommand.h"
|
#include "renderer/CCCustomCommand.h"
|
||||||
#include "renderer/CCGroupCommand.h"
|
#include "renderer/CCGroupCommand.h"
|
||||||
|
#include "renderer/CCPrimitiveCommand.h"
|
||||||
#include "renderer/CCGLProgramCache.h"
|
#include "renderer/CCGLProgramCache.h"
|
||||||
#include "renderer/ccGLStateCache.h"
|
#include "renderer/ccGLStateCache.h"
|
||||||
#include "renderer/CCMeshCommand.h"
|
#include "renderer/CCMeshCommand.h"
|
||||||
|
@ -321,6 +322,12 @@ void Renderer::visitRenderQueue(const RenderQueue& queue)
|
||||||
auto cmd = static_cast<BatchCommand*>(command);
|
auto cmd = static_cast<BatchCommand*>(command);
|
||||||
cmd->execute();
|
cmd->execute();
|
||||||
}
|
}
|
||||||
|
else if(RenderCommand::Type::PRIMITIVE_COMMAND == commandType)
|
||||||
|
{
|
||||||
|
flush();
|
||||||
|
auto cmd = static_cast<PrimitiveCommand*>(command);
|
||||||
|
cmd->execute();
|
||||||
|
}
|
||||||
else if (RenderCommand::Type::MESH_COMMAND == commandType)
|
else if (RenderCommand::Type::MESH_COMMAND == commandType)
|
||||||
{
|
{
|
||||||
flush2D();
|
flush2D();
|
||||||
|
|
|
@ -0,0 +1,314 @@
|
||||||
|
/****************************************************************************
|
||||||
|
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
||||||
|
|
||||||
|
http://www.cocos2d-x.org
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "renderer/CCVertexIndexBuffer.h"
|
||||||
|
#include "base/CCEventType.h"
|
||||||
|
#include "base/CCEventListenerCustom.h"
|
||||||
|
|
||||||
|
NS_CC_BEGIN
|
||||||
|
|
||||||
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||||
|
bool VertexBuffer::_enableShadowCopy = true;
|
||||||
|
#else
|
||||||
|
bool VertexBuffer::_enableShadowCopy = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||||
|
bool IndexBuffer::_enableShadowCopy = true;
|
||||||
|
#else
|
||||||
|
bool IndexBuffer::_enableShadowCopy = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
VertexBuffer* VertexBuffer::create(int sizePerVertex, int vertexNumber)
|
||||||
|
{
|
||||||
|
auto result = new (std::nothrow) VertexBuffer();
|
||||||
|
if(result && result->init(sizePerVertex, vertexNumber))
|
||||||
|
{
|
||||||
|
result->autorelease();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
CC_SAFE_DELETE(result);
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
VertexBuffer::VertexBuffer()
|
||||||
|
: _vbo(0)
|
||||||
|
, _vertexNumber(0)
|
||||||
|
, _sizePerVertex(0)
|
||||||
|
{
|
||||||
|
|
||||||
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||||
|
Director::getInstance()->getEventDispatcher()->addCustomEventListener(EVENT_COME_TO_BACKGROUND, CC_CALLBACK_1(VertexBuffer::listenToBackground, this));
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
VertexBuffer::~VertexBuffer()
|
||||||
|
{
|
||||||
|
if(glIsBuffer(_vbo))
|
||||||
|
{
|
||||||
|
glDeleteBuffers(1, &_vbo);
|
||||||
|
_vbo = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool VertexBuffer::init(int sizePerVertex, int vertexNumber)
|
||||||
|
{
|
||||||
|
if(0 == sizePerVertex || 0 == vertexNumber)
|
||||||
|
return false;
|
||||||
|
_sizePerVertex = sizePerVertex;
|
||||||
|
_vertexNumber = vertexNumber;
|
||||||
|
|
||||||
|
if(isShadowCopyEnabled())
|
||||||
|
{
|
||||||
|
_shadowCopy.resize(sizePerVertex * _vertexNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
glGenBuffers(1, &_vbo);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
|
||||||
|
glBufferData(GL_ARRAY_BUFFER, getSize(), nullptr, GL_STATIC_DRAW);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int VertexBuffer::getSizePerVertex() const
|
||||||
|
{
|
||||||
|
return _sizePerVertex;
|
||||||
|
}
|
||||||
|
|
||||||
|
int VertexBuffer::getVertexNumber() const
|
||||||
|
{
|
||||||
|
return _vertexNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool VertexBuffer::updateVertices(const void* verts, int count, int begin)
|
||||||
|
{
|
||||||
|
if(count <= 0 || nullptr == verts) return false;
|
||||||
|
|
||||||
|
if(begin < 0)
|
||||||
|
{
|
||||||
|
CCLOGERROR("Update vertices with begin = %d, will set begin to 0", begin);
|
||||||
|
begin = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(count + begin > _vertexNumber)
|
||||||
|
{
|
||||||
|
CCLOGERROR("updated vertices exceed the max size of vertex buffer, will set count to _vertexNumber-begin");
|
||||||
|
count = _vertexNumber - begin;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isShadowCopyEnabled())
|
||||||
|
{
|
||||||
|
memcpy(&_shadowCopy[begin * _sizePerVertex], verts, count * _sizePerVertex);
|
||||||
|
}
|
||||||
|
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
|
||||||
|
glBufferSubData(GL_ARRAY_BUFFER, begin * _sizePerVertex, count * _sizePerVertex, verts);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VertexBuffer::listenToBackground(EventCustom *event)
|
||||||
|
{
|
||||||
|
if(glIsBuffer(_vbo))
|
||||||
|
{
|
||||||
|
glDeleteBuffers(1, &_vbo);
|
||||||
|
_vbo = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GLuint VertexBuffer::getVBO() const
|
||||||
|
{
|
||||||
|
if(0 == _vbo)
|
||||||
|
{
|
||||||
|
recreateVBO();
|
||||||
|
}
|
||||||
|
return _vbo;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VertexBuffer::recreateVBO() const
|
||||||
|
{
|
||||||
|
CCLOG("come to foreground of VertexBuffer");
|
||||||
|
glGenBuffers(1, &_vbo);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
|
||||||
|
const void* buffer = nullptr;
|
||||||
|
if(isShadowCopyEnabled())
|
||||||
|
{
|
||||||
|
buffer = &_shadowCopy[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
glBufferData(GL_ARRAY_BUFFER, _sizePerVertex * _vertexNumber, buffer, GL_STATIC_DRAW);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
|
if(!glIsBuffer(_vbo))
|
||||||
|
{
|
||||||
|
CCLOGERROR("recreate VertexBuffer Error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int VertexBuffer::getSize() const
|
||||||
|
{
|
||||||
|
return _sizePerVertex * _vertexNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
IndexBuffer* IndexBuffer::create(IndexType type, int number)
|
||||||
|
{
|
||||||
|
auto result = new (std::nothrow) IndexBuffer();
|
||||||
|
if(result && result->init(type, number))
|
||||||
|
{
|
||||||
|
result->autorelease();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
CC_SAFE_DELETE(result);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
IndexBuffer::IndexBuffer()
|
||||||
|
: _vbo(0)
|
||||||
|
, _type(IndexType::INDEX_TYPE_SHORT_16)
|
||||||
|
, _indexNumber(0)
|
||||||
|
{
|
||||||
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||||
|
Director::getInstance()->getEventDispatcher()->addCustomEventListener(EVENT_COME_TO_BACKGROUND, CC_CALLBACK_1(IndexBuffer::listenToBackground, this));
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
IndexBuffer::~IndexBuffer()
|
||||||
|
{
|
||||||
|
if(glIsBuffer(_vbo))
|
||||||
|
{
|
||||||
|
glDeleteBuffers(1, &_vbo);
|
||||||
|
_vbo = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IndexBuffer::init(IndexBuffer::IndexType type, int number)
|
||||||
|
{
|
||||||
|
if(number <=0 ) return false;
|
||||||
|
|
||||||
|
_type = type;
|
||||||
|
_indexNumber = number;
|
||||||
|
|
||||||
|
glGenBuffers(1, &_vbo);
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vbo);
|
||||||
|
glBufferData(GL_ELEMENT_ARRAY_BUFFER, getSize(), nullptr, GL_STATIC_DRAW);
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||||
|
|
||||||
|
if(isShadowCopyEnabled())
|
||||||
|
{
|
||||||
|
_shadowCopy.resize(getSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
IndexBuffer::IndexType IndexBuffer::getType() const
|
||||||
|
{
|
||||||
|
return _type;
|
||||||
|
}
|
||||||
|
|
||||||
|
int IndexBuffer::getSizePerIndex() const
|
||||||
|
{
|
||||||
|
return IndexType::INDEX_TYPE_SHORT_16 == _type ? 2 : 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
int IndexBuffer::getIndexNumber() const
|
||||||
|
{
|
||||||
|
return _indexNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IndexBuffer::updateIndices(const void* indices, int count, int begin)
|
||||||
|
{
|
||||||
|
if(count <= 0 || nullptr == indices) return false;
|
||||||
|
|
||||||
|
if(begin < 0)
|
||||||
|
{
|
||||||
|
CCLOGERROR("Update indices with begin = %d, will set begin to 0", begin);
|
||||||
|
begin = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(count + begin > _indexNumber)
|
||||||
|
{
|
||||||
|
CCLOGERROR("updated indices exceed the max size of vertex buffer, will set count to _indexNumber-begin");
|
||||||
|
count = _indexNumber - begin;
|
||||||
|
}
|
||||||
|
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vbo);
|
||||||
|
glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, begin * getSizePerIndex(), count * getSizePerIndex(), indices);
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||||
|
|
||||||
|
if(isShadowCopyEnabled())
|
||||||
|
{
|
||||||
|
memcpy(&_shadowCopy[begin * getSizePerIndex()], indices, count * getSizePerIndex());
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int IndexBuffer::getSize() const
|
||||||
|
{
|
||||||
|
return getSizePerIndex() * _indexNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IndexBuffer::listenToBackground(EventCustom *event)
|
||||||
|
{
|
||||||
|
if(glIsBuffer(_vbo))
|
||||||
|
{
|
||||||
|
glDeleteBuffers(1, &_vbo);
|
||||||
|
_vbo = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GLuint IndexBuffer::getVBO() const
|
||||||
|
{
|
||||||
|
if(0 == _vbo)
|
||||||
|
{
|
||||||
|
recreateVBO();
|
||||||
|
}
|
||||||
|
|
||||||
|
return _vbo;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IndexBuffer::recreateVBO() const
|
||||||
|
{
|
||||||
|
CCLOG("come to foreground of IndexBuffer");
|
||||||
|
glGenBuffers(1, &_vbo);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
|
||||||
|
const void* buffer = nullptr;
|
||||||
|
if(isShadowCopyEnabled())
|
||||||
|
{
|
||||||
|
buffer = &_shadowCopy[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
glBufferData(GL_ARRAY_BUFFER, getSize(), buffer, GL_STATIC_DRAW);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
|
if(!glIsBuffer(_vbo))
|
||||||
|
{
|
||||||
|
CCLOGERROR("recreate IndexBuffer Error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_CC_END
|
|
@ -0,0 +1,117 @@
|
||||||
|
/****************************************************************************
|
||||||
|
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
||||||
|
|
||||||
|
http://www.cocos2d-x.org
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __CC_VERTEX_INDEX_BUFFER_H__
|
||||||
|
#define __CC_VERTEX_INDEX_BUFFER_H__
|
||||||
|
|
||||||
|
#include "base/CCRef.h"
|
||||||
|
#include "base/CCDirector.h"
|
||||||
|
|
||||||
|
NS_CC_BEGIN
|
||||||
|
|
||||||
|
class CC_DLL VertexBuffer : public Ref
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static VertexBuffer* create(int sizePerVertex, int vertexNumber);
|
||||||
|
|
||||||
|
int getSizePerVertex() const;
|
||||||
|
int getVertexNumber() const;
|
||||||
|
bool updateVertices(const void* verts, int count, int begin);
|
||||||
|
|
||||||
|
int getSize() const;
|
||||||
|
|
||||||
|
GLuint getVBO() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
VertexBuffer();
|
||||||
|
virtual ~VertexBuffer();
|
||||||
|
|
||||||
|
bool init(int sizePerVertex, int vertexNumber);
|
||||||
|
protected:
|
||||||
|
//event listener for foreground and background
|
||||||
|
void listenToBackground(EventCustom *event);
|
||||||
|
void recreateVBO() const;
|
||||||
|
protected:
|
||||||
|
mutable GLuint _vbo;
|
||||||
|
int _sizePerVertex;
|
||||||
|
int _vertexNumber;
|
||||||
|
//buffer used for shadow copy
|
||||||
|
std::vector<unsigned char> _shadowCopy;
|
||||||
|
protected:
|
||||||
|
static bool _enableShadowCopy;
|
||||||
|
public:
|
||||||
|
static bool isShadowCopyEnabled() { return _enableShadowCopy; }
|
||||||
|
static void enableShadowCopy(bool enabled) { _enableShadowCopy = enabled; }
|
||||||
|
};
|
||||||
|
|
||||||
|
class CC_DLL IndexBuffer : public Ref
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum class IndexType
|
||||||
|
{
|
||||||
|
INDEX_TYPE_SHORT_16,
|
||||||
|
INDEX_TYPE_UINT_32
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
static IndexBuffer* create(IndexType type, int number);
|
||||||
|
|
||||||
|
IndexType getType() const;
|
||||||
|
int getSizePerIndex() const;
|
||||||
|
int getIndexNumber() const;
|
||||||
|
bool updateIndices(const void* indices, int count, int begin);
|
||||||
|
|
||||||
|
int getSize() const;
|
||||||
|
|
||||||
|
GLuint getVBO() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
IndexBuffer();
|
||||||
|
virtual ~IndexBuffer();
|
||||||
|
|
||||||
|
bool init(IndexType type, int number);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
mutable GLuint _vbo;
|
||||||
|
IndexType _type;
|
||||||
|
int _indexNumber;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
//event listener for foreground and background
|
||||||
|
void listenToBackground(EventCustom *event);
|
||||||
|
void recreateVBO() const;
|
||||||
|
|
||||||
|
//buffer used for shadow copy
|
||||||
|
std::vector<unsigned char> _shadowCopy;
|
||||||
|
protected:
|
||||||
|
static bool _enableShadowCopy;
|
||||||
|
public:
|
||||||
|
static bool isShadowCopyEnabled() { return _enableShadowCopy; }
|
||||||
|
static void enableShadowCopy(bool enabled) { _enableShadowCopy = enabled; }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
NS_CC_END
|
||||||
|
|
||||||
|
#endif /* __CC_VERTEX_INDEX_BUFFER_H__*/
|
|
@ -0,0 +1,132 @@
|
||||||
|
/****************************************************************************
|
||||||
|
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
||||||
|
|
||||||
|
http://www.cocos2d-x.org
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "renderer/CCVertexIndexData.h"
|
||||||
|
NS_CC_BEGIN
|
||||||
|
|
||||||
|
VertexData* VertexData::create()
|
||||||
|
{
|
||||||
|
VertexData* result = new (std::nothrow) VertexData();
|
||||||
|
if(result)
|
||||||
|
{
|
||||||
|
result->autorelease();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
CC_SAFE_DELETE(result);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t VertexData::getVertexStreamCount() const
|
||||||
|
{
|
||||||
|
return _vertexStreams.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool VertexData::setStream(VertexBuffer* buffer, const VertexStreamAttribute& stream)
|
||||||
|
{
|
||||||
|
if( buffer == nullptr ) return false;
|
||||||
|
auto iter = _vertexStreams.find(stream._semantic);
|
||||||
|
if(iter == _vertexStreams.end())
|
||||||
|
{
|
||||||
|
buffer->retain();
|
||||||
|
auto& bufferAttribute = _vertexStreams[stream._semantic];
|
||||||
|
bufferAttribute._buffer = buffer;
|
||||||
|
bufferAttribute._stream = stream;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
buffer->retain();
|
||||||
|
iter->second._buffer->release();
|
||||||
|
iter->second._stream = stream;
|
||||||
|
iter->second._buffer = buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VertexData::removeStream(int semantic)
|
||||||
|
{
|
||||||
|
auto iter = _vertexStreams.find(semantic);
|
||||||
|
if(iter != _vertexStreams.end())
|
||||||
|
{
|
||||||
|
iter->second._buffer->release();
|
||||||
|
_vertexStreams.erase(iter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const VertexStreamAttribute* VertexData::getStreamAttribute(int semantic) const
|
||||||
|
{
|
||||||
|
auto iter = _vertexStreams.find(semantic);
|
||||||
|
if(iter == _vertexStreams.end()) return nullptr;
|
||||||
|
else return &iter->second._stream;
|
||||||
|
}
|
||||||
|
|
||||||
|
VertexStreamAttribute* VertexData::getStreamAttribute(int semantic)
|
||||||
|
{
|
||||||
|
auto iter = _vertexStreams.find(semantic);
|
||||||
|
if(iter == _vertexStreams.end()) return nullptr;
|
||||||
|
else return &iter->second._stream;
|
||||||
|
}
|
||||||
|
|
||||||
|
VertexBuffer* VertexData::getStreamBuffer(int semantic) const
|
||||||
|
{
|
||||||
|
auto iter = _vertexStreams.find(semantic);
|
||||||
|
if(iter == _vertexStreams.end()) return nullptr;
|
||||||
|
else return iter->second._buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
VertexData::VertexData()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
VertexData::~VertexData()
|
||||||
|
{
|
||||||
|
for(auto& element : _vertexStreams)
|
||||||
|
{
|
||||||
|
element.second._buffer->release();
|
||||||
|
}
|
||||||
|
_vertexStreams.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VertexData::use()
|
||||||
|
{
|
||||||
|
uint32_t flags(0);
|
||||||
|
for(auto& element : _vertexStreams)
|
||||||
|
{
|
||||||
|
flags = flags | (1 << element.second._stream._semantic);
|
||||||
|
}
|
||||||
|
|
||||||
|
GL::enableVertexAttribs(flags);
|
||||||
|
|
||||||
|
for(auto& element : _vertexStreams)
|
||||||
|
{
|
||||||
|
//glEnableVertexAttribArray((GLint)element.second._stream._semantic);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, element.second._buffer->getVBO());
|
||||||
|
glVertexAttribPointer(GLint(element.second._stream._semantic),element.second._stream._size,
|
||||||
|
element.second._stream._type,element.second._stream._normalize, element.second._buffer->getSizePerVertex(), (GLvoid*)element.second._stream._offset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_CC_END
|
|
@ -0,0 +1,90 @@
|
||||||
|
/****************************************************************************
|
||||||
|
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
||||||
|
|
||||||
|
http://www.cocos2d-x.org
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __CC_VERTEX_INDEX_DATA_H__
|
||||||
|
#define __CC_VERTEX_INDEX_DATA_H__
|
||||||
|
|
||||||
|
#include "base/CCRef.h"
|
||||||
|
#include "renderer/CCVertexIndexBuffer.h"
|
||||||
|
#include "base/CCMap.h"
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
NS_CC_BEGIN
|
||||||
|
|
||||||
|
class VertexBuffer;
|
||||||
|
|
||||||
|
struct CC_DLL VertexStreamAttribute
|
||||||
|
{
|
||||||
|
VertexStreamAttribute()
|
||||||
|
: _offset(0),_semantic(0),_type(0),_size(0), _normalize(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
VertexStreamAttribute(int offset, int semantic, int type, int size)
|
||||||
|
: _offset(offset),_semantic(semantic),_type(type),_size(size), _normalize(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
VertexStreamAttribute(int offset, int semantic, int type, int size, bool normalize)
|
||||||
|
: _offset(offset),_semantic(semantic),_type(type),_size(size), _normalize(normalize)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool _normalize;
|
||||||
|
int _offset;
|
||||||
|
int _semantic;
|
||||||
|
int _type;
|
||||||
|
int _size;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CC_DLL VertexData : public Ref
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static VertexData* create();
|
||||||
|
|
||||||
|
size_t getVertexStreamCount() const;
|
||||||
|
bool setStream(VertexBuffer* buffer, const VertexStreamAttribute& stream);
|
||||||
|
void removeStream(int semantic);
|
||||||
|
const VertexStreamAttribute* getStreamAttribute(int semantic) const;
|
||||||
|
VertexStreamAttribute* getStreamAttribute(int semantic);
|
||||||
|
|
||||||
|
VertexBuffer* getStreamBuffer(int semantic) const;
|
||||||
|
|
||||||
|
void use();
|
||||||
|
protected:
|
||||||
|
VertexData();
|
||||||
|
virtual ~VertexData();
|
||||||
|
protected:
|
||||||
|
struct BufferAttribute
|
||||||
|
{
|
||||||
|
VertexBuffer* _buffer;
|
||||||
|
VertexStreamAttribute _stream;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::map<int, BufferAttribute> _vertexStreams;
|
||||||
|
};
|
||||||
|
|
||||||
|
NS_CC_END
|
||||||
|
|
||||||
|
#endif //__CC_VERTEX_INDEX_DATA_H__
|
|
@ -15,4 +15,8 @@ set(COCOS_RENDERER_SRC
|
||||||
renderer/CCTexture2D.cpp
|
renderer/CCTexture2D.cpp
|
||||||
renderer/CCTextureAtlas.cpp
|
renderer/CCTextureAtlas.cpp
|
||||||
renderer/CCTextureCache.cpp
|
renderer/CCTextureCache.cpp
|
||||||
|
renderer/CCVertexIndexBuffer.cpp
|
||||||
|
renderer/CCVertexIndexData.cpp
|
||||||
|
renderer/CCPrimitive.cpp
|
||||||
|
renderer/CCPrimitiveCommand.cpp
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue