Jump to content
  • Advertisement
Sign in to follow this  
Mikie

OpenGL Issues with DirectX SDK and VS C++

This topic is 4828 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everyone! This is my first post here after many visits and quite a lot time spent reading the stacks of info available - great stuff! I'm fairly new to DirectX and, although I have used some Win32 GDI/MFX and a wee bit of SDL and OpenGl previously, I'm having some fundamental problems understanding what's going on! Tech Background: Windows XP sp2, Visual Studio C++ 6.0 sp5, DirectX 9c (as reported by DX tools), NON-DirectX 9 video card (actually its a soon-to-be-upgraded (i.e. junk) SIS305 card. 1st: Can I start with the DX9 SDK? As always before I plunge into programming on a new platform I try out sample code supplied, so I tried all the samples/demos that come with the SDK - all went well if sometimes extremely slowly (the junk gfx card) but they all worked - EXCEPT Donuts 4 demo. Now, I had the original DX9 SDK installed ages ago and everything worked fine back then even Donuts. I upgraded to 9.0c just a few months ago and now all that happens is... nothing. The PC reports heavy processor usage for about 5 secs and then stops - the Donut process kicks off then quits almost immediately with no error messages etc. Why?! 2nd: I have acquired several books on Direct X programming some of which are based on DX9 and some on DX8 - I had to buy second hand and got given a couple by friends in the business (I have an almost non-existant budget - thank you Ebay!). So what's the problem? Well - mostly things are OK, for DX9 the basics seem fine and the source supplied with the books (if I was lucky enough to get the CD too, otherwise I have to key it all in) mostly work but for one book "Strategy Game Programming with DirectX 9.0" I'm having all sorts of probs. Some of the precompile samples work just fine and others do the same as Donuts ie nothing, well not quite - at least now a window flashs up for a fraction of second then disappears again. Why?! I've tried compiling some the ones that don't work but with mixed results... point 3 3rd: Regarding DX9 - as I've said I have DX9.0c installed and when I try to compile DX9 code I get a slew of errors. I've searched the net and GameDev and I think I have the answer for this: DX9 has several slightly varying versions and some of the functions that worked in one have changed in later eg D3DXCreateFont and others. I seem to have sorted most of these issues out - is there any where I can go for a definitive list of all these issues and even a quick way to solve them?! 4th: The DirectX 8 books - should I just throw them all way now?! I got them because they covered aspects of DX programming of interest to me but seeing as I've had so many problems between revisions of DX9 am I just going to be banging my head against a brick wall for the next couple of months?! I mean, is there any point trying out the DX8 code with the DX9 SDK? I understand that programs written in prev versions of DX will work with the DX9 runtime but is this the case for compiling too? Can I use compiler directives/includes/libs etc to get them to compile? I think that's it - sorry the post is so long/dense/poorly written but I kinda just got going! Any help or pointers would be greatly appreciated Mikie

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Mikie
Hello everyone!

G'day!
Quote:

