本文整理汇总了C++中USRect::Width方法的典型用法代码示例。如果您正苦于以下问题:C++ USRect::Width方法的具体用法?C++ USRect::Width怎么用?C++ USRect::Width使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类USRect
的用法示例。
在下文中一共展示了USRect::Width方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawGrid
//----------------------------------------------------------------//
void MOAIDraw::DrawGrid ( const USRect& rect, u32 xCells, u32 yCells ) {
if ( xCells > 1 ) {
float xStep = rect.Width () / ( float )xCells;
for ( u32 i = 1; i < xCells; ++i ) {
float x = rect.mXMin + (( float )i * xStep );
USVec2D v0 ( x, rect.mYMin );
USVec2D v1 ( x, rect.mYMax );
MOAIDraw::DrawLine ( v0, v1 );
}
}
if ( yCells > 1 ) {
float yStep = rect.Height () / ( float )yCells;
for ( u32 i = 1; i < yCells; ++i ) {
float y = rect.mYMin + (( float )i * yStep );
USVec2D v0 ( rect.mXMin, y );
USVec2D v1 ( rect.mXMax, y );
MOAIDraw::DrawLine ( v0, v1 );
}
}
MOAIDraw::DrawRectOutline ( rect );
}
示例2: SetScissorRect
//----------------------------------------------------------------//
void MOAIGfxDevice::SetScissorRect ( USRect rect ) {
rect.Bless ();
USRect& current = this->mScissorRect;
if ( ( current.mXMin != rect.mXMin ) ||
( current.mYMin != rect.mYMin ) ||
( current.mXMax != rect.mXMax ) ||
( current.mYMax != rect.mYMax )) {
this->Flush ();
USRect deviceRect = this->mFrameBuffer->WndRectToDevice ( rect );
GLint x = ( GLint )deviceRect.mXMin;
GLint y = ( GLint )deviceRect.mYMin;
GLsizei w = ( GLsizei )( deviceRect.Width () + 0.5f );
GLsizei h = ( GLsizei )( deviceRect.Height () + 0.5f );
glScissor ( x, y, w, h );
this->mScissorRect = rect;
glEnable ( GL_SCISSOR_TEST );
}
}
示例3: DrawGrid
//----------------------------------------------------------------//
void MOAIDraw::DrawGrid ( USRect& rect, u32 xCells, u32 yCells ) {
MOAILineBrush glLine;
if ( xCells > 1 ) {
float xStep = rect.Width () / ( float )xCells;
for ( u32 i = 1; i < xCells; ++i ) {
float x = rect.mXMin + (( float )i * xStep );
USVec2D v0 ( x, rect.mYMin );
USVec2D v1 ( x, rect.mYMax );
glLine.SetVerts ( v0, v1 );
glLine.Draw ();
}
}
if ( yCells > 1 ) {
float yStep = rect.Height () / ( float )yCells;
for ( u32 i = 1; i < yCells; ++i ) {
float y = rect.mYMin + (( float )i * yStep );
USVec2D v0 ( rect.mXMin, y );
USVec2D v1 ( rect.mXMax, y );
glLine.SetVerts ( v0, v1 );
glLine.Draw ();
}
}
MOAIDraw::DrawRectOutline ( rect );
}
示例4: ResetState
//----------------------------------------------------------------//
void MOAIGfxDevice::ResetState () {
this->mTop = 0;
this->mPrimCount = 0;
// turn off texture
#if USE_OPENGLES1
glDisable ( GL_TEXTURE_2D );
#endif
this->mTextureUnits [ 0 ] = 0;
// turn off blending
glDisable ( GL_BLEND );
this->mBlendEnabled = false;
// disable backface culling
glDisable ( GL_CULL_FACE );
this->mCullFunc = 0;
// disable depth test
glDisable ( GL_DEPTH_TEST );
this->mDepthFunc = 0;
// enable depth write
glDepthMask ( true );
this->mDepthMask = true;
// clear the vertex format
this->SetVertexFormat ();
// clear the shader
this->mShader = 0;
// reset the pen width
this->mPenWidth = 1.0f;
glLineWidth (( GLfloat )this->mPenWidth );
// reset the point size
this->mPointSize = 1.0f;
// reset the scissor rect
MOAIGfxDevice& device = MOAIGfxDevice::Get ();
USRect scissorRect = device.GetRect ();
glScissor (( int )scissorRect.mXMin, ( int )scissorRect.mYMin, ( int )scissorRect.Width (), ( int )scissorRect.Height ());
this->mScissorRect = scissorRect;
#if USE_OPENGLES1
// fixed function reset
if ( !this->IsProgrammable ()) {
// reset the current vertex color
glColor4f ( 1.0f, 1.0f, 1.0f, 1.0f );
// reset the point size
glPointSize (( GLfloat )this->mPointSize );
}
#endif
}
示例5: SetScissorRect
//----------------------------------------------------------------//
void MOAIGfxDevice::SetScissorRect ( const USRect& rect ) {
USRect& current = this->mScissorRect;
if ( ( current.mXMin != rect.mXMin ) ||
( current.mYMin != rect.mYMin ) ||
( current.mXMax != rect.mXMax ) ||
( current.mYMax != rect.mYMax )) {
this->Flush ();
glScissor (( int )rect.mXMin, ( int )rect.mYMin, ( int )rect.Width (), ( int )rect.Height ());
this->mScissorRect = rect;
}
}
示例6: SetViewport
//----------------------------------------------------------------//
void MOAIGfxDevice::SetViewport ( const USRect& viewport ) {
// set us up the viewport
GLint x = ( GLint )viewport.mXMin;
GLint y = ( GLint )viewport.mYMin;
GLsizei w = ( GLsizei )( viewport.Width () + 0.5f );
GLsizei h = ( GLsizei )( viewport.Height () + 0.5f );
glViewport ( x, y, w, h );
this->mViewRect = viewport;
}
示例7: SetViewRect
//----------------------------------------------------------------//
void MOAIGfxDevice::SetViewRect ( USRect rect ) {
USRect deviceRect = rect;
deviceRect = this->mFrameBuffer->WndRectToDevice ( rect );
GLint x = ( GLint )deviceRect.mXMin;
GLint y = ( GLint )deviceRect.mYMin;
GLsizei w = ( GLsizei )( deviceRect.Width () + 0.5f );
GLsizei h = ( GLsizei )( deviceRect.Height () + 0.5f );
glViewport ( x, y, w, h );
this->mViewRect = rect;
}
示例8: GetWndToNormMtx
//----------------------------------------------------------------//
USMatrix4x4 MOAIGfxDevice::GetWndToNormMtx () const {
USRect rect = this->mViewRect;
float hWidth = rect.Width () * 0.5f;
float hHeight = rect.Height () * 0.5f;
// Inv Wnd
USMatrix4x4 wndToNorm;
wndToNorm.Translate ( -hWidth - rect.mXMin, -hHeight - rect.mYMin, 0.0f );
USMatrix4x4 mtx;
mtx.Scale (( 1.0f / hWidth ), -( 1.0f / hHeight ), 1.0f );
wndToNorm.Append ( mtx );
return wndToNorm;
}
示例9: GetNormToWndMtx
//----------------------------------------------------------------//
USMatrix4x4 MOAIGfxDevice::GetNormToWndMtx () const {
USRect rect = this->mViewRect;
float hWidth = rect.Width () * 0.5f;
float hHeight = rect.Height () * 0.5f;
// Wnd
USMatrix4x4 normToWnd;
normToWnd.Scale ( hWidth, -hHeight, 1.0f );
USMatrix4x4 mtx;
mtx.Translate ( hWidth + rect.mXMin, hHeight + rect.mYMin, 0.0f );
normToWnd.Append ( mtx );
return normToWnd;
}
示例10: SetViewport
//----------------------------------------------------------------//
void MOAIGfxDevice::SetViewport ( const USRect& viewport ) {
// set us up the viewport
GLint x = ( GLint )viewport.mXMin;
GLint y = ( GLint )viewport.mYMin;
GLsizei w = ( GLsizei )( viewport.Width () + 0.5f );
GLsizei h = ( GLsizei )( viewport.Height () + 0.5f );
glViewport (
( GLint )( x * this->mDeviceScale ),
( GLint )( y * this->mDeviceScale ),
( GLsizei )( w * this->mDeviceScale ),
( GLsizei )( h * this->mDeviceScale )
);
this->mViewRect = viewport;
}
示例11: GetWorldToWndMtx
//----------------------------------------------------------------//
USMatrix4x4 MOAIGfxDevice::GetWorldToWndMtx ( float xScale, float yScale ) const {
USMatrix4x4 worldToWnd;
USMatrix4x4 mtx;
USRect rect = this->GetViewRect ();
float hWidth = rect.Width () * 0.5f;
float hHeight = rect.Height () * 0.5f;
// viewproj
worldToWnd = this->GetViewProjMtx ();
// wnd
mtx.Scale ( hWidth * xScale, hHeight * yScale, 1.0f );
worldToWnd.Append ( mtx );
mtx.Translate ( hWidth + rect.mXMin, hHeight + rect.mYMin, 0.0f );
worldToWnd.Append ( mtx );
return worldToWnd;
}
示例12: GetWndToWorldMtx
//----------------------------------------------------------------//
USMatrix4x4 MOAIGfxDevice::GetWndToWorldMtx () const {
USMatrix4x4 wndToWorld;
USMatrix4x4 mtx;
USRect rect = this->GetViewRect ();
float hWidth = rect.Width () * 0.5f;
float hHeight = rect.Height () * 0.5f;
// Inv Wnd
wndToWorld.Translate ( -hWidth - rect.mXMin, -hHeight - rect.mYMin, 0.0f );
mtx.Scale (( 1.0f / hWidth ), -( 1.0f / hHeight ), 1.0f );
wndToWorld.Append ( mtx );
// inv viewproj
mtx = this->GetViewProjMtx ();
mtx.Inverse ();
wndToWorld.Append ( mtx );
return wndToWorld;
}
示例13: BuildLayout
//----------------------------------------------------------------//
void MOAITextDesigner::BuildLayout ( MOAITextBox& textBox ) {
if ( !textBox.mStyleMap.GetTop ()) return;
this->mStr = textBox.mText;
this->mIdx = textBox.mCurrentPageIdx;
this->mStyleSpan = 0;
this->mStyle = 0;
int tokenIdx = this->mIdx;
int lineIdx = this->mIdx;
float width = textBox.mFrame.Width ();
float height = textBox.mFrame.Height ();
u32 lineStart = 0;
u32 lineSize = 0;
u32 tokenStart = 0;
u32 tokenSize = 0;
USRect lineRect;
lineRect.Init ( 0.0f, 0.0f, 0.0f, 0.0f );
USRect tokenRect;
tokenRect.Init ( 0.0f, 0.0f, 0.0f, 0.0f );
float tokenAscent = 0.0f;
float lineAscent = 0.0f;
USVec2D pen;
pen.Init ( 0.0f, 0.0f );
MOAIGlyph* glyph = 0;
MOAIGlyph* prevGlyph = 0;
textBox.mMore = true;
bool more = true;
while ( more ) {
u32 c = this->NextChar ( textBox );
float scale = textBox.mGlyphScale * ( this->mStyle ? this->mStyle->mScale : 1.0f );
bool acceptToken = false;
bool acceptLine = false;
if ( MOAIFont::IsControl ( c )) {
if ( c == '\n' ) {
tokenIdx = this->mIdx - 1;
tokenStart = textBox.mSprites.GetTop ();
acceptToken = true;
acceptLine = true;
if ( !tokenRect.Height ()) {
tokenRect.mYMax += this->mDeck->mHeight * scale;
}
}
else if ( c == 0 ) {
textBox.mMore = false;
tokenIdx = this->mIdx - 1;
tokenStart = textBox.mSprites.GetTop ();
acceptToken = true;
acceptLine = true;
more = false;
}
}
else {
glyph = this->mDeck->GetGlyph ( c );
if ( !glyph ) continue;
if ( glyph->mAdvanceX == 0.0f ) continue;
// apply kerning
if ( prevGlyph ) {
MOAIKernVec kernVec = prevGlyph->GetKerning ( glyph->mCode );
pen.mX += kernVec.mX * scale;
}
prevGlyph = glyph;
if ( MOAIFont::IsWhitespace ( c )) {
if ( tokenSize ) {
acceptToken = true;
}
}
else {
float glyphBottom = pen.mY + ( this->mDeck->mHeight * scale );
// handle new token
if ( !tokenSize ) {
tokenIdx = this->mIdx - 1;
tokenStart = textBox.mSprites.GetTop ();
//.........这里部分代码省略.........
示例14: ResetState
//----------------------------------------------------------------//
void MOAIGfxDevice::ResetState () {
for ( u32 i = 0; i < TOTAL_VTX_TRANSFORMS; ++i ) {
this->mVertexTransforms [ i ].Ident ();
}
this->mUVTransform.Ident ();
this->mCpuVertexTransformMtx.Ident ();
this->mBillboardMtx.Ident ();
this->mVertexMtxInput = VTX_STAGE_MODEL;
this->mVertexMtxOutput = VTX_STAGE_MODEL;
this->mTop = 0;
this->mPrimCount = 0;
// turn off texture
#if USE_OPENGLES1
if ( !this->IsProgrammable ()) {
glDisable ( GL_TEXTURE_2D );
}
#endif
this->mTextureUnits [ 0 ] = 0;
// turn off blending
glDisable ( GL_BLEND );
this->mBlendEnabled = false;
// disable backface culling
glDisable ( GL_CULL_FACE );
this->mCullFunc = 0;
// disable depth test
glDisable ( GL_DEPTH_TEST );
this->mDepthFunc = 0;
// enable depth write
glDepthMask ( true );
this->mDepthMask = true;
// clear the vertex format
this->SetVertexFormat ();
// clear the shader
this->mShader = 0;
// reset the pen width
this->mPenWidth = 1.0f;
glLineWidth (( GLfloat )this->mPenWidth );
// reset the point size
this->mPointSize = 1.0f;
// reset the scissor rect
USRect scissorRect = this->mFrameBuffer->GetBufferRect ();
glScissor (( int )scissorRect.mXMin, ( int )scissorRect.mYMin, ( int )scissorRect.Width (), ( int )scissorRect.Height ());
this->mScissorRect = scissorRect;
// fixed function reset
#if USE_OPENGLES1
if ( !this->IsProgrammable ()) {
// load identity matrix
glMatrixMode ( GL_MODELVIEW );
glLoadIdentity ();
glMatrixMode ( GL_PROJECTION );
glLoadIdentity ();
glMatrixMode ( GL_TEXTURE );
glLoadIdentity ();
// reset the current vertex color
glColor4f ( 1.0f, 1.0f, 1.0f, 1.0f );
// reset the point size
glPointSize (( GLfloat )this->mPointSize );
}
#endif
}