Skip to content

Commit 251f530

Browse files
author
SeanLin
committed
Merge pull request cocos2d#730 from dingpinglv/Iss1615_WebGLRendering
Issue cocos2d#1615 Implementing WebGL rendering
2 parents 13b281c + ad85c00 commit 251f530

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+8717
-2363
lines changed

HelloHTML5World/build.xml

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,72 @@
66

77
<target name="compile">
88
<jscomp compilationLevel="simple" warning="quiet"
9-
debug="false" output="myApp-v0.1.js">
9+
debug="false" output="myApp-v2.1.js">
1010
<sources dir="${basedir}/../cocos2d">
1111
<file name="platform/CCClass.js"/>
1212
<file name="platform/CCCommon.js"/>
1313
<file name="platform/platform.js"/>
1414
<file name="platform/miniFramework.js"/>
15+
<file name="platform/ZipUtils.js"/>
16+
<file name="platform/base64.js"/>
17+
<file name="platform/gzip.js"/>
18+
<file name="platform/CCMacro.js"/>
19+
<file name="platform/CCFileUtils.js"/>
20+
<file name="platform/CCTypes.js"/>
1521
<file name="cocoa/CCGeometry.js"/>
16-
<file name="cocoa/CCSet.js"/>
22+
<file name="platform/CCConfig.js"/>
1723
<file name="cocoa/CCNS.js"/>
18-
<file name="platform/CCTypes.js"/>
24+
<file name="cocoa/CCSet.js"/>
1925
<file name="cocoa/CCAffineTransform.js"/>
2026
<file name="support/CCPointExtension.js"/>
2127
<file name="base_nodes/CCNode.js"/>
2228
<file name="base_nodes/CCdomNode.js"/>
23-
<file name="platform/CCMacro.js"/>
24-
<file name="platform/CCConfig.js"/>
29+
<file name="base_nodes/CCAtlasNode.js"/>
2530
<file name="textures/CCTexture2D.js"/>
2631
<file name="textures/CCTextureCache.js"/>
32+
<file name="textures/CCTextureAtlas.js"/>
33+
<file name="misc_nodes/CCRenderTexture.js"/>
34+
<file name="misc_nodes/CCProgressTimer.js"/>
35+
<file name="effects/CCGrid.js"/>
36+
<file name="effects/CCGrabber.js"/>
2737
<file name="actions/CCAction.js"/>
2838
<file name="actions/CCActionInterval.js"/>
39+
<file name="actions/CCActionInstant.js"/>
2940
<file name="actions/CCActionManager.js"/>
41+
<file name="actions/CCActionProgressTimer.js"/>
42+
<file name="actions/CCActionCamera.js"/>
3043
<file name="actions/CCActionEase.js"/>
44+
<file name="actions/CCActionGrid.js"/>
45+
<file name="actions/CCActionTiledGrid.js"/>
46+
<file name="actions/CCActionCatmullRom.js"/>
3147
<file name="layers_scenes_transitions_nodes/CCScene.js"/>
3248
<file name="layers_scenes_transitions_nodes/CCLayer.js"/>
3349
<file name="layers_scenes_transitions_nodes/CCTransition.js"/>
50+
<file name="layers_scenes_transitions_nodes/CCTransitionProgress.js"/>
51+
<file name="layers_scenes_transitions_nodes/CCTransitionPageTurn.js"/>
3452
<file name="sprite_nodes/CCSprite.js"/>
53+
<file name="sprite_nodes/CCAnimation.js"/>
54+
<file name="sprite_nodes/CCAnimationCache.js"/>
55+
<file name="sprite_nodes/CCSpriteFrame.js"/>
56+
<file name="sprite_nodes/CCSpriteFrameCache.js"/>
57+
<file name="sprite_nodes/CCSpriteBatchNode.js"/>
58+
<file name="label_nodes/CCLabelAtlas.js"/>
3559
<file name="label_nodes/CCLabelTTF.js"/>
36-
<file name="text_input_node/CCIMEDispatcher.js"/>
60+
<file name="label_nodes/CCLabelBMFont.js"/>
61+
<file name="particle_nodes/CCParticleSystem.js"/>
62+
<file name="particle_nodes/CCParticleBatchNode.js"/>
63+
<file name="particle_nodes/CCParticleSystemQuad.js"/>
64+
<file name="particle_nodes/CCParticleExamples.js"/>
3765
<file name="touch_dispatcher/CCTouchDelegateProtocol.js"/>
3866
<file name="touch_dispatcher/CCTouchHandler.js"/>
3967
<file name="touch_dispatcher/CCTouchDispatcher.js"/>
40-
<file name="keypad_dispatcher/CCKeypadDelegate.js"/>
41-
<file name="keypad_dispatcher/CCKeypadDispatcher.js"/>
68+
<file name="touch_dispatcher/CCMouseDispatcher.js"/>
69+
<file name="keyboard_dispatcher/CCKeyboardDelegate.js"/>
70+
<file name="keyboard_dispatcher/CCKeyboardDispatcher.js"/>
71+
<file name="text_input_node/CCIMEDispatcher.js"/>
72+
<file name="text_input_node/CCTextFieldTTF.js"/>
4273
<file name="CCDirector.js"/>
74+
<file name="CCCamera.js"/>
4375
<file name="CCScheduler.js"/>
4476
<file name="CCLoader.js"/>
4577
<file name="CCDrawingPrimitives.js"/>
@@ -48,6 +80,14 @@
4880
<file name="platform/AppControl.js"/>
4981
<file name="menu_nodes/CCMenuItem.js"/>
5082
<file name="menu_nodes/CCMenu.js"/>
83+
<file name="tileMap_parallax_nodes/CCTMXTiledMap.js"/>
84+
<file name="tileMap_parallax_nodes/CCTMXXMLParser.js"/>
85+
<file name="tileMap_parallax_nodes/CCTMXObjectGroup.js"/>
86+
<file name="tileMap_parallax_nodes/CCTMXLayer.js"/>
87+
<file name="tileMap_parallax_nodes/CCParallaxNode.js"/>
88+
<file name="Draw_Nodes/CCDrawNode.js"/>
89+
<file name="physics_nodes/CCPhysicsDebugNode.js"/>
90+
<file name="physics_nodes/CCPhysicsSprite.js"/>
5191
</sources>
5292
<sources dir="${basedir}/../CocosDenshion">
5393
<file name="SimpleAudioEngine.js"/>

