Directx10 Beginning!
Moderator: PC Supremacists
-
- Chaos Rift Newbie
- Posts: 12
- Joined: Mon Feb 02, 2009 8:13 pm
Directx10 Beginning!
I started learning how to use the Directx10 API, but im having trouble setting up the D3Dx10, etc device. I saw in a youtube video where this guy uses the <window.h> to make the window. Then he makes another program to link the Directx 10 device, such as the back buffer, rendering and swap chains.
Also i am a noob in using Microsoft Visual C++ 2008 but managed to add the libaries and include files in to the directories. Yet i program a simple input/ output program and in won't execute. I've looked up the code snippet for the Directx 10 device and setup the window from Microsoft forums and other forums but yet im having trouble executing. So explaining what the code does is not useful because i have read so many forums that is just getting confussing, atleast from the window programming. So please tell me whats wrong with my complier and how to make everything work. That way i will study the code and see how it works. I know i would be a disapointment for many but i am just frustrated that i can get the right tutorial. A code snippet would be helpful and thank you!
Also i am a noob in using Microsoft Visual C++ 2008 but managed to add the libaries and include files in to the directories. Yet i program a simple input/ output program and in won't execute. I've looked up the code snippet for the Directx 10 device and setup the window from Microsoft forums and other forums but yet im having trouble executing. So explaining what the code does is not useful because i have read so many forums that is just getting confussing, atleast from the window programming. So please tell me whats wrong with my complier and how to make everything work. That way i will study the code and see how it works. I know i would be a disapointment for many but i am just frustrated that i can get the right tutorial. A code snippet would be helpful and thank you!
- Netwatcher
- 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!
Can you show us what you've got so-far(code)?
also are you going to use it with more then one frame(or buffer, w/e you wanna call em), will you use it to render mainly 2D or 3D?
I'm familier with DX9, though I don't think there's much difference in the setup I will try to help my best.
Edit:
check this out http://takinginitiative.wordpress.com/2 ... 10-device/
this is how i set up my Windows part of the application.
also are you going to use it with more then one frame(or buffer, w/e you wanna call em), will you use it to render mainly 2D or 3D?
I'm familier with DX9, though I don't think there's much difference in the setup I will try to help my best.
Edit:
check this out http://takinginitiative.wordpress.com/2 ... 10-device/
this is how i set up my Windows part of the application.
Code: Select all
LRESULT WINAPI WinProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
switch( msg )
{
case WM_DESTROY:
//release the Direct3D objects
if (d3ddev != NULL) d3ddev->Release();
if (d3d != NULL) d3d->Release();
//release sound objects (not a DX object!)
if (dsound != NULL) delete dsound;
//release input objects
if (dinput != NULL) dinput->Release();
Kill_Keyboard();
Kill_Mouse();
//Release all the nasty shit
Game_End(hWnd);
//Send a message to kill the program
PostQuitMessage(0);
return 0;
/*
case WM_ACTIVATE:
switch(wParam)
{
case WA_CLICKACTIVE:
active=true;
Resume(hwnd);
break;
case WA_ACTIVE:
if(!active)
Resume(hwnd);
break;
case WA_INACTIVE:
active=false;
break;
}*/
/* case WM_MOUSEMOVE:
absMouseX = GET_X_LPARAM(lParam);
absMouseY = GET_Y_LPARAM(lParam);
break;*/
}
return DefWindowProc( hWnd, msg, wParam, lParam );
}
//helper function to set up the window properties
ATOM MyRegisterClass(HINSTANCE hInstance)
{
//create the window class structure
WNDCLASSEX wc;
wc.cbSize = sizeof(WNDCLASSEX);
//fill the struct with info
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = (WNDPROC)WinProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(hInstance,MAKEINTRESOURCE(2));
wc.hIconSm = LoadIcon(wc.hInstance,MAKEINTRESOURCE(2));
wc.hCursor = LoadCursor(NULL, IDC_HAND);
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = APPTITLE;
wc.hIconSm = NULL;
//set up the window with the class info
return RegisterClassEx(&wc);
}
//entry point for a Windows program
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
MSG msg;
HWND hWnd;
// register the class
MyRegisterClass(hInstance);
//SCREENMODE is 1 or 0, windowed or fullscreen
DWORD style;
if (SCREENMODE)
style = WS_EX_TOPMOST | WS_VISIBLE | WS_POPUP;
else
style = WS_OVERLAPPED;
//create a new window
hWnd = CreateWindow(
APPTITLE, //window class
APPTITLE, //title bar
style, //window style
0, //x position of window
0, //y position of window
SCREEN_WIDTH, //width of the window
SCREEN_HEIGHT, //height of the window
NULL, //parent window
NULL, //menu
hInstance, //application instance
NULL); //window parameters
//was there an error creating the window?
if (!hWnd)
return FALSE;
//display the window
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
//initialize Direct3D
if (!Init_Direct3D(hWnd, SCREEN_WIDTH, SCREEN_HEIGHT, SCREENMODE))
{
MessageBox(hWnd, "Error initializing Direct3D", "Error", MB_OK);
return 0;
}
//initialize DirectSound
if (!Init_DirectSound(hWnd))
{
MessageBox(hWnd, "Error initializing DirectSound", "Error", MB_OK);
return 0;
}
//initialize DirectInput
if (!Init_DirectInput(hWnd))
{
MessageBox(hWnd, "Error initializing DirectInput", "Error", MB_OK);
return 0;
}
//initialize the game
if (!Game_Init(hWnd))
{
MessageBox(hWnd, "Error initializing the game", "Error", MB_OK);
return 0;
}
// main message loop
int done = 0;
while (!done)
{
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
//look for quit message
if (msg.message == WM_QUIT)
done = 1;
//decode and pass messages on to WndProc
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
//Run the game loop
Game_Run(hWnd);
}
}
return msg.wParam;
}
"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/
-Derek Powazek, http://powazek.com/posts/1655
blip.fm DJ profile - http://blip.fm/Noobay
current code project http://sourceforge.net/projects/vulcanengine/
-
- Chaos Rift Newbie
- Posts: 12
- Joined: Mon Feb 02, 2009 8:13 pm
Re: Directx10 Beginning!
Well, that's the thing. I don't have actual code that i can show you. I've been trying that same code you posted which is the MAIN WINDOW, but I'm having trouble with Visual C++ 2008. When i use the DevC++ IDE it executes the window with no problem, but doesn't work with directx 10. I believe that maybe is a setting that has to be changed in the Visual C++ complier. I'm mainly going to be rendering in 3D, but would like to do some 2D work! Thank You NetWatcher for your help and i guess i have to keep searching.
Check this Website: http://www.codeproject.com/KB/directx/ ... 0-device/
Check this Website: http://www.codeproject.com/KB/directx/ ... 0-device/
- MarauderIIC
- Respected Programmer
- Posts: 3406
- Joined: Sat Jul 10, 2004 3:05 pm
- Location: Maryland, USA
Re: Directx10 Beginning!
Good luck. I don't think there are many DX folks around here. Feel free to post a list of your resources and update it as you find more.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
- Netwatcher
- 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!
If you've looked everywhere and can't figure it out you can do one of two things.
A.)
Look at the DirectX SDK documentation, found at-
[url]C:\Program Files\Microsoft DirectX SDK (August 2009)\Documentation\DirectX\directx_sdk.chm[/url]
(depends on where you installed it and what SDK version you have, I put August 2009 because it is the latest and is probably what you're using)
from the Content tree go down to "DirectX graphics", open "Direct3D 10" then go to "tutorials and samples", everything you need is there;
it tells you how to setup the window, the device and pretty much everything you need!
*note- I marked "programming guide" in red for no reason, opening it won't help anything :p
B.)
if all else fails, buy a book.
I'd recommend Beginning DirectX 10 Game Programming
C.) comes after B but before D.
-cheers,
hope it helped
A.)
Look at the DirectX SDK documentation, found at-
[url]C:\Program Files\Microsoft DirectX SDK (August 2009)\Documentation\DirectX\directx_sdk.chm[/url]
(depends on where you installed it and what SDK version you have, I put August 2009 because it is the latest and is probably what you're using)
from the Content tree go down to "DirectX graphics", open "Direct3D 10" then go to "tutorials and samples", everything you need is there;
it tells you how to setup the window, the device and pretty much everything you need!
*note- I marked "programming guide" in red for no reason, opening it won't help anything :p
B.)
if all else fails, buy a book.
I'd recommend Beginning DirectX 10 Game Programming
C.) comes after B but before D.
-cheers,
hope it helped
"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/
-Derek Powazek, http://powazek.com/posts/1655
blip.fm DJ profile - http://blip.fm/Noobay
current code project http://sourceforge.net/projects/vulcanengine/
- Spikey
- Chaos Rift Cool Newbie
- Posts: 98
- Joined: Sat Dec 13, 2008 6:39 am
- Programming Language of Choice: C++
- Location: Ottawa, Canada
- Contact:
Re: Directx10 Beginning!
Actually I'm studying DirectX 9.0c right now, reading 3D Game Programming with Direct X 9.0c: A Shader Approach
You can google tons of resources, also the SDK comes with documentation. Like Netwatcher said, if all else fails, buy a book. The included cd will come with examples you can work with.
You can google tons of resources, also the SDK comes with documentation. Like Netwatcher said, if all else fails, buy a book. The included cd will come with examples you can work with.
-
- Chaos Rift Newbie
- Posts: 12
- Joined: Mon Feb 02, 2009 8:13 pm
Re: Directx10 Beginning!
Thanks but is the exact same code that i reviewed in Microsoft Tutorials. I will read more in detail and i downloaded the newer version of Directx10 book.
Introduction to 3D Game Programming with DirectX 10
by Frank D. Luna
is a good book but right now im covering the vectors so doesn't really tell me how to setup everything.
You know what. thank you so much. You did everything in your power to help and i am thankful for that. i will read some more to see what happens.
Would any of you know how to setup Microsoft Visual C++ 2008. i think thats where the problem is... i haven't been able to comply even the simplest small program but i can with DevC++ (Bloodshed) but DevC++ doesn't work with directx10... Thanks again!
Introduction to 3D Game Programming with DirectX 10
by Frank D. Luna
is a good book but right now im covering the vectors so doesn't really tell me how to setup everything.
You know what. thank you so much. You did everything in your power to help and i am thankful for that. i will read some more to see what happens.
Would any of you know how to setup Microsoft Visual C++ 2008. i think thats where the problem is... i haven't been able to comply even the simplest small program but i can with DevC++ (Bloodshed) but DevC++ doesn't work with directx10... Thanks again!
-
- Chaos Rift Newbie
- Posts: 11
- Joined: Mon Sep 28, 2009 1:11 am
Re: Directx10 Beginning!
That is a good book to study and get started with.EvolutionXEngine wrote:Introduction to 3D Game Programming with DirectX 10
by Frank D. Luna
Frank Luna's book on DirectX9 was pretty good, then he came out with the Shader Approach... which was odd because he kept the same material, but made a complete departure from the built-in pipeline without really any mention of it. So it was right into shader vertex declarations right in the middle of setting up your first polygon. Overall, though, it's probably the simplest out there.
I have admittedly not touched DirectX10, but in that right, don't be afraid to look up DirectX9 examples online. You'll find many more of those.
If you get stuck, I know I have a simple "shell" of code that simply initializes DirectX9 and presents a black screen in full screen mode matching your desktop resolution on your main display. I'm sure it takes a bit of modification to migrate that to DirectX10 (more than changing 9's to 10's...). I think I added an XBOX gamepad input class, and keyboard and mouse, and a simple sound engine based on DXUT. Haven't tried it in DirectX10... too "busy".
-
- Chaos Rift Newbie
- Posts: 12
- Joined: Mon Feb 02, 2009 8:13 pm
Re: Directx10 Beginning!
I think i might have found the problem! I believe you have to do something with "project" > Confuguration Properties>Linker>Input and in the Additional Dependencies field. I heard that you suppose to do this for every project that you do in Microsoft Visual C++. Would this be after you add all the libaries and include files to the directory? maybe that's why is not executing.
I let you know if it works or not when i get home. lol im at college!
I HOPE THIS WORKS!
I let you know if it works or not when i get home. lol im at college!
I HOPE THIS WORKS!
- Netwatcher
- 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!
you can also do this(write at the beginning of your code)
example
Code: Select all
#pragma comment (lib, "NameOfLib")
Code: Select all
#pragma comment(lib,"d9dx.lib")
Last edited by Netwatcher on Thu Oct 01, 2009 4:01 pm, edited 2 times in total.
"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/
-Derek Powazek, http://powazek.com/posts/1655
blip.fm DJ profile - http://blip.fm/Noobay
current code project http://sourceforge.net/projects/vulcanengine/
- cypher1554R
- Chaos Rift Demigod
- Posts: 1124
- Joined: Sun Jun 22, 2008 5:06 pm
Re: Directx10 Beginning!
Yes, you have to link the static library in order to compile..EvolutionXEngine wrote:I think i might have found the problem! I believe you have to do something with "project" > Confuguration Properties>Linker>Input and in the Additional Dependencies field. I heard that you suppose to do this for every project that you do in Microsoft Visual C++. Would this be after you add all the libaries and include files to the directory? maybe that's why is not executing.
I let you know if it works or not when i get home. lol im at college!
I HOPE THIS WORKS!
"project" > Configuration Properties>Linker>Input (and write library names inside separated with space: "d3d9.lib d3dx9.lib" <- I think those are the right names)
You have to say what kind of errors you're getting in order to get help. (and sometimes code, when necessary)
-
- Chaos Rift Newbie
- Posts: 12
- Joined: Mon Feb 02, 2009 8:13 pm
Re: Directx10 Beginning!
Do i have to the same thing to just execute a "Window" You see in the Directx 10 folder contains tutorials like you guys mention and, Tutorial 00 is just the create a "window" a simple window and i cant execute... Why cant i execute a window...?
- cypher1554R
- Chaos Rift Demigod
- Posts: 1124
- Joined: Sun Jun 22, 2008 5:06 pm
Re: Directx10 Beginning!
Like I said,
cypher1554R wrote:You have to say what kind of errors you're getting in order to get help. (and sometimes code, when necessary)
- Netwatcher
- 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!
When you create the new project for the window using Microsoft Visual C++ go to File->New->Project-> there will be a tree-list of templates, look for Win32, click it,EvolutionXEngine wrote:Do i have to the same thing to just execute a "Window" You see in the Directx 10 folder contains tutorials like you guys mention and, Tutorial 00 is just the create a "window" a simple window and i cant execute... Why cant i execute a window...?
then you will have two options, "Win32 Console Application" and "Win32 Project", pick the "Win32 Project",
now enter a name for your new project, click next.
Now, a window would pop with the title "Win32 Application wizard - "NameOfProject"-
Make sure "Windows Application" is checked, look down and see the label "Additional Options", Check the "Empty Project" box and click on "Finish" to create the project.
Now to create a new source look for the Solution Explorer, where there are the "Header FIles", "Resource Files" and "Source Files" folders in a tree-view list, then simply right click any of the folders, then choose "Add"->"New Item" pick C++ File(.cpp) and you're good to go.
"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/
-Derek Powazek, http://powazek.com/posts/1655
blip.fm DJ profile - http://blip.fm/Noobay
current code project http://sourceforge.net/projects/vulcanengine/
-
- Chaos Rift Newbie
- Posts: 12
- Joined: Mon Feb 02, 2009 8:13 pm
Re: Directx10 Beginning!
Code: Select all
//--------------------------------------------------------------------------------------
// File: Tutorial00.cpp
//
// This tutorial sets up a windows application with a window and a message pump
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//--------------------------------------------------------------------------------------
#include <windows.h>
#include "resource.h"
//--------------------------------------------------------------------------------------
// Global Variables
//--------------------------------------------------------------------------------------
HINSTANCE g_hInst = NULL;
HWND g_hWnd = NULL;
//--------------------------------------------------------------------------------------
// Forward declarations
//--------------------------------------------------------------------------------------
HRESULT InitWindow( HINSTANCE hInstance, int nCmdShow );
LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM );
//--------------------------------------------------------------------------------------
// Entry point to the program. Initializes everything and goes into a message processing
// loop. Idle time is used to render the scene.
//--------------------------------------------------------------------------------------
int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow )
{
if( FAILED( InitWindow( hInstance, nCmdShow ) ) )
return 0;
// Main message loop
MSG msg = {0};
while( GetMessage( &msg, NULL, 0, 0 ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
return ( int )msg.wParam;
}
//--------------------------------------------------------------------------------------
// Register class and create window
//--------------------------------------------------------------------------------------
HRESULT InitWindow( HINSTANCE hInstance, int nCmdShow )
{
// Register class
WNDCLASSEX wcex;
wcex.cbSize = sizeof( WNDCLASSEX );
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon( hInstance, ( LPCTSTR )IDI_TUTORIAL1 );
wcex.hCursor = LoadCursor( NULL, IDC_ARROW );
wcex.hbrBackground = ( HBRUSH )( COLOR_WINDOW + 1 );
wcex.lpszMenuName = NULL;
wcex.lpszClassName = L"TutorialWindowClass";
wcex.hIconSm = LoadIcon( wcex.hInstance, ( LPCTSTR )IDI_TUTORIAL1 );
if( !RegisterClassEx( &wcex ) )
return E_FAIL;
// Create window
g_hInst = hInstance;
RECT rc = { 0, 0, 640, 480 };
AdjustWindowRect( &rc, WS_OVERLAPPEDWINDOW, FALSE );
g_hWnd = CreateWindow( L"TutorialWindowClass", L"Direct3D 10 Tutorial 0: Setting Up Window", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, rc.right - rc.left, rc.bottom - rc.top, NULL, NULL, hInstance,
NULL );
if( !g_hWnd )
return E_FAIL;
ShowWindow( g_hWnd, nCmdShow );
return S_OK;
}
//--------------------------------------------------------------------------------------
// Called every time the application receives a message
//--------------------------------------------------------------------------------------
LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
PAINTSTRUCT ps;
HDC hdc;
switch( message )
{
case WM_PAINT:
hdc = BeginPaint( hWnd, &ps );
EndPaint( hWnd, &ps );
break;
case WM_DESTROY:
PostQuitMessage( 0 );
break;
default:
return DefWindowProc( hWnd, message, wParam, lParam );
}
return 0;
}
1>Compiling...
1>main.cpp
1>c:\users\Erick\documents\visual studio 2008\projects\massivedynamics\massivedynamics\main.cpp(9) : fatal error C1083: Cannot open include file: 'resource.h': No such file or directory
1>Build log was saved at "file://c:\Users\Erick\Documents\Visual Studio 2008\Projects\MassiveDynamics\MassiveDynamics\Debug\BuildLog.htm"
1>MassiveDynamics - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Like i mention, i tried to execute a simple window! i get the error above. This is Tutorial 00 from DirectX10! I linked all the static libraries and followed your instructions but it will not execute.... Do you have to link the Windows API too? just to make a simple window?