can't see window's clientpart

vkensou

20-02-2014 02:21:32

i use mygui with directx9 (hge)

and change MyGUI_DirectXRenderManager's code like this:


void DirectXRenderManager::begin()
{
//......

D3DXMATRIX m;
D3DXMatrixIdentity(&m);
mpD3DDevice->SetTransform(D3DTS_WORLD, &m);
mpD3DDevice->SetTransform(D3DTS_VIEW, &m);
//mpD3DDevice->SetTransform(D3DTS_PROJECTION, &m);

D3DXMATRIX matProj,tmp;
D3DXMatrixScaling(&matProj, 1.0f, -1.0f, 1.0f);
D3DXMatrixTranslation(&tmp, -0.5f, mViewSize.height+0.5f, 0.0f);
D3DXMatrixMultiply(&matProj, &matProj, &tmp);
D3DXMatrixOrthoOffCenterLH(&tmp, 0, (float)mViewSize.width, 0, (float)mViewSize.height, 0.0f, 1.0f);
D3DXMatrixMultiply(&matProj, &matProj, &tmp);
mpD3DDevice->SetTransform(D3DTS_PROJECTION, &matProj);
}

void DirectXRenderManager::setViewSize(int _width, int _height)
{
if (_height == 0)
_height = 1;
if (_width == 0)
_width = 1;

mViewSize.set(_width, _height);

mInfo.maximumDepth = 1.0f;
mInfo.hOffset = 0.5f;
mInfo.vOffset = 0.5f;
mInfo.aspectCoef = float(mViewSize.height) / float(mViewSize.width);
mInfo.pixScaleX = 0.5f;
mInfo.pixScaleY = -0.5f;

onResizeView(mViewSize);

mUpdate = true;
}




mygui's other parts work normally.but window's clientpart(clienttileskin) cant see.
how can i make mygui work normally with directx9(hge)

vkensou

20-02-2014 02:32:28



in this image. window's client part cant see.It should have had a blue background

The following is normal:

Altren

20-02-2014 11:31:13

Don't know what's wrong with your code, but the main difference that window client area skin have compared to most other skins is that tiled texture is used there. Or there is something wrong with alpha handling.

vkensou

21-02-2014 09:40:57

Don't know what's wrong with your code, but the main difference that window client area skin have compared to most other skins is that tiled texture is used there. Or there is something wrong with alpha handling.

i find the question.

in mygui y-axis positive direction up,but in my situation y-axis positive direction down(just like windows).so when when mygui render tile skin ,there are some troubles.

here is my solution:

replace MyGUI_TileRect.cpp 's void TileRect::doRender()




void TileRect::doRender()
{
if (!mVisible || mEmptyView || mTileSize.empty()) return;

VertexQuad* quad = (VertexQuad*)mRenderItem->getCurrentVertexBuffer();

const RenderTargetInfo& info = mRenderItem->getRenderTarget()->getInfo();

// размер одного тайла
mRealTileWidth = info.pixScaleX * (float)(mTileSize.width) * 2;
mRealTileHeight = info.pixScaleY * (float)(mTileSize.height) * 2;

mTextureHeightOne = (mCurrentTexture.bottom - mCurrentTexture.top) / mRealTileHeight;
mTextureWidthOne = (mCurrentTexture.right - mCurrentTexture.left) / mRealTileWidth;


float vertex_z = info.maximumDepth;

// абсолютный размер окна
float window_left = ((info.pixScaleX * (float)(mCoord.left + mCroppedParent->getAbsoluteLeft() - info.leftOffset) + info.hOffset) * 2) - 1;
float window_top = -(((info.pixScaleY * (float)(mCoord.top + mCroppedParent->getAbsoluteTop() - info.topOffset) + info.vOffset) * 2) - 1);

// размер вьюпорта
float real_left = ((info.pixScaleX * (float)(mCurrentCoord.left + mCroppedParent->getAbsoluteLeft() - info.leftOffset) + info.hOffset) * 2) - 1;
float real_right = real_left + (info.pixScaleX * (float)mCurrentCoord.width * 2);
float real_top = -(((info.pixScaleY * (float)(mCurrentCoord.top + mCroppedParent->getAbsoluteTop() - info.topOffset) + info.vOffset) * 2) - 1);
float real_bottom = real_top - (info.pixScaleY * (float)mCurrentCoord.height * 2);
size_t count = 0;

float left = window_left;
float right = window_left;
float top = window_top;
float bottom = window_top;

for (int y = 0; y < mCoord.height; y += mTileSize.height)
{
top = bottom;
bottom -= mRealTileHeight;
right = window_left;

float vertex_top = top;
float vertex_bottom = bottom;
bool texture_crop_height = false;

if(real_top >= real_bottom)
{
if (vertex_top > real_top)
{
// проверка на полный выход
if (vertex_bottom > real_top)
{
continue;
}
// обрезаем
vertex_top = real_top;
texture_crop_height = true;
}
if (vertex_bottom < real_bottom)
{
// вообще вниз ушли
if (vertex_top < real_bottom)
{
continue;
}
// обрезаем
vertex_bottom = real_bottom;
texture_crop_height = true;
}
}
else
{
if (vertex_top < real_top)
{
// проверка на полный выход
if (vertex_bottom < real_top)
{
continue;
}
// обрезаем
vertex_top = real_top;
texture_crop_height = true;
}
if (vertex_bottom > real_bottom)
{
// вообще вниз ушли
if (vertex_top > real_bottom)
{
continue;
}
// обрезаем
vertex_bottom = real_bottom;
texture_crop_height = true;
}
}

for (int x = 0; x < mCoord.width; x += mTileSize.width)
{
left = right;
right += mRealTileWidth;

float vertex_left = left;
float vertex_right = right;
bool texture_crop_width = false;


if (vertex_left < real_left)
{
// проверка на полный выход
if (vertex_right < real_left)
{
continue;
}
// обрезаем
vertex_left = real_left;
texture_crop_width = true;
}

if (vertex_right > real_right)
{
// вообще строку до конца не нуна
if (vertex_left > real_right)
{
continue;
}
// обрезаем
vertex_right = real_right;
texture_crop_width = true;
}

// текущие текстурные координаты
float texture_left = mCurrentTexture.left;
float texture_right = mCurrentTexture.right;
float texture_top = mCurrentTexture.top;
float texture_bottom = mCurrentTexture.bottom;

// смещение текстуры по вертикили
if (texture_crop_height)
{
// прибавляем размер смещения в текстурных координатах
texture_top += (top - vertex_top) * mTextureHeightOne;
// отнимаем размер смещения в текстурных координатах
texture_bottom -= (vertex_bottom - bottom) * mTextureHeightOne;
}

// смещение текстуры по горизонтали
if (texture_crop_width)
{
// прибавляем размер смещения в текстурных координатах
texture_left += (vertex_left - left) * mTextureWidthOne;
// отнимаем размер смещения в текстурных координатах
texture_right -= (right - vertex_right) * mTextureWidthOne;
}

quad[count].set(
vertex_left,
vertex_top,
vertex_right,
vertex_bottom,
vertex_z,
texture_left,
texture_top,
texture_right,
texture_bottom,
mCurrentColour
);

count ++;
}
}

mRenderItem->setLastVertexCount(VertexQuad::VertexCount * count);
}