Fixed bitblt test to use ReactOS build system.

svn path=/trunk/; revision=4592
This commit is contained in:
Steven Edwards 2003-04-26 21:37:09 +00:00
parent 8b4929f41e
commit 91316fff93
2 changed files with 34 additions and 85 deletions

View file

@ -1,20 +1,17 @@
// ------------------------------------------------------------------ /*
// Windows 2000 Graphics API Black Book * Windows 2000 Graphics API Black Book
// Chapter 1 - Listing 1.3 (BitBlt Bitmap Rendering Demo) * (BitBlt Bitmap Rendering Demo)
// *
// Created by Damon Chandler <dmc27@ee.cornell.edu> * Created by Damon Chandler <dmc27@ee.cornell.edu>
// Updates can be downloaded at: <www.coriolis.com> * Updates can be downloaded at: <www.coriolis.com>
// *
// Please do not hesistate to e-mail me at dmc27@ee.cornell.edu * Please do not hesistate to e-mail me at dmc27@ee.cornell.edu
// if you have any questions about this code. * if you have any questions about this code.
// ------------------------------------------------------------------ */
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#include <windows.h> #include <windows.h>
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
HINSTANCE HInst; HINSTANCE HInst;
const char* WndClassName = "GMainWnd"; const char* WndClassName = "GMainWnd";
@ -34,7 +31,8 @@ int APIENTRY WinMain(HINSTANCE HInstance, HINSTANCE HPrevInstance,
wc.lpfnWndProc = MainWndProc; wc.lpfnWndProc = MainWndProc;
wc.hInstance = HInstance; wc.hInstance = HInstance;
wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_BTNFACE + 1); /* wc.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_BTNFACE + 1); */
wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
wc.lpszClassName = WndClassName; wc.lpszClassName = WndClassName;
if (RegisterClass(&wc)) if (RegisterClass(&wc))
@ -63,10 +61,8 @@ int APIENTRY WinMain(HINSTANCE HInstance, HINSTANCE HPrevInstance,
} }
return 0; return 0;
} }
//------------------------------------------------------------------
/* image related */
// image related
BITMAP bmp; BITMAP bmp;
LPCSTR filename = TEXT("lena.bmp"); LPCSTR filename = TEXT("lena.bmp");
HDC HMemDC = NULL; HDC HMemDC = NULL;
@ -79,24 +75,24 @@ LRESULT CALLBACK MainWndProc(HWND HWnd, UINT Msg, WPARAM WParam,
{ {
case WM_CREATE: case WM_CREATE:
{ {
// create a memory DC /* create a memory DC */
HMemDC = CreateCompatibleDC(NULL); HMemDC = CreateCompatibleDC(NULL);
if (HMemDC) if (HMemDC)
{ {
// load a bitmap from file /* load a bitmap from file */
HBITMAP HBmp = HBITMAP HBmp =
static_cast<HBITMAP>( /* static_cast<HBITMAP> */(
LoadImage(HInst, filename, IMAGE_BITMAP, LoadImage(HInst, filename, IMAGE_BITMAP,
0, 0, LR_LOADFROMFILE) 0, 0, LR_LOADFROMFILE)
); );
if (HBmp) if (HBmp)
{ {
// extract dimensions of the bitmap /* extract dimensions of the bitmap */
GetObject(HBmp, sizeof(BITMAP), &bmp); GetObject(HBmp, sizeof(BITMAP), &bmp);
// associate the bitmap with the memory DC /* associate the bitmap with the memory DC */
HOldBmp = static_cast<HBITMAP>( /* HOldBmp = static_cast<HBITMAP> */
SelectObject(HMemDC, HBmp) (SelectObject(HMemDC, HBmp)
); );
} }
} }
@ -109,9 +105,9 @@ LRESULT CALLBACK MainWndProc(HWND HWnd, UINT Msg, WPARAM WParam,
try try
#endif #endif
{ {
//
// TODO: add palette support (see Chapter 9)... /* TODO: add palette support (see Chapter 9)... */
//
BitBlt(Hdc, 20, 15, BitBlt(Hdc, 20, 15,
bmp.bmWidth, bmp.bmHeight, bmp.bmWidth, bmp.bmHeight,
@ -129,7 +125,7 @@ LRESULT CALLBACK MainWndProc(HWND HWnd, UINT Msg, WPARAM WParam,
} }
case WM_DESTROY: case WM_DESTROY:
{ {
// clean up /* clean up */
DeleteObject(SelectObject(HMemDC, HOldBmp)); DeleteObject(SelectObject(HMemDC, HOldBmp));
DeleteDC(HMemDC); DeleteDC(HMemDC);
@ -139,4 +135,3 @@ LRESULT CALLBACK MainWndProc(HWND HWnd, UINT Msg, WPARAM WParam,
} }
return DefWindowProc(HWnd, Msg, WParam, LParam); return DefWindowProc(HWnd, Msg, WParam, LParam);
} }
//------------------------------------------------------------------

View file

@ -1,66 +1,20 @@
# Makefile - Proj_Listing1_5.dsp
ifndef CFG PATH_TO_TOP = ../../..
CFG=Proj_Listing1_5 - Win32 Debug
endif
CC=gcc
CFLAGS=
CXX=g++
CXXFLAGS=$(CFLAGS)
RC=windres -O COFF
ifeq "$(CFG)" "Proj_Listing1_5 - Win32 Release"
CFLAGS+=-fexceptions -O2 -DWIN32 -DNDEBUG -D_WINDOWS -D_MBCS -W
LD=$(CXX) $(CXXFLAGS)
LDFLAGS=
LDFLAGS+=-Wl,--subsystem,windows
LIBS+=-lkernel32 -luser32 -lgdi32
else
ifeq "$(CFG)" "Proj_Listing1_5 - Win32 Debug"
CFLAGS+=-fexceptions -g -O0 -DWIN32 -D_DEBUG -D_WINDOWS -D_MBCS -W
LD=$(CXX) $(CXXFLAGS)
LDFLAGS=
LDFLAGS+=-Wl,--subsystem,windows
LIBS+=-lkernel32 -luser32 -lgdi32
endif
endif
ifndef TARGET TARGET_NORC = yes
TARGET=bitblt.exe
endif
.PHONY: all TARGET_TYPE = program
all: $(TARGET)
%.o: %.c TARGET_APPTYPE = windows
$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
%.o: %.cpp TARGET_NAME = bitblt
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $@ -c $<
%.res: %.rc TARGET_SDKLIBS = kernel32.a gdi32.a
$(RC) $(CPPFLAGS) -o $@ -i $<
SOURCE_FILES= \ TARGET_OBJECTS = $(TARGET_NAME).o
bitblt.cpp
HEADER_FILES= include $(PATH_TO_TOP)/rules.mak
RESOURCE_FILES= include $(TOOLS_PATH)/helper.mk
SRCS=$(SOURCE_FILES) $(HEADER_FILES) $(RESOURCE_FILES)
OBJS=$(patsubst %.rc,%.res,$(patsubst %.cpp,%.o,$(patsubst %.c,%.o,$(filter %.c %.cpp %.rc,$(SRCS)))))
$(TARGET): $(OBJS)
$(LD) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
.PHONY: clean
clean:
-del $(OBJS) $(TARGET)
.PHONY: depends
depends:
-$(CXX) $(CXXFLAGS) $(CPPFLAGS) -MM $(filter %.c %.cpp,$(SRCS)) > Proj_Listing1_5.dep
-include Proj_Listing1_5.dep
# EOF