Tech Background: Windows XP sp2, Visual Studio C++ 6.0 sp5, DirectX 9c (as reported by DX tools), NON-DirectX 9 video card (actually its a soon-to-be-upgraded (i.e. junk) SIS305 card.


What version of the SDK? (9c is the runtime version, not the SDK version) There should be a release notes or something in the SDK dir that tells you. It might also say in the start menu.

Quote:

1st: Can I start with the DX9 SDK? As always before I plunge into programming on a new platform I try out sample code supplied, so I tried all the samples/demos that come with the SDK - all went well if sometimes extremely slowly (the junk gfx card) but they all worked - EXCEPT Donuts 4 demo. Now, I had the original DX9 SDK installed ages ago and everything worked fine back then even Donuts. I upgraded to 9.0c just a few months ago and now all that happens is... nothing. The PC reports heavy processor usage for about 5 secs and then stops - the Donut process kicks off then quits almost immediately with no error messages etc. Why?!


If you installed the debug runtime (and you really should have) you can read the debugging bit in the Forum FAQ which should tell you why it failed.

Quote:

2nd: I have acquired several books on Direct X programming some of which are based on DX9 and some on DX8 - I had to buy second hand and got given a couple by friends in the business (I have an almost non-existant budget - thank you Ebay!). So what's the problem? Well - mostly things are OK, for DX9 the basics seem fine and the source supplied with the books (if I was lucky enough to get the CD too, otherwise I have to key it all in) mostly work but for one book "Strategy Game Programming with DirectX 9.0" I'm having all sorts of probs. Some of the precompile samples work just fine and others do the same as Donuts ie nothing, well not quite - at least now a window flashs up for a fraction of second then disappears again. Why?! I've tried compiling some the ones that don't work but with mixed results... point 3

See above. Additionally you may want to update your video drivers. The SIS305 is pretty dodgy though, IIRC. Don't forget that there is a wealth of free info available. A bunch of other sites are listed in the Forum FAQ.

Quote:

3rd: Regarding DX9 - as I've said I have DX9.0c installed and when I try to compile DX9 code I get a slew of errors. I've searched the net and GameDev and I think I have the answer for this: DX9 has several slightly varying versions and some of the functions that worked in one have changed in later eg D3DXCreateFont
and others. I seem to have sorted most of these issues out - is there any where I can go for a definitive list of all these issues and even a quick way to solve them?!

I'm not aware of any such list, but if you keep the docs open you can usually find what parameters need to be added/removed/changed fairly quickly. If you have a newer DX9 SDK then it also won't be compatible with VC6. VC2005 Express is available for free. Searching the forums should turn up a number of threads discussing where to get it and how to set it up for DX development.

Quote:

4th: The DirectX 8 books - should I just throw them all way now?! I got them because they covered aspects of DX programming of interest to me but seeing as I've had so many problems between revisions of DX9 am I just going to be banging my head against a brick wall for the next couple of months?! I mean, is there any point trying out the DX8 code with the DX9 SDK? I understand that programs written in prev versions of DX will work with the DX9 runtime but is this the case for compiling too? Can I use compiler directives/includes/libs etc to get them to compile?


All of the concepts are still valid, so throwing them out would be a bit extreme. If you include the DX8 headers and link with the DX8 libs, then you can use the DX8 code. In most cases the changes required to move DX8 code to DX9 is fairly small and makes for a pretty good (if tedious) learning experience.

Share this post


Link to post
Share on other sites
Hello and Wow! I got a reply from Drunken Hyena! I'm chuffed to bits dude, thanks, I've read your work for years now - most insightful!

Ok, please bare with me here:

"What version of the SDK?"

-- I had a look at the SDK doc and all I found was DirectX 9.0. Nothing in the Start menu to give me clue. I don't understand - which version of the SDK do I have then? I'm sure I d/l another revision recently. When I was trying to get some code to run today I had to change references to D3DXCreateFont as VS was reporting errors such as 'too many arguements are being passed': 12 instead of 3 as stated in the SDK docs, does that help narrow it down? Also, the DX control panel tool reports 9.0c (4.09.0000.0904) but that's the Runtime, right?

"If you installed the debug runtime (and you really should have) you can read the debugging bit in the Forum FAQ which should tell you why it failed."

-- I certainly did install the debug runtime cos I read the FAQ a while ago ( I try to help myself before hitting the boards) and VS debug panel reports a slew of "no matching symbolic information found" for d3d9.dll, d3d8thk.dll, gdi32.dll etc etc. Umm...

"See above. Additionally you may want to update your video drivers. The SIS305 is pretty dodgy though, IIRC."

-- Dodgy? It's absolute rubbish and it's going in the bin soon... and driver updates didn't help.

"If you have a newer DX9 SDK then it also won't be compatible with VC6. VC2005 Express is available for free"

-- Urgh.. I was really hoping this wouldn't be the case - I thought the FAQ said they can work together? Is VC2005 any good? What about overheads on the computer? And does that mean "Managed" DX/C# or can I stick with vanilla DX/C++?

DX8 "All of the concepts are still valid"

-- Yeah! I won't rush to bin them then, I'm happy to learn as I go, that's fine.


Thanks again!

Share this post


Link to post
Share on other sites
Hello again!

I'm still trying to figure out which SDK I have installed so I looked through the SDK material and found a project that reports you version of DX. In the "getdxver.cpp" file I found this:

-----
// Name: GetDXVersion()
// Desc: This function returns the DirectX version.
// Arguments:
// pdwDirectXVersion - This can be NULL. If non-NULL, the return value is:
// 0x00000000 = No DirectX installed
// 0x00010000 = DirectX 1.0 installed
// 0x00020000 = DirectX 2.0 installed
// 0x00030000 = DirectX 3.0 installed
// 0x00030001 = DirectX 3.0a installed
// 0x00050000 = DirectX 5.0 installed
// 0x00060000 = DirectX 6.0 installed
// 0x00060100 = DirectX 6.1 installed
// 0x00060101 = DirectX 6.1a installed
// 0x00070000 = DirectX 7.0 installed
// 0x00070001 = DirectX 7.0a installed
// 0x00080000 = DirectX 8.0 installed
// 0x00080100 = DirectX 8.1 installed
// 0x00080101 = DirectX 8.1a installed
// 0x00080102 = DirectX 8.1b installed
// 0x00080200 = DirectX 8.2 installed
// 0x00090000 = DirectX 9.0 installed


Does this effectively mean I only have DX9.0 installed? I ask as there isn't mention of 9.0a, 9.0b, 9.0c any where... I'm assuming later versions will have more info on the revision letter. Could I trouble anyone to confirm this please?

Share this post


Link to post
Share on other sites
Right, OK, I think I have got DX9.0c SDK installed, I eventually found a reference to 9.0c in the SDK docs. And I'm still stuck with the code from "Strategy Game Programming with DirectX 9.0" - the thing I don't understand is why some of the examples work fine and others don't. I've pasted the main() code below - when I step through I find that the programs that fail to work ALWAYS quit through vCleanup() ie that they fail at if( SUCCEEDED( InitD3D( hWnd ) ) )

Does this help to help me through this at all?

//--------------------------------------------------------------------------------------
//
// Main windows function, ie main()
//
//--------------------------------------------------------------------------------------
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
HWND hWnd;
MSG msg;
WNDCLASSEX wndclass;
RECT rcWindowClient;
DWORD dwInputTimer = 0;
int iResult = 0;

// Set up window class
wndclass.cbSize = sizeof(wndclass);
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = fnMessageProcessor;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon( NULL, IDI_APPLICATION );
wndclass.hCursor = LoadCursor( NULL, IDC_ARROW );
wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = "Map Viewer Demo"; // Registered Class Name
wndclass.hIconSm = LoadIcon( NULL, IDI_APPLICATION );

// Register the window class
if( RegisterClassEx( &wndclass ) == NULL )
{
// The program failed, exit
exit(1);
}

// Create the window
hWnd = CreateWindowEx( WS_EX_OVERLAPPEDWINDOW,
"Map Viewer Demo", // Class Name
"D3D_MapViewer", // Name Displayed on Title Bar
WS_OVERLAPPEDWINDOW,
0,
0,
g_iWindowWidth,
g_iWindowHeight,
NULL,
NULL,
hInstance,
NULL );

// Store window handle globally for access later
g_hWnd = hWnd;

// Display the window
ShowWindow( hWnd, iCmdShow );

// Set the global instance of the program
g_hInstance = hInstance;

// Figure out the client work area
GetClientRect( hWnd, &rcWindowClient );

// Calculate the rendering offsets based on the client size
g_iXOffset = (g_iWindowWidth-(rcWindowClient.right-rcWindowClient.left));
g_iYOffset = (g_iWindowHeight-(rcWindowClient.bottom-rcWindowClient.top));

// Resize the window to be truely the resolution desired
SetWindowPos(
hWnd,
NULL,
0, // X-Pos
0, // Y-Pos
g_iWindowWidth + g_iXOffset, // Width
g_iWindowHeight + g_iYOffset, // Height
NULL);

// Clear out message structure
ZeroMemory( &msg, sizeof(msg) );

// Initialize Direct Input
iResult = iInitDirectInput();
if( iResult != INPUTERROR_SUCCESS ) {
MessageBox( hWnd, "DirectInput Error", "Unable to initialize Direct Input.", MB_ICONERROR );
vCleanup();
exit( 1 );
}

// Initialize DI Keyboard
iResult = iInitKeyboard(hWnd);
if( iResult != INPUTERROR_SUCCESS ) {
MessageBox( hWnd, "DirectInput Error", "Unable to initialize Keyboard.", MB_ICONERROR );
vCleanup();
exit( 1 );
}

// Initialize Direct3D
if( SUCCEEDED( InitD3D( hWnd ) ) ) { // FAILS

// Initialize the virtual buffer for the display quad
vInitInterfaceObjects();

// Initialize the tile map
vInitMap();

// Enter the message loop
while( msg.message!=WM_QUIT ) {
if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) ) {
TranslateMessage( &msg );
DispatchMessage( &msg );
}
else {
// Check if it is ok to process mouse clicks
if( timeGetTime() > dwInputTimer ) {
// Check for input
vCheckInput();
dwInputTimer = timeGetTime()+50;
}

// Render the scene
vRender();
}
}
}
// Clean up everything and exit the app
vCleanup(); // ALWAYS EXITS HERE
UnregisterClass( "Map Viewer Demo", wndclass.hInstance );
return 0;
}




