Go to the documentation of this file.00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "MyGUI_Precompiled.h"
00024 #include "MyGUI_RawRect.h"
00025 #include "MyGUI_RenderItem.h"
00026 #include "MyGUI_RenderManager.h"
00027 #include "MyGUI_SkinManager.h"
00028 #include "MyGUI_LanguageManager.h"
00029 #include "MyGUI_CommonStateInfo.h"
00030
00031 namespace MyGUI
00032 {
00033
00034 MYGUI_FORCEINLINE void ConvertColour(uint32& _colour, VertexColourType _format)
00035 {
00036 if (_format == VertexColourType::ColourABGR)
00037 _colour = ((_colour & 0x00FF0000) >> 16) | ((_colour & 0x000000FF) << 16) | (_colour & 0xFF00FF00);
00038 }
00039
00040 RawRect::RawRect() :
00041 SubSkin(),
00042 mRectTextureLT(FloatPoint(0, 0)),
00043 mRectTextureRT(FloatPoint(1, 0)),
00044 mRectTextureLB(FloatPoint(0, 1)),
00045 mRectTextureRB(FloatPoint(1, 1)),
00046 mColourLT(Colour::White),
00047 mColourRT(Colour::White),
00048 mColourLB(Colour::White),
00049 mColourRB(Colour::White),
00050 mRenderColourLT(0xFFFFFFFF),
00051 mRenderColourRT(0xFFFFFFFF),
00052 mRenderColourLB(0xFFFFFFFF),
00053 mRenderColourRB(0xFFFFFFFF)
00054 {
00055 mVertexFormat = RenderManager::getInstance().getVertexFormat();
00056 }
00057
00058 RawRect::~RawRect()
00059 {
00060 }
00061
00062 void RawRect::setAlpha(float _alpha)
00063 {
00064 mCurrentAlpha = ((uint8)(_alpha*255) << 24);
00065
00066 mRenderColourLT = mCurrentAlpha | (mRenderColourLT & 0x00FFFFFF);
00067 mRenderColourRT = mCurrentAlpha | (mRenderColourRT & 0x00FFFFFF);
00068 mRenderColourLB = mCurrentAlpha | (mRenderColourLB & 0x00FFFFFF);
00069 mRenderColourRB = mCurrentAlpha | (mRenderColourRB & 0x00FFFFFF);
00070
00071 if (nullptr != mNode) mNode->outOfDate(mRenderItem);
00072 }
00073
00074 void RawRect::setRectColour(const Colour& _colourLT, const Colour& _colourRT, const Colour& _colourLB, const Colour& _colourRB)
00075 {
00076 mColourLT = _colourLT;
00077 mRenderColourLT = texture_utility::toColourARGB(mColourLT);
00078 ConvertColour(mRenderColourLT, mVertexFormat);
00079 mRenderColourLT = mCurrentAlpha | (mRenderColourLT & 0x00FFFFFF);
00080
00081 mColourRT = _colourRT;
00082 mRenderColourRT = texture_utility::toColourARGB(mColourRT);
00083 ConvertColour(mRenderColourRT, mVertexFormat);
00084 mRenderColourRT = mCurrentAlpha | (mRenderColourRT & 0x00FFFFFF);
00085
00086 mColourLB = _colourLB;
00087 mRenderColourLB = texture_utility::toColourARGB(mColourLB);
00088 ConvertColour(mRenderColourLB, mVertexFormat);
00089 mRenderColourLB = mCurrentAlpha | (mRenderColourLB & 0x00FFFFFF);
00090
00091 mColourRB = _colourRB;
00092 mRenderColourRB = texture_utility::toColourARGB(mColourRB);
00093 ConvertColour(mRenderColourRB, mVertexFormat);
00094 mRenderColourRB = mCurrentAlpha | (mRenderColourRB & 0x00FFFFFF);
00095
00096 if (nullptr != mNode) mNode->outOfDate(mRenderItem);
00097 }
00098
00099 void RawRect::setRectTexture(const FloatPoint& _pointLT, const FloatPoint& _pointRT, const FloatPoint& _pointLB, const FloatPoint& _pointRB)
00100 {
00101 mRectTextureLT = _pointLT;
00102 mRectTextureRT = _pointRT;
00103 mRectTextureLB = _pointLB;
00104 mRectTextureRB = _pointRB;
00105 }
00106
00107 void RawRect::doRender()
00108 {
00109 if (!mVisible || mEmptyView) return;
00110
00111 Vertex* _vertex = mRenderItem->getCurrentVertextBuffer();
00112
00113 const RenderTargetInfo& info = mRenderItem->getRenderTarget()->getInfo();
00114
00115 float vertex_z = info.maximumDepth;
00116
00117 float vertex_left = ((info.pixScaleX * (float)(mCurrentCoord.left + mCroppedParent->getAbsoluteLeft() - info.leftOffset) + info.hOffset) * 2) - 1;
00118 float vertex_right = vertex_left + (info.pixScaleX * (float)mCurrentCoord.width * 2);
00119 float vertex_top = -(((info.pixScaleY * (float)(mCurrentCoord.top + mCroppedParent->getAbsoluteTop() - info.topOffset) + info.vOffset) * 2) - 1);
00120 float vertex_bottom = vertex_top - (info.pixScaleY * (float)mCurrentCoord.height * 2);
00121
00122
00123 _vertex[0].x = vertex_left;
00124 _vertex[0].y = vertex_top;
00125 _vertex[0].z = vertex_z;
00126 _vertex[0].colour = mRenderColourLT;
00127 _vertex[0].u = mRectTextureLT.left;
00128 _vertex[0].v = mRectTextureLT.top;
00129
00130
00131 _vertex[1].x = vertex_left;
00132 _vertex[1].y = vertex_bottom;
00133 _vertex[1].z = vertex_z;
00134 _vertex[1].colour = mRenderColourLB;
00135 _vertex[1].u = mRectTextureLB.left;
00136 _vertex[1].v = mRectTextureLB.top;
00137
00138
00139 _vertex[2].x = vertex_right;
00140 _vertex[2].y = vertex_top;
00141 _vertex[2].z = vertex_z;
00142 _vertex[2].colour = mRenderColourRT;
00143 _vertex[2].u = mRectTextureRT.left;
00144 _vertex[2].v = mRectTextureRT.top;
00145
00146
00147 _vertex[3].x = vertex_right;
00148 _vertex[3].y = vertex_top;
00149 _vertex[3].z = vertex_z;
00150 _vertex[3].colour = mRenderColourRT;
00151 _vertex[3].u = mRectTextureRT.left;
00152 _vertex[3].v = mRectTextureRT.top;
00153
00154
00155 _vertex[4].x = vertex_left;
00156 _vertex[4].y = vertex_bottom;
00157 _vertex[4].z = vertex_z;
00158 _vertex[4].colour = mRenderColourLB;
00159 _vertex[4].u = mRectTextureLB.left;
00160 _vertex[4].v = mRectTextureLB.top;
00161
00162
00163 _vertex[5].x = vertex_right;
00164 _vertex[5].y = vertex_bottom;
00165 _vertex[5].z = vertex_z;
00166 _vertex[5].colour = mRenderColourRB;
00167 _vertex[5].u = mRectTextureRB.left;
00168 _vertex[5].v = mRectTextureRB.top;
00169
00170 mRenderItem->setLastVertexCount(VertexQuad::VertexCount);
00171 }
00172
00173 void RawRect::setStateData(IStateInfo * _data)
00174 {
00175 SubSkinStateInfo* data = _data->castType<SubSkinStateInfo>();
00176 const FloatRect& rect = data->getRect();
00177 mRectTextureLT.set(rect.left, rect.top);
00178 mRectTextureRT.set(rect.right, rect.top);
00179 mRectTextureLB.set(rect.left, rect.bottom);
00180 mRectTextureRB.set(rect.right, rect.bottom);
00181 }
00182
00183 }