Skip to main content
GameDev.net gamedev.net
🔒 Locked

speeding up menu rendering

Started by vboyx May 22, 2003 at 9:55 PM 5 replies 400+ views
Original Post
vboyx
vboyx
is there anyway to speed this up? it draws a button/menu, much like the ones in the WinGui
void DrawButton(RECT dest, HDC destDC)
{
	int Top,Left,Right,Bottom;
	Top = dest.top;
	Left = dest.left;
	Right = dest.right;
	Bottom = dest.bottom;

        for (Top = dest.top;Top <= Bottom;Top++)
        {
	     for (Left = dest.left; Left <= Right; Left++)
	     {
	     SetPixel(destDC,Left,Top,RGB(128,128,128));
	     SetPixel(destDC,dest.left,Top,RGB(190,190,190));
	     SetPixel(destDC,Left,dest.top,RGB(190,190,190));
	     SetPixel(destDC,Right,Top,RGB(91,91,91));
	     SetPixel(destDC,Left,Bottom,RGB(91,91,91));
	     }
        }
}
  
[edited by - vboyx on May 22, 2003 10:57:28 PM] [edited by - vboyx on May 22, 2003 10:57:48 PM]
Endurion
Endurion
Use everything but SetPixel.
If you want to draw it up yourself, use lines.
Or use DrawFrameControl, lets Windows do the work.
Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>
vboyx
vboyx
duh...but whats the function for
drawing a line? and i am going
to use a DC to hold the data.
Leadorn
Leadorn
You can use LineTo and MoveEx for line drawing, else you can have a bitmap with the button texture and Blit it to screen instead of drawing it.




  
HBITMAP LoadBMP(char *szFileName)
{
//Handle to bitmap

HBITMAP HBitmap = 0;

HBitmap = (HBITMAP) LoadImage(0,szFileName,IMAGE_BITMAP,0,0,LR_DEFAULTCOLOR|LR_LOADFROMFILE);
if(HBitmap == 0) return 0;

return HBitmap;
}
//Create a offscreen dc.


BITMAP Bitmap;
GetObject(HBitmap,sizeof(BITMAP),&Bitmap);
int Surface_Width = Bitmap.bmWidth;
int Surface_Height = Bitmap.bmHeight;

//Source DC

HDC HBitmap_dc = CreateCompatibleDC(hdc);
//select loaded bitmap ito dc.

SelectObject(HBitmap_dc,HBitmap);

//use this to draw the bitmap to the dc for the window.

BitBlt(hdc,0,0,Surface_Width,Surface_Height,HBitmap_dc,0,0,SRCCOPY);


vboyx
vboyx
thanx, i think i got it.
but i want to do different sized menu''s
depending on screen res,user settings, etc.
so drawing it would be easier than loading it
as a bitmap.
Skizz
Skizz
Why not just use CreatePopupMenu, InsertMenuItem and TrackPopupMenuEx and let Win32 do all the hard work of drawing and sizing the menu.

Skizz

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.