• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Archived

This topic is now archived and is closed to further replies.

PsYcHoPrOg

MY WINDOW!! WHAT?

7 posts in this topic

When I ran this program, no window came up. Why? Here''s the code(long) #define WIN32_LEAN_AND_MEAN #include #include #include #include #include #include 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); } default:break; } return(DefWindowProc(hwnd, msg, wparam, lparam)); } int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int nshowcmd) { HDC hdc; HWND hwnd; WNDCLASSEX wc; PAINTSTRUCT ps; MSG msg; wc.style =CS_DBLCLKS/CS_OWNDC/ CS_HREDRAW/CS_VREDRAW; wc.cbSize =sizeof(WNDCLASSEX); wc.cbClsExtra =0; wc.cbWndExtra =0; wc.hbrBackground =(HBRUSH)GetStockObject(BLACK_BRUSH); wc.hCursor =LoadCursor(NULL, IDC_ARROW); wc.hIcon =LoadIcon(NULL, IDI_APPLICATION); wc.hIconSm =LoadIcon(NULL, IDI_APPLICATION); wc.hInstance =hinstance; wc.lpfnWndProc =WindowProc; wc.lpszClassName ="wc"; wc.lpszMenuName =NULL; if(!RegisterClassEx(&wc)) return(0); if(!(CreateWindowEx(NULL, "WINDOWCLASS", "BLTEX", WS_OVERLAPPEDWINDOW/WS_VISIBLE, 0, 0,640, 480, NULL, NULL, hinstance, NULL))) { return(0); } ShowCursor(FALSE); instance = hinstance; windowh = hwnd; GameInit(); while(1) { if(PeekMessage(&msg, hwnd, 0, 0, PM_REMOVE)) { if(msg.message == WM_QUIT) break; GameMain(); TranslateMessage(&msg); DispatchMessage(&msg); } } 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); } ddsd.dwSize =sizeof(ddsd); ddsd.dwFlags =DDSD_CAPS/DDSD_BACKBUFFERCOUNT; ddsd.dwBackBufferCount =1; ddsd.ddsCaps.dwCaps =DDSCAPS_BACKBUFFER; if(FAILED(pbuff->GetAttachedSurface(&ddcap, &bbuff))) { return(0); } return(1); } int GameMain() { if(FAILED(bbuff->GetSurfaceDesc(&ddsd))) { return(0); } hbm =(HBITMAP)LoadImage(NULL, "Image.bmp", IMAGE_BITMAP, ddsd.dwWidth, ddsd.dwHeight, LR_LOADFROMFILE/LR_CREATEDIBSECTION); imagedc = CreateCompatibleDC(NULL); SelectObject(imagedc, hbm); if(FAILED(bbuff->GetDC(&surfacedc))) { return(0); } if(BitBlt(surfacedc,0,0,ddsd.dwHeight, ddsd.dwWidth, imagedc, 0, 0, SRCCOPY) == FALSE) { return(0); } if(FAILED(pbuff->Flip(NULL, DDFLIP_WAIT))) { return(0); } return(1); } int GameEnd() { if(imagedc) { bbuff->ReleaseDC(imagedc); } if(imagedc) { DeleteDC(imagedc); } if(hbm) { DeleteObject(hbm); } if(pbuff) { pbuff->Release(); } if(bbuff) { bbuff->Release(); } if(lpdd) { lpdd->Release(); } return(1); } Games are the path to another dimension.
0

Share this post


Link to post
Share on other sites
I believe your missing a call to ShowWindow (put it right before ShowCursor).

--TheGoop
0

Share this post


Link to post
Share on other sites
now I have another problem, my window shows, but now, the bitmap doesn''t show, what''s wrong? Here''s the code(long and the includes are in quotes for HTML:


#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;
char buffer[80];


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;
HDC hdc;


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.bmp", 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(imagedc);
}
if(imagedc)
{
DeleteDC(imagedc);
}
if(hbm)
{
DeleteObject(hbm);
}
if(pbuff)
{
pbuff->Release();
}

if(lpdd)
{
lpdd->Release();
}
return(1);
}

0

Share this post


Link to post
Share on other sites
Hey! I''ve read 3 books on the subject, so don''t give me that! I don''t know what''s wrong, I''ve done it before, but this time, I have no Idea what''s wrong! I find that comment extremely offensive!
0

Share this post


Link to post
Share on other sites
I''m not entirely sure why it doesn''t display your bitmap, but I can make a few suggestions (other than "lose the attitude", which seems to apply to your last post).

GameMain is called repeatedly, isn''t it? It certainly looks like it will be caused each time the program polls the message loop. If thats the case, why are you loading a bitmap from a file for every single frame??? Even if there is nothing wrong with your code, thats amazingly inefficient. It would make more sense to load the bitmap into a surface in GameInit, and then use DirectDraw''s Blt command to put it into the back buffer.

You spend quite a bit of time returning different values from GameMain - but you never even check them. You could make your debugging a whole lot easier if you actually trap the error codes you are generating........
0

Share this post


Link to post
Share on other sites