System/Sys.js

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/****************************************************************************
2+
http://www.cocos2d-html5.org
3+
http://www.cocos2d-iphone.org
4+
http://www.cocos2d-x.org
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in
14+
all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
THE SOFTWARE.
23+
****************************************************************************/
24+
25+
var sys = sys || {};
26+
27+
/** LocalStorage is a local storage component.
28+
*/
29+
sys.localStorage = window.localStorage;
30+
31+
32+
/** Capabilities
33+
*/
34+
Object.defineProperties(sys,
35+
{
36+
"capabilities" : {
37+
get : function(){
38+
var capabilities = {"canvas":true};
39+
40+
// if (window.DeviceOrientationEvent!==undefined || window.OrientationEvent!==undefined)
41+
// capabilities["accelerometer"] = true;
42+
43+
if( 'ontouchstart' in document.documentElement )
44+
capabilities["touches"] = true;
45+
else if( 'onmouseup' in document.documentElement )
46+
capabilities["mouse"] = true;
47+
48+
if( 'onkeyup' in document.documentElement )
49+
capabilities["keyboard"] = true;
50+
51+
return capabilities;
52+
},
53+
enumerable : true,
54+
configurable : true
55+
},
56+
"os" : {
57+
get : function() {
58+
var iOS = ( navigator.userAgent.match(/(iPad|iPhone|iPod)/i) ? true : false );
59+
var isAndroid = navigator.userAgent.match(/android/i) || navigator.platform.match(/android/i) ? true : false;
60+
var OSName=navigator.appVersion;
61+
if (navigator.appVersion.indexOf("Win")!=-1)
62+
OSName="Windows";
63+
else if (navigator.appVersion.indexOf("Mac")!=-1)
64+
OSName="OS X";
65+
else if (navigator.appVersion.indexOf("X11")!=-1)
66+
OSName="UNIX";
67+
else if (navigator.appVersion.indexOf("Linux")!=-1)
68+
OSName="Linux";
69+
else if( iOS )
70+
OSName = "iOS";
71+
else if( isAndroid )
72+
OSName = "Android";
73+
},
74+
enumerable : true,
75+
configurable : true
76+
},
77+
"platform" : {
78+
get : function(){
79+
return "browser";
80+
},
81+
enumerable : true,
82+
configurable : true
83+
},
84+
"version" : {
85+
get : function(){
86+
return cc.ENGINE_VERSION;
87+
},
88+
enumerable : true,
89+
configurable : true
90+
}
91+
});

