Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


No BMP


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 PsYcHoPrOg   Members   -  Reputation: 115

Like
Likes
Like

Posted 17 February 2000 - 12:29 PM

When I compiled the following, no bitmap came up, why?(I deliberately put my includes in quotes) #define WIN32_LEAN_AND_MEAN #include "windows.h" #include "windowsx.h" #include "stdio.h" #include "conio.h" #include "memory.h" #include "ddraw.h" HWND windowh = NULL; HINSTANCE instance= NULL; int GameInit(); int GameMain(); int GameEnd(); LPDIRECTDRAW lpdd = NULL; LPDIRECTDRAWSURFACE pbuff= NULL; LPDIRECTDRAWSURFACE bbuff= NULL; DDSCAPS ddcap; DDSURFACEDESC ddsd; DDBLTFX bltfx; HBITMAP hbm; HDC imagedc =NULL; HDC surfacedc =NULL; LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { PAINTSTRUCT ps; HDC hdc; switch(msg) { case WM_CREATE: { return(0); } break; case WM_PAINT: { hdc = BeginPaint(hwnd,&ps); EndPaint(hwnd,&ps); return(0); } break; case WM_DESTROY: { PostQuitMessage(0); return(0); } break; default:break; } return (DefWindowProc(hwnd, msg, wparam, lparam)); } int WINAPI WinMain( HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow) { WNDCLASSEX winclass; HWND hwnd; MSG msg; winclass.cbSize = sizeof(WNDCLASSEX); winclass.style = CS_DBLCLKS / CS_OWNDC / CS_HREDRAW / CS_VREDRAW; winclass.lpfnWndProc = WindowProc; winclass.cbClsExtra = 0; winclass.cbWndExtra = 0; winclass.hInstance = hinstance; winclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); winclass.hCursor = LoadCursor(NULL, IDC_ARROW); winclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); winclass.lpszMenuName = NULL; winclass.lpszClassName = "WINDOW_CLASS_NAME"; winclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION); instance = hinstance; if (!RegisterClassEx(&winclass)) return(0); if (!(hwnd = CreateWindowEx(NULL, "WINDOW_CLASS_NAME", "BlitEx", WS_POPUP / WS_VISIBLE, 0,0, 480,640, NULL, NULL, hinstance, NULL))) windowh = hwnd; GameInit(); while(TRUE) { if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { if (msg.message == WM_QUIT) break; TranslateMessage(&msg); DispatchMessage(&msg); } GameMain(); } GameEnd(); return(msg.wParam); } int GameInit() { if(FAILED(DirectDrawCreate(NULL, &lpdd, NULL))) { return(0); } if(FAILED(lpdd->SetCooperativeLevel(windowh, DDSCL_EXCLUSIVE/ DDSCL_FULLSCREEN/ DDSCL_ALLOWREBOOT))) { return(0); } if(FAILED(lpdd->SetDisplayMode(640, 480, 16))) { return(0); } memset(&ddsd, 0, sizeof(ddsd)); ddsd.dwSize =sizeof(ddsd); ddsd.dwFlags =DDSD_CAPS; ddsd.ddsCaps.dwCaps =DDSCAPS_PRIMARYSURFACE/DDSCAPS_FLIP; if(FAILED(lpdd->CreateSurface(&ddsd, &pbuff, NULL))) { return(0); } return(1); } int GameMain() { hbm =(HBITMAP)LoadImage(NULL, "Image.dib", IMAGE_BITMAP, ddsd.dwWidth, ddsd.dwHeight, LR_LOADFROMFILE/LR_CREATEDIBSECTION); imagedc = CreateCompatibleDC(NULL); SelectObject(imagedc, hbm); if(FAILED(pbuff->GetDC(&surfacedc))) { return(0); } if(BitBlt(surfacedc,0,0,ddsd.dwHeight, ddsd.dwWidth, imagedc, 0, 0, SRCCOPY) == FALSE) { return(0); } return(1); } int GameEnd() { if(imagedc) { pbuff->ReleaseDC(surfacedc); } if(imagedc) { DeleteObject(imagedc); } if(hbm) { DeleteObject(hbm); } if(pbuff) { pbuff->Release(); } if(lpdd) { lpdd->Release(); } return(1); } Games are the path to another dimension.

Sponsor:

#2 Pythius   Members   -  Reputation: 122

Like
Likes
Like

Posted 17 February 2000 - 07:03 PM

It''s generally not a good idea to load a bitmap EVERY CYCLE THROUGH YOUR MAIN LOOP. I think that''s your problem. Perhaps you could do something to move it to your Init? Anyway, happy coding and enjoy.

Pythius

#3 PsYcHoPrOg   Members   -  Reputation: 115

Like
Likes
Like

Posted 18 February 2000 - 12:40 AM

Thanks, I''ll try it and post up should that not work.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS