Page 2 of 2

Re: Directx10 Beginning!

Posted: Fri Oct 02, 2009 6:28 pm
by JaxDragon
It seems as though resource.h doesn't exist. Are you sure it's in your project's solution?

Re: Directx10 Beginning!

Posted: Fri Oct 02, 2009 8:50 pm
by cypher1554R
You've probably copied the project from Direct X SDK to your projects folder and file path changed. Try opening and compiling the one that's in your SDK folder.

Re: Directx10 Beginning!

Posted: Sun Oct 04, 2009 5:32 pm
by internetfx
EvolutionXEngine wrote:

Code: Select all

#include "resource.h"
Since you didn't create "resource.h" and it's shown with quotes, you can probably remove it. I believe their supplied code assumes you are compiling their project complete with resources, or have some default resource file with a header already in your project template.

Assuming you create a project as the previous poster stated, as Win32 and with the Empty Project turned on, this code will set up an "invisible" window that you can attach a full-screen DirectX to (ESC to exit). Replace "WS_EX_TOPMOST | WS_POPUP" with zero (0) and you'll see the window, but with no drawing updates.

Not entirely suitable as a realistic example, but this is the code shell that I have started with for game experimenting or for building full-screen animated show-off stuff (like what we do on a big-screen in our development office). For a project, this might be WinMain.cpp, but instead of the do-nothing application running here, I create an application object ( GameApp app(hInst, g_hWnd); ) that I design elsewhere, say GameApp.cpp (and .h), then tell it to run ( int status = app->run(); ), and the message loop happens in GameApp::run() instead.

Code: Select all

#include <windows.h>

LRESULT CALLBACK MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam );

//
//  Windows Main Entry Point
//

INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE hInstPrev, LPSTR lpCmdLine, INT nCmdShow)
{
	// Initialize COM
	CoInitializeEx(NULL, COINIT_MULTITHREADED);

	// Application instance handle
	//HINSTANCE hInstance = hInst;

	// Register the window class
	WNDCLASSEX wc;
	wc.cbSize =				sizeof(WNDCLASSEX);
	wc.style =				CS_HREDRAW | CS_VREDRAW;
	wc.lpfnWndProc =		MsgProc;
	wc.cbClsExtra =			0;
	wc.cbWndExtra =			0;
	wc.hIcon =				LoadIcon(NULL, IDI_APPLICATION);
	wc.hIconSm =			LoadIcon(NULL, IDI_APPLICATION);
	wc.hCursor =			LoadCursor(NULL, IDC_ARROW);
	wc.hbrBackground =		NULL;
	wc.lpszMenuName =		NULL;
	wc.lpszClassName =		L"DirectX Application";
	wc.hInstance =			hInst;

	RegisterClassEx( &wc );
	
	// Create the application's window
	HWND g_hWnd = CreateWindowW( wc.lpszClassName, TEXT("DirectX Application"),
						   WS_EX_TOPMOST | WS_POPUP, 200, 200, 600, 200,
						   NULL, NULL, wc.hInstance, NULL );

	// Show the window
	ShowWindow(g_hWnd, nCmdShow);
	UpdateWindow(g_hWnd);

	// Initialize DirectX and run your application here (minimal do-nothing code supplied)
	int status = S_OK;

	MSG msg;
	msg.message = WM_NULL;

	while (msg.message != WM_QUIT)
	{
		if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
		else
		{
			//  Game timers, logic and drawing
		}
	}

	// Unregister the window class
	UnregisterClass( wc.lpszClassName, wc.hInstance );

	// Release COM
	CoUninitialize();

	return status;
}

//
//  Windows Message Processor
//

LRESULT CALLBACK MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{

    switch( msg )
    {
        case WM_DESTROY:
			{
				PostQuitMessage( 0 );
	            return 0;
			}
		case WM_KEYDOWN:
			{
				if (wParam == VK_ESCAPE)
					DestroyWindow(hWnd);
				return 0;
			}
    }

    return DefWindowProc( hWnd, msg, wParam, lParam );
}

Re: Directx10 Beginning!

Posted: Mon Oct 05, 2009 12:07 pm
by EvolutionXEngine
OMG i got it to work .. you guys where right .. I didn't know what was Projects/Solutions.. to open Tutorial00.cpp i first had to open Project Tutorial00.(something lol) and then execute.. My heart started pumping fast and that "window" made my day.. Thanks Guys .. Im going to continue reading my book!

By the way. do you know about a good tutorial about sending MSG <--- or something like that.. Would the analogy be like real life mail sending and receiving or data packets being send in a network? Sorry if i confused you.. lol :lol: :mrgreen: :bow:

Re: Directx10 Beginning!

Posted: Mon Oct 05, 2009 12:51 pm
by Netwatcher
EvolutionXEngine wrote:OMG i got it to work .. you guys where right .. I didn't know what was Projects/Solutions.. to open Tutorial00.cpp i first had to open Project Tutorial00.(something lol) and then execute.. My heart started pumping fast and that "window" made my day.. Thanks Guys .. Im going to continue reading my book!

By the way. do you know about a good tutorial about sending MSG <--- or something like that.. Would the analogy be like real life mail sending and receiving or data packets being send in a network? Sorry if i confused you.. lol :lol: :mrgreen: :bow:
hmm, think of it as a brain.
You just put your left hand over a flame, your brain receives an electrical signal from nerves your left hand, translates it to something like "Nerves in the left hand are recieving ;arge amounts of heat".
which makes your brain tell you to start feeling pain in your left hand or whatnot.

Re: Directx10 Beginning!

Posted: Mon Oct 05, 2009 4:46 pm
by cypher1554R
EvolutionXEngine wrote:OMG i got it to work .. you guys where right .. I didn't know what was Projects/Solutions.. to open Tutorial00.cpp i first had to open Project Tutorial00.(something lol) and then execute.. My heart started pumping fast and that "window" made my day.. Thanks Guys .. Im going to continue reading my book!

By the way. do you know about a good tutorial about sending MSG <--- or something like that.. Would the analogy be like real life mail sending and receiving or data packets being send in a network? Sorry if i confused you.. lol :lol: :mrgreen: :bow:
This is where I started my Win32 API learning: http://winprog.org/tutorial/start.html

The messages are used to control your WndProc() function's flow according to user input.
Example: If you use your mouse to change the window size, windows will send WM_SIZE message to your application, and you can "switch(message)" and use "case WM_SIZE: //do something" inside your WndProc() to tell what happens when user changes window size.

Re: Directx10 Beginning!

Posted: Thu Jan 07, 2010 10:07 pm
by Automagician23
And when you start using DX, as long as you don't receive a WM_QUIT message, usually you will just call the game loop from inside WinMain and do whatever you want to do as far as gameplay and drawing.