Jump to content
  • Advertisement
Sign in to follow this  
yewbie

Looking for good way to draw UI frames

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

Basically in my game I have a UI setup where a frame gets dynamically drawn depending on your screen size.
The way I am doing it is probably not the best way to do it, and it only works with resolutions evenly divided by my tile size (64).

What I want to do it provide the resolution and draw a frame around the outside of the image unscaled.
here is my working solutions I am looking for some suggestions because this just seems bad.

TileNumber equates to the tile to get based on the attached image, they are parse by number left to right, top to bottom in 64x64 squares.
All of this is changeable I am using a self designed engine using C++ and DirectX API

also DrawTextureToLocation just draws a quad to my offscreensurface
with x1, y1, x2, y2,Light,Alpha, Texture sorry the formatting got messed up on it.

void UIManager2::DrawUIFrame() //Draws our pretty screen frame
{
//This draws our top frame
int Xsquares= (WindowSizeX) / 64;
int Ysquares= (WindowSizeY) / 64;
int TileNumber = 0;
int OffsetX = 3; //pixel offset
int OffsetY = 0; //pixel offset
for(int x=0;x<Xsquares;x++)
{
for(int y=0;y<Ysquares;y++)
{
if(x==0 && y == 0)
{
TileNumber = 9; //top left
}
else if (x== (Xsquares-1) && y == 0) //top right //negative one here to make up for our for loop starting at zero
{
TileNumber = 11;
}
else if(y == Ysquares-1 && x == 0) //bottom left corner
{
TileNumber = 17;
}
else if(y == Ysquares-1 && x == Xsquares-1) //bottom right corner
{
TileNumber = 19;
}
else if(y ==Ysquares-1) //bottom
{
TileNumber = 18;
}
else if(y == 0) //
{
TileNumber = 10;
}
else if(x == 0) //left wall
{
TileNumber = 13;
}
else if(x == Xsquares-1) //right wall
{
TileNumber = 15;
}


else
{
TileNumber =0;
}

if(TileNumber > 0)
{
DrawTextureToLocation(x*64 - OffsetX , y*64 - OffsetY,
x*64 + 64 -OffsetX ,y*64 - OffsetY,
x*64+64 - OffsetX , y*64 + 64 - OffsetY,
x*64 - OffsetX , y*64 + 64 - OffsetY,
255,255, UITextures.TextureList.GetTexture(TileNumber) );
}
}
}
}

Share this post


Link to post
Share on other sites
Advertisement

Am I understanding this clearly? your UI is 64x64 tiles? Isn't this very limiting?


You are not, the UI frame is made out of squares that are 64x64, the UI is the same size of whatever the resolution of the window is.
I am describing the process of drawing a non scaled frame around the outside edge of the window using 64x64 tiles consisting of corners and edges.

Share this post


Link to post
Share on other sites
Well I think I am just going to use a 32x32 size tile to render the frame so that I can get all of my target resolutions without having to worry about drawing a half tile for one of them.
Im surprised I have not received any input on this =p

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!