void CALL HGE_Impl::Gfx_SetClipping(int x, int y, int w, int h) { D3DVIEWPORT8 vp; int scr_width, scr_height; if(!pCurTarget) { scr_width=pHGE->System_GetStateInt(HGE_SCREENWIDTH); scr_height=pHGE->System_GetStateInt(HGE_SCREENHEIGHT); } else { scr_width=Texture_GetWidth((HTEXTURE)pCurTarget->pTex); scr_height=Texture_GetHeight((HTEXTURE)pCurTarget->pTex); } if(!w) { vp.X=0; vp.Y=0; vp.Width=scr_width; vp.Height=scr_height; } else { if(x<0) { w+=x; x=0; } if(y<0) { h+=y; y=0; } if(x+w > scr_width) w=scr_width-x; if(y+h > scr_height) h=scr_height-y; vp.X=x; vp.Y=y; vp.Width=w; vp.Height=h; } vp.MinZ=0.0f; vp.MaxZ=1.0f; _render_batch(); pD3DDevice->SetViewport(&vp); D3DXMATRIX tmp; D3DXMatrixScaling(&matProj, 1.0f, -1.0f, 1.0f); D3DXMatrixTranslation(&tmp, -0.5f, +0.5f, 0.0f); D3DXMatrixMultiply(&matProj, &matProj, &tmp); D3DXMatrixOrthoOffCenterLH(&tmp, (float)vp.X, (float)(vp.X+vp.Width), -((float)(vp.Y+vp.Height)), -((float)vp.Y), vp.MinZ, vp.MaxZ); D3DXMatrixMultiply(&matProj, &matProj, &tmp); #ifdef UNDER_CE pD3DDevice->SetTransform(D3DTS_PROJECTION, (D3DMMATRIX*)&matProj, D3DMFMT_D3DMVALUE_FLOAT); #else pD3DDevice->SetTransform(D3DTS_PROJECTION, &matProj); #endif }
int Texture::GetHeight() { return obj ? Texture_GetHeight(obj) : 0; }
void HGE_CALL HGE_Impl::Gfx_SetClipping(int x, int y, int w, int h) { // Set the viewport D3D11_VIEWPORT vp; ZeroMemory(&vp, sizeof(D3D11_VIEWPORT)); vp.TopLeftX = 0; vp.TopLeftY = 0; vp.Width = nScreenWidth; vp.Height = nScreenHeight; int scr_width, scr_height; if (!pCurTarget) { scr_width = pHGE->System_GetStateInt(HGE_SCREENWIDTH); scr_height = pHGE->System_GetStateInt(HGE_SCREENHEIGHT); } else { scr_width = Texture_GetWidth((HTEXTURE)pCurTarget->pTex); scr_height = Texture_GetHeight((HTEXTURE)pCurTarget->pTex); } if (!w) { vp.TopLeftX = 0; vp.TopLeftY = 0; vp.Width = scr_width; vp.Height = scr_height; } else { if (x<0) { w += x; x = 0; } if (y<0) { h += y; y = 0; } if (x + w > scr_width) w = scr_width - x; if (y + h > scr_height) h = scr_height - y; vp.TopLeftX = x; vp.TopLeftY = y; vp.Width = w; vp.Height = h; } vp.MinDepth = 0.0f; vp.MaxDepth = 1.0f; _render_batch(); m_pD3DDeviceContext->RSSetViewports(1, &vp); //Adjust scaling and orthogonal arguments accordingly. // D3DXMATRIX tmp; // D3DXMatrixScaling(&matProj, 1.0f, -1.0f, 1.0f); // D3DXMatrixTranslation(&tmp, -0.5f, +0.5f, 0.0f); // D3DXMatrixMultiply(&matProj, &matProj, &tmp); // D3DXMatrixOrthoOffCenterLH(&tmp, (float)vp.TopLeftX, (float)(vp.TopLeftX + vp.Width), -((float)(vp.TopLeftY + vp.Height)), -((float)vp.TopLeftY), vp.MinDepth, vp.MaxDepth); // D3DXMatrixMultiply(&matProj, &matProj, &tmp); //pD3DDevice->SetTransform(D3DTS_PROJECTION, &matProj); }