Sorry about the repeat posts but I'm not getting this!

ps Thanks for the tidy-up!

[Edited by - Mikie on August 26, 2005 12:11:56 PM]

Share this post


Link to post
Share on other sites
Argh... I feel very close to giving DX a miss and going back to SDL/OpenGL at this rate - at least I'll be able to get away from MS and their messy ways...

I'm now looking at upgrading to a newer version of Visual Studio and I have an extremely tight budget so I believe my options are as follows:

i. Get the Visual C++ 2005 Toolkit and wangle Visual Studio 6.0 to work with it..
--is this a good idea? I've read a few sites where is appears possible if messy!

ii. Download Visual Studio 2005 Beta and forget about the .NET stuff, assuming that's possible.
-- Will it co-exist with VS6? Will I truly not have problems with DX9 with it? I've heard the install expires after a while - what then?!

Not an upgrade but an option:

iii. Beyond3D website has "Using VS6 with DirectX April 2005 SDK"
http://www.beyond3d.com/forum/showthread.php?t=21239

--I like the look of this option but it's even messier - has anyone tried this?

Share this post


Link to post
Share on other sites
// Right, OK, I think I have got DX9.0c SDK installed,

That is not an SDK version, the runtime is named DirectX 9.0c and will stay that way until Vista is released. The SDK version is 9.0 followed by a month and year. They bring them out every two months. The latest SDK is DirectX 9.0 SDK Update (August 2005) and the next one will be DirectX 9.0 Update (October 2005). You can see which version you have simply by looking under the start menu e.g. mine currently says Microsoft DirectX 9.0 SDK Update (August 2005).

