mirror of https://github.com/axmolengine/axmol.git
init code for viewport
This commit is contained in:
parent
22ddf53539
commit
1fb0ba112b
|
@ -35,6 +35,19 @@ NS_CC_BEGIN
|
||||||
|
|
||||||
Camera* Camera::_visitingCamera = nullptr;
|
Camera* Camera::_visitingCamera = nullptr;
|
||||||
|
|
||||||
|
Viewport::Viewport(float left, float bottom, float width, float height)
|
||||||
|
: _left(left)
|
||||||
|
, _bottom(bottom)
|
||||||
|
, _width(width)
|
||||||
|
, _height(height)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Viewport::Viewport()
|
||||||
|
{
|
||||||
|
_left = _bottom = 0.f;
|
||||||
|
_width = _height = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
Camera* Camera::getDefaultCamera()
|
Camera* Camera::getDefaultCamera()
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,6 +33,20 @@ NS_CC_BEGIN
|
||||||
|
|
||||||
class Scene;
|
class Scene;
|
||||||
class FrameBufferObject;
|
class FrameBufferObject;
|
||||||
|
/**
|
||||||
|
Viewport is a normalized to renderTarget
|
||||||
|
*/
|
||||||
|
struct CC_DLL Viewport
|
||||||
|
{
|
||||||
|
Viewport(float left, float bottom, float width, float height);
|
||||||
|
Viewport();
|
||||||
|
|
||||||
|
float _left;
|
||||||
|
float _bottom;
|
||||||
|
float _width;
|
||||||
|
float _height;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Note:
|
* Note:
|
||||||
* Scene creates a default camera. And the default camera mask of Node is 1, therefore it can be seen by the default camera.
|
* Scene creates a default camera. And the default camera mask of Node is 1, therefore it can be seen by the default camera.
|
||||||
|
@ -54,10 +68,9 @@ enum class CameraFlag
|
||||||
USER7 = 1 << 7,
|
USER7 = 1 << 7,
|
||||||
USER8 = 1 << 8,
|
USER8 = 1 << 8,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines a camera .
|
* Defines a camera .
|
||||||
*/
|
*/
|
||||||
class CC_DLL Camera :public Node
|
class CC_DLL Camera :public Node
|
||||||
{
|
{
|
||||||
friend class Scene;
|
friend class Scene;
|
||||||
|
@ -204,7 +217,7 @@ public:
|
||||||
void clearBackground(float depth);
|
void clearBackground(float depth);
|
||||||
|
|
||||||
void setFrameBufferObject(FrameBufferObject* fbo);
|
void setFrameBufferObject(FrameBufferObject* fbo);
|
||||||
|
void setViewport(const Viewport& vp) { _viewport = vp; }
|
||||||
CC_CONSTRUCTOR_ACCESS:
|
CC_CONSTRUCTOR_ACCESS:
|
||||||
Camera();
|
Camera();
|
||||||
~Camera();
|
~Camera();
|
||||||
|
@ -222,6 +235,7 @@ CC_CONSTRUCTOR_ACCESS:
|
||||||
bool initPerspective(float fieldOfView, float aspectRatio, float nearPlane, float farPlane);
|
bool initPerspective(float fieldOfView, float aspectRatio, float nearPlane, float farPlane);
|
||||||
bool initOrthographic(float zoomX, float zoomY, float nearPlane, float farPlane);
|
bool initOrthographic(float zoomX, float zoomY, float nearPlane, float farPlane);
|
||||||
void applyFrameBufferObject();
|
void applyFrameBufferObject();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
Scene* _scene; //Scene camera belongs to
|
Scene* _scene; //Scene camera belongs to
|
||||||
|
@ -244,6 +258,7 @@ protected:
|
||||||
static Camera* _visitingCamera;
|
static Camera* _visitingCamera;
|
||||||
|
|
||||||
friend class Director;
|
friend class Director;
|
||||||
|
Viewport _viewport;
|
||||||
|
|
||||||
FrameBufferObject* _fbo;
|
FrameBufferObject* _fbo;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue