Sign in to follow this  

directX 9 + VS 2008 SP1 problems.

This topic is 3323 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

right, i'm trying to follow a tutorial on directX, and so far, i've gotten nowhere. none of the directX samples works, this code doesn't work: // include the basic windows header files and the Direct3D header file #include <windows.h> #include <windowsx.h> #include <d3d9.h> #include <d3dx9.h> // include the Direct3D Library file #pragma comment (lib, "d3d9.lib") #pragma comment (lib, "d3dx9.lib") // global declarations LPDIRECT3D9 d3d; // the pointer to our Direct3D interface LPDIRECT3DDEVICE9 d3ddev; // the pointer to the device class // function prototypes void initD3D(HWND hWnd); // sets up and initializes Direct3D void render_frame(void); // renders a single frame void cleanD3D(void); // closes Direct3D and releases memory // the WindowProc function prototype LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); // this function initializes and prepares Direct3D for use void initD3D(HWND hWnd) { d3d = Direct3DCreate9(D3D_SDK_VERSION); // create the Direct3D interface D3DPRESENT_PARAMETERS d3dpp; // create a struct to hold various device information ZeroMemory(&d3dpp, sizeof(d3dpp)); // clear out the struct for use d3dpp.Windowed = TRUE; // program windowed, not fullscreen d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; // discard old frames d3dpp.hDeviceWindow = hWnd; // set the window to be used by Direct3D // create a device class using this information and information from the d3dpp stuct d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &d3ddev); return; } HRESULT CreateDevice( UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS *pPresentationParameters, IDirect3DDevice9 **ppReturnedDeviceInterface ); // this is the function used to render a single frame void render_frame(void) { // clear the window to a deep blue d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 40, 100), 1.0f, 0); d3ddev->BeginScene(); // begins the 3D scene // do 3D rendering on the back buffer here d3ddev->EndScene(); // ends the 3D scene d3ddev->Present(NULL, NULL, NULL, NULL); // displays the created frame return; } // this is the function that cleans up Direct3D and COM void cleanD3D(void) { d3ddev->Release(); // close and release the 3D device d3d->Release(); // close and release Direct3D return; } i get the error 1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup 1>G:\backup2007\otherstuff\RTSgame\codestuff\engineapp\test\DXtestapp\Debug\DXtestapp.exe : fatal error LNK1120: 1 unresolved externals i've added into the VC++ directories in the options menu this: ------------------------------------ C:\Program Files\Microsoft DirectX SDK (February 2007)\Include $(VCInstallDir)include $(VCInstallDir)atlmfc\include $(WindowsSdkDir)\include $(FrameworkSDKDir)include C:\SDL-1.2.8\include i just downloaded SDL to see if it fixed any of my problems, which it didn't. the library files in the VC++ directories are these: ------------------------------------ C:\Program Files\Microsoft DirectX SDK (February 2007)\Lib\x86 $(VCInstallDir)lib $(VCInstallDir)atlmfc\lib $(VCInstallDir)atlmfc\lib\i386 $(WindowsSdkDir)\lib $(FrameworkSDKDir)lib $(VSInstallDir) $(VSInstallDir)lib C:\SDL-1.2.8\lib in the linker>system i've set subsystem to windows, in C/C++ preprocessor is set to WIN32;_DEBUG;_WINDOWS in debugging i haven't set a working directory, in linker-input-ignore specific library i set libcmtd, msvcrt, atls, but removing those doesn't do anything. and well yeah.. dunno what to do. i've searched forums for a solution for a few hours, and found nothing that fixed the issue.

Share this post


Link to post
Share on other sites
If that's all your code I can only think that you forgot to write a WinMain function like the compiler error says. Post your WinMain. Maybe the arg types are wrong and the compiler can't match it.

Share this post


Link to post
Share on other sites
BTW it's a good idea to get to know the compiler errors or do some google before posting. This problem has nothing to do with Directx. Goggling LNK2019 error will tell you it probably can't find a function definition. It also says WinMain, which is Windows API.

Share this post


Link to post
Share on other sites
GAH, finally got it running.

yeah you're right, before, i had just copy-pasted parts from the tutorial into
the code, but at the bottom there was the complete code HIDDEN behind a dropdown list thing.

was this tutorial:

http://www.directxtutorial.com/Tutorial9/B-Direct3DBasics/dx9B1.aspx

if you copy/paste the pieces of code along the tutorial, it doesn't compile,
but if you copy paste the complete code towards the bottom it compiles.
grrr....

all this time and i thought it was a setup error.

oh and i searched for the link errors, but i don't speak microsoft that well, so the explanation for the error message was pretty confusing, especially since i was not expecting the problem to be with the code, as i had copy-pasted it from someone who had already got it working.
if you have a language course in deciphering the explanation, that would be helpful too.

[Edited by - dejawolf on November 7, 2008 2:09:15 AM]

Share this post


Link to post
Share on other sites
Quote:
Original post by dejawolf
GAH, finally got it running.

yeah you're right, before, i had just copy-pasted parts from the tutorial into
the code, but at the bottom there was the complete code HIDDEN behind a dropdown list thing.

was this tutorial:

http://www.directxtutorial.com/Tutorial9/B-Direct3DBasics/dx9B1.aspx

if you copy/paste the pieces of code along the tutorial, it doesn't compile,
but if you copy paste the complete code towards the bottom it compiles.
grrr....

all this time and i thought it was a setup error.

oh and i searched for the link errors, but i don't speak microsoft that well, so the explanation for the error message was pretty confusing, especially since i was not expecting the problem to be with the code, as i had copy-pasted it from someone who had already got it working.
if you have a language course in deciphering the explanation, that would be helpful too.
directxtutorial.com is really, really, really bad. I'm amazed at the number of people who use it. It teaches bad habits, and doesn't explain things very well. For instance it doesn't handle return values at all, meaning your code will just crash if run on some hardware, and it doesn't check for support of anything and just assumed it can be done.

I'd really recommend finding a better site to learn from, the Forum FAQ has several.

Share this post


Link to post
Share on other sites
well, it was the first thing i came upon that seemed to explain things, so i went with it.
the alternative is basically finding bits and pieces of information here and there, with different programming styles to confuse you.
it also presents itself well as a beginners tutorial, and has lots illustrations to show, instead of explain how things works.
and i just tend to process images 1000x faster than i process words.
plus everything is chaptered up fairly neatly into digestible chunks of information.
but if there truly is a better "beginners tutorial for DirectX" out there, well, i'm interested.

Share this post


Link to post
Share on other sites
Quote:
Original post by dejawolf
and i just tend to process images 1000x faster than i process words.


Sometimes you just need to spend 1000x more time to understand something properly... [grin]

Share this post


Link to post
Share on other sites

This topic is 3323 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.

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