Directx10 Beginning!

Anything related in any way to game development as a whole is welcome here. Tell us about your game, grace us with your project, show us your new YouTube video, etc.

Moderator: PC Supremacists

User avatar
JaxDragon
Chaos Rift Junior
Chaos Rift Junior
Posts: 395
Joined: Mon Aug 04, 2008 2:03 pm
Current Project: Kanoba Engine
Favorite Gaming Platforms: PS3, PC
Programming Language of Choice: C++
Location: Northeast NC

Re: Directx10 Beginning!

Post by JaxDragon »

It seems as though resource.h doesn't exist. Are you sure it's in your project's solution?
User avatar
cypher1554R
Chaos Rift Demigod
Chaos Rift Demigod
Posts: 1124
Joined: Sun Jun 22, 2008 5:06 pm

Re: Directx10 Beginning!

Post 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.
internetfx
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 11
Joined: Mon Sep 28, 2009 1:11 am

Re: Directx10 Beginning!

Post 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 );
}
EvolutionXEngine
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 12
Joined: Mon Feb 02, 2009 8:13 pm

Re: Directx10 Beginning!

Post 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:
User avatar
Netwatcher
Chaos Rift Junior
Chaos Rift Junior
Posts: 378
Joined: Sun Jun 07, 2009 2:49 am
Current Project: The Awesome Game (Actual title)
Favorite Gaming Platforms: Cabbage, Ground beef
Programming Language of Choice: C++
Location: Rehovot, Israel

Re: Directx10 Beginning!

Post 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.
"Programmers are the Gods of their tiny worlds. They create something out of nothing. In their command-line universe, they say when it’s sunny and when it rains. And the tiny universe complies."
-Derek Powazek, http://powazek.com/posts/1655

blip.fm DJ profile - http://blip.fm/Noobay
current code project http://sourceforge.net/projects/vulcanengine/
User avatar
cypher1554R
Chaos Rift Demigod
Chaos Rift Demigod
Posts: 1124
Joined: Sun Jun 22, 2008 5:06 pm

Re: Directx10 Beginning!

Post 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.
User avatar
Automagician23
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 3
Joined: Tue Jan 05, 2010 9:40 pm
Current Project: Making a pokemon remake for no reason whatsoever
Favorite Gaming Platforms: 360, PC
Programming Language of Choice: c/c++ && c#
Location: Philadelphia, PA

Re: Directx10 Beginning!

Post 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.
The answer to life's problems isn't more useless gadgets, It's more useless features and fewer usable gadgets.
Post Reply