home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Learn 3D Graphics Programming on the PC
/
Learn_3D_Graphics_Programming_on_the_PC_Ferraro.iso
/
rwwin
/
gdi3d.c_
/
gdi3d.bin
Wrap
Text File
|
1995-11-14
|
4KB
|
134 lines
/**********************************************************************
*
* File : gdi3d.c
*
* Abstract : RenderWare Shop demo. GDI utility functions for drawing
* 3D shapes.
*
**********************************************************************
*
* This file is a product of Criterion Software Ltd.
*
* This file is provided as is with no warranties of any kind and is
* provided without any obligation on Criterion Software Ltd. or
* Canon Inc. to assist in its use or modification.
*
* Criterion Software Ltd. will not, under any
* circumstances, be liable for any lost revenue or other damages arising
* from the use of this file.
*
* Copyright (c) 1995 Criterion Software Ltd.
* All Rights Reserved.
*
* RenderWare is a trademark of Canon Inc.
*
************************************************************************/
/**********************************************************************
*
* Include files.
*
**********************************************************************/
#include <windows.h>
/**********************************************************************
*
* Draw a 3D rectangle.
*
**********************************************************************/
BOOL
Rectangle3D(HDC hdc, int left, int top, int right, int bottom, BOOL out)
{
HPEN oldPen;
HPEN topLeftPen;
HPEN bottomRightPen;
HBRUSH oldBrush;
HBRUSH faceBrush;
topLeftPen = CreatePen(PS_SOLID, 1, GetSysColor((out ? COLOR_BTNHIGHLIGHT : COLOR_BTNSHADOW)));
if (!topLeftPen)
return FALSE;
bottomRightPen = CreatePen(PS_SOLID, 1, GetSysColor((out ? COLOR_BTNSHADOW : COLOR_BTNHIGHLIGHT)));
if (!bottomRightPen)
{
DeleteObject(topLeftPen);
return FALSE;
}
faceBrush = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
if (!faceBrush)
{
DeleteObject(bottomRightPen);
DeleteObject(topLeftPen);
return FALSE;
}
oldPen = SelectObject(hdc, topLeftPen);
MoveToEx(hdc, left, bottom - 1, NULL);
LineTo(hdc, left, top);
LineTo(hdc, right - 1, top);
SelectObject(hdc, bottomRightPen);
MoveToEx(hdc, right - 1, top, NULL);
LineTo(hdc, right - 1, bottom - 1);
LineTo(hdc, left, bottom - 1);
SelectObject(hdc, GetStockObject(NULL_PEN));
oldBrush = SelectObject(hdc, faceBrush);
Rectangle(hdc, left + 1, top + 1, right, bottom);
SelectObject(hdc, oldBrush);
SelectObject(hdc, oldPen);
DeleteObject(faceBrush);
DeleteObject(bottomRightPen);
DeleteObject(topLeftPen);
return TRUE;
}
/**********************************************************************
*
* Draw a framed 3D rectangle.
*
**********************************************************************/
BOOL
FrameRect3D(HDC hdc, int left, int top, int right, int bottom, BOOL out)
{
HPEN oldPen;
HPEN topLeftPen;
HPEN bottomRightPen;
topLeftPen = CreatePen(PS_SOLID, 1, GetSysColor((out ? COLOR_BTNHIGHLIGHT : COLOR_BTNSHADOW)));
if (!topLeftPen)
return FALSE;
bottomRightPen = CreatePen(PS_SOLID, 1, GetSysColor((out ? COLOR_BTNSHADOW : COLOR_BTNHIGHLIGHT)));
if (!bottomRightPen)
{
DeleteObject(topLeftPen);
return FALSE;
}
oldPen = SelectObject(hdc, topLeftPen);
MoveToEx(hdc, left, bottom - 1, NULL);
LineTo(hdc, left, top);
LineTo(hdc, right - 1, top);
SelectObject(hdc, bottomRightPen);
MoveToEx(hdc, right - 1, top, NULL);
LineTo(hdc, right - 1, bottom - 1);
LineTo(hdc, left, bottom - 1);
SelectObject(hdc, oldPen);
DeleteObject(bottomRightPen);
DeleteObject(topLeftPen);
return TRUE;
}
/**********************************************************************
*
* End of file.
*
**********************************************************************/