cocos2d/CCCamera.js

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2424
THE SOFTWARE.
2525
****************************************************************************/
26-
var cc = cc = cc || {};
27-
2826

2927
/**
3028
A CCCamera is used in every CCNode.
@@ -53,13 +51,17 @@ cc.Camera = cc.Class.extend({
5351
_eyeX:null,
5452
_eyeY:null,
5553
_eyeZ:null,
54+
5655
_centerX:null,
5756
_centerY:null,
5857
_centerZ:null,
58+
5959
_upX:null,
6060
_upY:null,
6161
_upZ:null,
62+
6263
_dirty:null,
64+
_lookupMatrix:new cc.kmMat4(),
6365

6466
/*public:*/
6567
ctor:function () {
@@ -88,29 +90,40 @@ cc.Camera = cc.Class.extend({
8890
this._upY = 1.0;
8991
this._upZ = 0.0;
9092

93+
cc.kmMat4Identity( this._lookupMatrix );
94+
9195
this._dirty = false;
9296
},
97+
9398
/** Sets the camera using gluLookAt using its eye, center and up_vector */
9499
locate:function () {
95100
if (this._dirty) {
96-
//TODO gl
97-
//gluLookAt(this._eyeX, this._eyeY, this._eyeZ,this._centerX, this._centerY, this._centerZ,this._upX, this._upY, this._upZ);
98-
}
101+
var eye = new cc.kmVec3(), center = new cc.kmVec3(), up = new cc.kmVec3();
102+
103+
cc.kmVec3Fill( eye, this._eyeX, this._eyeY , this._eyeZ );
104+
cc.kmVec3Fill( center, this._centerX, this._centerY, this._centerZ);
105+
106+
cc.kmVec3Fill( up, this._upX, this._upY, this._upZ);
107+
cc.kmMat4LookAt( this._lookupMatrix, eye, center, up);
99108

109+
this._dirty = false;
110+
}
111+
cc.kmGLMultMatrix( this._lookupMatrix );
100112
},
113+
101114
/** sets the eye values in points */
102115
setEyeXYZ:function (eyeX, eyeY, eyeZ) {
103-
this._eyeX = eyeX * cc.CONTENT_SCALE_FACTOR;
104-
this._eyeY = eyeY * cc.CONTENT_SCALE_FACTOR;
105-
this._eyeZ = eyeZ * cc.CONTENT_SCALE_FACTOR;
116+
this._eyeX = eyeX ;
117+
this._eyeY = eyeY ;
118+
this._eyeZ = eyeZ ;
106119

107120
this._dirty = true;
108121
},
109122
/** sets the center values in points */
110123
setCenterXYZ:function (centerX, centerY, fenterZ) {
111-
this._centerX = centerX * cc.CONTENT_SCALE_FACTOR;
112-
this._centerY = centerY * cc.CONTENT_SCALE_FACTOR;
113-
this._centerZ = fenterZ * cc.CONTENT_SCALE_FACTOR;
124+
this._centerX = centerX ;
125+
this._centerY = centerY ;
126+
this._centerZ = fenterZ ;
114127

115128
this._dirty = true;
116129
},
@@ -125,21 +138,15 @@ cc.Camera = cc.Class.extend({
125138

126139
/** get the eye vector values in points */
127140
getEyeXYZ:function (eyeX, eyeY, eyeZ) {
128-
eyeX = this._eyeX / cc.CONTENT_SCALE_FACTOR;
129-
eyeY = this._eyeY / cc.CONTENT_SCALE_FACTOR;
130-
eyeZ = this._eyeZ / cc.CONTENT_SCALE_FACTOR;
141+
return {eyeX:this._eyeX , eyeY:this._eyeY , eyeZ: this._eyeZ };
131142
},
132143
/** get the center vector values int points */
133144
getCenterXYZ:function (centerX, centerY, centerZ) {
134-
centerX = this._centerX / cc.CONTENT_SCALE_FACTOR;
135-
centerY = this._centerY / cc.CONTENT_SCALE_FACTOR;
136-
centerZ = this._centerZ / cc.CONTENT_SCALE_FACTOR;
145+
return {centerX:this._centerX ,centerY:this._centerY ,centerZ:this._centerZ };
137146
},
138147
/** get the up vector values */
139148
getUpXYZ:function (upX, upY, upZ) {
140-
upX = this._upX;
141-
upY = this._upY;
142-
upZ = this._upZ;
149+
return {upX:this._upX,upY:this._upY,upZ:this._upZ};
143150
},
144151

145152
/*private:*/

0 commit comments

Comments
 (0)