Jump to content
  • Advertisement
Sign in to follow this  
Noamke

D3D9 Interface Problem

This topic is 2699 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey,
First of all im new here, and new to D3D.

Well, i was trying to draw and Quad on the window i made, and then move it if the user clicks on it and drags it, and it was successful, however, the quad that is drawn is drawn on screen point, and not on Projection View, so it gets a bit messy as the texture and the quad itself strech if the window is maximized.

If some1 could help me on this 1, i would be totally thankful to him.

Here is the source:

void DrawMainUIWindow()
{
d3ddev->SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE);
d3ddev->SetRenderState(D3DRS_LIGHTING,TRUE);

d3ddev->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_SELECTARG1);
d3ddev->SetTextureStageState(0,D3DTSS_COLORARG1,D3DTA_TEXTURE);

d3ddev->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_SRCALPHA);
d3ddev->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA);
d3ddev->SetRenderState(D3DRS_BLENDOP,D3DBLENDOP_ADD);

d3ddev->SetRenderState( D3DRS_ZENABLE, D3DZB_FALSE );

int resNum = 0;
if(Minimized) resNum = 102;
else resNum = 103;

int texWidth = 150;
int texHeight = 200;

if(Minimized) texHeight = 25;
else texHeight = 200;

D3DXCreateTextureFromResourceExA(d3ddev,
NULL,
MAKEINTRESOURCEA(resNum),
texWidth,
texHeight,
1,
0,
D3DFMT_A8R8G8B8,
D3DPOOL_MANAGED,
D3DX_DEFAULT,
D3DX_DEFAULT,
NULL,
NULL,
NULL,
&d3dTexture);

float finalHeight = 0;
if(!Minimized) finalHeight = 200;
else finalHeight = 15;

/*CUSTOMVERTEX vertices[] =
{
{ x, y, -1.0f, 1,/ * D3DCOLOR_ARGB(255, 0, 0, 0), * /0, 0},
{ x + width, y, -1.0f, 1,/ * D3DCOLOR_ARGB(255, 0, 0, 0), * /1, 0},
{ x, y + finalHeight, -1.0f, 1,/ * D3DCOLOR_ARGB(255, 0, 0, 0), * /0, 1},
{ x + width, y + finalHeight, -1.0f, 1,/ * D3DCOLOR_ARGB(255, 0, 0, 0), * /1, 1},
};

// create a vertex buffer interface called v_buffer
d3ddev->CreateVertexBuffer(4*sizeof(CUSTOMVERTEX),
0,
CUSTOMFVF,
D3DPOOL_MANAGED,
&v_buffer,
NULL);

VOID* pVoid; // a void pointer

// lock v_buffer and load the vertices into it
v_buffer->Lock(0, 0, (void**)&pVoid, 0);
memcpy(pVoid, vertices, sizeof(vertices));
v_buffer->Unlock();*/

D3DXVECTOR3 pos;
D3DXVECTOR3 centr;
pos.x=x;
pos.y=y;
pos.z=0.0f;
centr.x=/*(float)size.right/(float)2;*/ 0;
centr.y=/*(float)size.bottom/(float)2;*/ 0;
size.left=0;size.top=0;size.right=150;size.bottom=texHeight;
m_sprite->Begin(D3DXSPRITE_ALPHABLEND);
m_sprite->Draw(d3dTexture,&size,NULL,&pos,0xFFFFFFFF);
size.left = x + 20; size.top = y + 3;
m_font->DrawTextA(m_sprite, "GenX Menu - By Genesis", -1, &size, DT_LEFT|DT_NOCLIP, D3DCOLOR_ARGB(255, 255, 255, 255));
m_sprite->End();
}


This function is called inside the d3ddev->BeginScene(); and d3ddev->EndScene();
As u might see, i tried doing it with Vertices, and i was able to create the main quad, but the text was drawn under it and the same problem that i have no was there aswell.

Share this post


Link to post
Share on other sites
Advertisement
Make sure your backbuffer has the same width as the window. Otherwise, you wont be able to resolve the stretching, as it has nothing to do with your drawing-method itself.

I'd go with vertices as it is way faster. If the text is drawn under it, just try to draw the text after the quad. It works for me without any problems.

Share this post


Link to post
Share on other sites

Make sure your backbuffer has the same width as the window. Otherwise, you wont be able to resolve the stretching, as it has nothing to do with your drawing-method itself.

I'd go with vertices as it is way faster. If the text is drawn under it, just try to draw the text after the quad. It works for me without any problems.


Thank you, u helped me alot :D

Please close this thread, my problems are solved ;D

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!