Sign in to follow this  
GlitchGuy2

[D3D] No window appears

Recommended Posts

Kay, I'm a newb at DirectX and I'm trying to learn DirectX9 programming. Unfortunately any of my Win32 applications are compiling and running, but nothing shows up.
/************************************/
/*            CRYSTAL BOND          */
/*************            ***********/
/*       DirectX game built by      */
/**     Glitch Softwares Studios   **/
/************************************/

//Include important files
#include <windows.h>
#include <windowsx.h>
#include <d3d9.h>

#include "functions.h"

//Include Direct3D Library
#pragma comment (lib, "d3d9.lib")

//Include files specifically for this game
#include "functions.h"

//Prototype of CALLBACK
LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);

// the entry point for any Windows program
int WINAPI WinMain(HINSTANCE hInstance,
                   HINSTANCE hPrevInstance,
                   LPSTR lpCmdLine,
                   int nCmdShow)
{
	HWND hWnd;

	WNDCLASSEX wc;
		//Clear windows for use
	ZeroMemory(&wc, sizeof(WNDCLASSEX));

	//Build structure with information
	wc.cbSize = sizeof(WNDCLASSEX);
	wc.style = CS_HREDRAW | CS_VREDRAW;
	wc.lpfnWndProc = WindowProc;
    wc.hInstance = hInstance;
    wc.hCursor = LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
    wc.lpszClassName = L"WindowClass";

	//Make the Windows Program
	hWnd = CreateWindowEx(NULL,
						L"WindowClass",				//Class name
						L"Crystal Bond",			//Window Caption
						WS_OVERLAPPEDWINDOW,		//Style
						5,							//X Start
						5,							//Y Start
						645,						//Width
						485,						//Height
						NULL,					//Parent Window
						NULL,					//Menus
						hInstance,				//Application handle
						NULL);					//Use with multiple windows

	//Make window visible
	ShowWindow(hWnd, nCmdShow);

	initD3D(hWnd);

	MSG resp;	//Create the structure to communicate the user input

	while(GetMessage(&resp,NULL,0,0))
	{
		TranslateMessage(&resp);	//Translate input to machine's language

		DispatchMessage(&resp);		//Send message to be processed.
	}
	return resp.wParam;

	while(true)
	{
		// Check to see if any messages are waiting in the queue
		while(PeekMessage(&resp, NULL, 0, 0, PM_REMOVE))
		{
			// Translate the message and dispatch it to WindowProc()
			TranslateMessage(&resp);
			DispatchMessage(&resp);
		}

		// If the message is WM_QUIT, exit the while loop
		if(resp.message == WM_QUIT)
			break;
		renderFrame();
	}
	cleanD3D();
}

LRESULT CALLBACK WindowProc(HWND hWnd,
							UINT message,
							WPARAM wParam,
							LPARAM lParam)
{
	//Look for what to do at message recieved
	switch(message)
	{
		//Message says: Close the program and window
	case WM_DESTROY:
		{PostQuitMessage(0);return 0;}break;
	}
	//Else, and nothing was supported in SWITCH
	return DefWindowProc(hWnd, message, wParam, lParam);
}


As I said, I'm new to the DirectX world, don't worry about things like cleanD3D(), as those are declared in one of my headers. Thanks in advanced. It'd be nice to get something of my own to work -_-'

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this