Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 30 additions & 68 deletions cocos2d/core/CCDirector.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,75 +24,8 @@
THE SOFTWARE.
****************************************************************************/

//Possible OpenGL projections used by director
/**
* sets a 2D projection (orthogonal projection)
* @constant
* @type Number
*/
cc.DIRECTOR_PROJECTION_2D = 0;

cc.g_NumberOfDraws = 0;

/**
* sets a 3D projection with a fovy=60, znear=0.5f and zfar=1500.
* @constant
* @type Number
*/
cc.DIRECTOR_PROJECTION_3D = 1;

/**
* it calls "updateProjection" on the projection delegate.
* @constant
* @type Number
*/
cc.DIRECTOR_PROJECTION_CUSTOM = 3;

/**
* Default projection is 3D projection
* @constant
* @type Number
*/
cc.DIRECTOR_PROJECTION_DEFAULT = cc.DIRECTOR_PROJECTION_3D;

//----------------------------------------------------------------------------------------------------------------------
//Possible device orientations
/**
* Device oriented vertically, home button on the bottom (UIDeviceOrientationPortrait)
* @constant
* @type Number
*/
cc.DEVICE_ORIENTATION_PORTRAIT = 0;

/**
* Device oriented horizontally, home button on the right (UIDeviceOrientationLandscapeLeft)
* @constant
* @type Number
*/
cc.DEVICE_ORIENTATION_LANDSCAPE_LEFT = 1;

/**
* Device oriented vertically, home button on the top (UIDeviceOrientationPortraitUpsideDown)
* @constant
* @type Number
*/
cc.DEVICE_ORIENTATION_PORTRAIT_UPSIDE_DOWN = 2;

/**
* Device oriented horizontally, home button on the left (UIDeviceOrientationLandscapeRight)
* @constant
* @type Number
*/
cc.DEVICE_ORIENTATION_LANDSCAPE_RIGHT = 3;

/**
* In browsers, we only support 2 orientations by change window size.
* @constant
* @type Number
*/
cc.DEVICE_MAX_ORIENTATIONS = 2;


cc.GLToClipTransform = function (transformOut) {
var projection = new cc.kmMat4();
cc.kmGLGetMatrix(cc.KM_GL_PROJECTION, projection);
Expand Down Expand Up @@ -197,7 +130,7 @@ cc.Director = cc.Class.extend(/** @lends cc.director# */{
this._oldAnimationInterval = this._animationInterval = 1.0 / cc.defaultFPS;
this._scenesStack = [];
// Set default projection (3D)
this._projection = cc.DIRECTOR_PROJECTION_DEFAULT;
this._projection = cc.Director.PROJECTION_DEFAULT;
// projection delegate if "Custom" projection is used
this._projectionDelegate = null;

Expand Down Expand Up @@ -872,6 +805,35 @@ cc.Director._getInstance = function () {
*/
cc.defaultFPS = 60;

//Possible OpenGL projections used by director
/**
* sets a 2D projection (orthogonal projection)
* @constant
* @type Number
*/
cc.Director.PROJECTION_2D = 0;

/**
* sets a 3D projection with a fovy=60, znear=0.5f and zfar=1500.
* @constant
* @type Number
*/
cc.Director.PROJECTION_3D = 1;

/**
* it calls "updateProjection" on the projection delegate.
* @constant
* @type Number
*/
cc.Director.PROJECTION_CUSTOM = 3;

/**
* Default projection is 3D projection
* @constant
* @type Number
*/
cc.Director.PROJECTION_DEFAULT = cc.Director.PROJECTION_3D;

if (cc._renderType === cc._RENDER_TYPE_CANVAS) {

var _p = cc.Director.prototype;
Expand Down
6 changes: 3 additions & 3 deletions cocos2d/core/CCDirectorWebGL.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ if (cc._renderType === cc._RENDER_TYPE_WEBGL) {
_t.setViewport();

switch (projection) {
case cc.DIRECTOR_PROJECTION_2D:
case cc.Director.PROJECTION_2D:
cc.kmGLMatrixMode(cc.KM_GL_PROJECTION);
cc.kmGLLoadIdentity();
var orthoMatrix = new cc.kmMat4();
Expand All @@ -58,7 +58,7 @@ if (cc._renderType === cc._RENDER_TYPE_WEBGL) {
cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW);
cc.kmGLLoadIdentity();
break;
case cc.DIRECTOR_PROJECTION_3D:
case cc.Director.PROJECTION_3D:
var zeye = _t.getZEye();
var matrixPerspective = new cc.kmMat4(), matrixLookup = new cc.kmMat4();
cc.kmGLMatrixMode(cc.KM_GL_PROJECTION);
Expand All @@ -77,7 +77,7 @@ if (cc._renderType === cc._RENDER_TYPE_WEBGL) {
cc.kmMat4LookAt(matrixLookup, eye, center, up);
cc.kmGLMultMatrix(matrixLookup);
break;
case cc.DIRECTOR_PROJECTION_CUSTOM:
case cc.Director.PROJECTION_CUSTOM:
if (_t._projectionDelegate)
_t._projectionDelegate.updateProjection();
break;
Expand Down
10 changes: 7 additions & 3 deletions cocos2d/core/base-nodes/BaseNodesWebGL.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,14 @@ _tmp.WebGLCCNode = function () {
if (_t._camera != null && !(_t.grid != null && _t.grid.isActive())) {
var apx = _t._anchorPointInPoints.x, apy = _t._anchorPointInPoints.y;
var translate = (apx !== 0.0 || apy !== 0.0);
if (translate) {
cc.kmGLTranslatef(cc.RENDER_IN_SUBPIXEL(apx), cc.RENDER_IN_SUBPIXEL(apy), 0);
if (translate){
if(!cc.SPRITEBATCHNODE_RENDER_SUBPIXEL) {
apx = 0 | apx;
apy = 0 | apy;
}
cc.kmGLTranslatef(apx, apy, 0);
_t._camera.locate();
cc.kmGLTranslatef(cc.RENDER_IN_SUBPIXEL(-apx), cc.RENDER_IN_SUBPIXEL(-apy), 0);
cc.kmGLTranslatef(-apx, -apy, 0);
} else {
_t._camera.locate();
}
Expand Down
7 changes: 6 additions & 1 deletion cocos2d/core/platform/CCClass.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,12 @@ cc.defineGetterSetter = function (proto, prop, getter, setter, getterName, sette
var hasGetter = (getter != null), hasSetter = (setter != undefined), props = Object.getOwnPropertyNames(proto);
for (var i = 0; i < props.length; i++) {
var name = props[i];
if( proto.__lookupGetter__(name) || typeof proto[name] !== "function" ) continue;

if( (Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(proto, name)
: proto.__lookupGetter__(name))
|| typeof proto[name] !== "function" )
continue;

var func = proto[name];
if (hasGetter && func === getter) {
getterName = name;
Expand Down
2 changes: 1 addition & 1 deletion cocos2d/core/platform/CCConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* @constant
* @type String
*/
cc.ENGINE_VERSION = "Cocos2d-html5-v3.0 alpha";
cc.ENGINE_VERSION = "Cocos2d-html5-v3.0 alpha 2";

/**
* <p>
Expand Down
Loading