I would suggest using Visual Studio Beta in your case. You do not have to use the .net stuff. Microsoft do not own C++ so could not change it to managed but instaed added managed extensions. Most developers use Visual C++ net and simply code native C++ with it.

Share this post


Link to post
Share on other sites
Hello and thanks for the reply - I was just at the toymaker website!

OK so I've popped over to MS and am in the middle of installing VS 2005 Beta - a couple of more questions tho..

Will I be able to continue using the old(er) DX9 and DX8 books I have to teach me the ropes in DX? I understand that some functionality found in these has been deprecated but that doesn't mean inaccessible, right? For example will I still be able to compile DX8 (or DX7 even) code? Don't get me wrong once I'm up and running I'll skip forward to DX9 and DX10 (if that's its name) but while I'm getting there it'd be nice to know that I can refer to my books to get me out of a hole and not have to worry too much amount errors/clashes between DX versions/revisions etc.

I really appreciate your help - my apologies for filling this thread!

(ps I'm only resistant to moving from VS6 cos it's kinda like an old friend to me now - I learnt to program C/C++ with it, I know where everything is, it's easy to use and configure - I'm gonna miss it!)

pps Which revision of DX9 should I get then - August 05 or June 05?

Share this post


Link to post
Share on other sites
Hello, again

I've downloaded and installed 2005 Beta...

first impression? it looks pretty

second impression? What do you mean I can't set "VC++ Directories in the Options dialog of Visual C++ Express Edition"?!

third impression? What do you mean I can't compile Win32 projects in Visual C++ Express Edition without yet more drive munching downloads?!!?!?

Umm.. VC6/SDL/OpenGL look so nice now - the grass ain't always greener!

Share this post


Link to post
Share on other sites
Of course it's not greener, the best stuff in life is never easy, but you can't give up. If you can't deal with bugs, code errors, compiler errors, and things going wrong in general, programming probably shouldn't be your prime area of choice.

However, if you can deal with it and just needed to vent, trust me, you will feel just awesome when you do get it all working.

About the DX SDK version, always try and ensure you have the latest version, remembering that they are all backwards compatible anyways so get the August 2005 release.

As stated previously, you do not have to use anything managed. I've used the VS beta for some time now and haven't written any managed code thus far.

There should be tutorial information about converting from VS6 to VS.NET (VS7) and the new VS beta is very much the same. Try starting there and then see if MS has any information about converting from VS.NET (VS7) to the new VS beta.

Hope this helps.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!