• Advertisement
Sign in to follow this  

Drawing semi-transparent rectangle

This topic is 4475 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

Hi, I am trying to draw a semi-transparent rectangle to use as a backing for a ingame popup menu but i cant find a function to do this. Maybe something like DrawText? Its for d3d9, Any advice would be appreciated. Thankyou.

Share this post


Link to post
Share on other sites
Advertisement
Well, actually its quite easy. Since your menu will be a 2d rectangle (i guess) u just have do define 4 vertices with pretransformed positions (XYZRHW). moreover u need some alphavalues. u can store them in your vertices diffuse color, a material or the vertices specular color. i would recommend u to store it in the vertices diffuse color (XYZRHW | DIFFUSE).

before u actually render your rectangle u have to active alphablending. i dont know the exact syntax but it should be something like this:
device->SetRenderState(ALPHABLENDENABLE, TRUE);

next u have do define the "alpha function". this should be something like this (look in your SDK Doku for the exact syntax):
device->SetRenderState(ALPHASRC, SRCALPHA);
device->SetRenderState(ALPHABLEND, INVSRCALPHA);

to tell d3d that it should use the alpha information stored in your vertices u can use the materialsource rendersate (something like device->SetRenderState(DIFFUSEMATERIALSOURCE, COLOR1)

now u just have to render your rectangle:)

Share this post


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

  • Advertisement