Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Why can't I create a DirectX8 Object???

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

It''s a small project, so I''ll just post up all the source so far. Scroll down ''till you get to the InitD3D() function, I''ve commented the line that will not execute. The error is: ''Direct3dCreate8'' : undeclared identifier Am I doing something wrong?
  

#define WIN32_LEANANDMEAN

#include <windows.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>


#include "D3d8.h"

IDirect3D8 *g_pD3D;

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
void InitD3D();
void ReleaseD3D();
void Render();

int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPTSTR lpCmdLine, int nCmdShow)
{
	WNDCLASSEX wc = { sizeof(WNDCLASSEX) };
	//ZeroMemory(&wc, sizeof(WNDCLASSEX);

	wc.cbSize = sizeof(WNDCLASSEX);
    wc.style = CS_CLASSDC;
	wc.lpfnWndProc = WndProc;
	wc.hInstance = GetModuleHandle(NULL);
	wc.lpszClassName = "DirectX8Test";

	RegisterClassEx(&wc);

	HWND hWnd = CreateWindow("DirectX8Test", "Direct X Test", WS_SYSMENU, 100, 100,
		300, 300, GetDesktopWindow(), NULL, wc.hInstance, NULL);

	ShowWindow(hWnd, nCmdShow);

	BOOL bGetMessage;

	MSG msg;

	while(bGetMessage = GetMessage(&msg, NULL, 0, 0))
	{
		if(bGetMessage == false)
		{
			// error handling

		} else {
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
	}
	
	return (int)msg.wParam;
}

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch(message)
	{
	case WM_DESTROY:
		PostQuitMessage(0);
		return 0;
	case WM_PAINT:
		Render();
		return 0;
	}

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

void InitD3D()
{
	g_pD3D = Direct3dCreate8(D3D_SDK_VERSION); // this line

             // will not compile!

}

void ReleaseD3D()
{
}

void Render()
{
}

  

Share this post


Link to post
Share on other sites
Advertisement
I think it may have something to do with project settings. Does anyone know what an "import library" is? Do I need one to use directX?

Share this post


Link to post
Share on other sites
Well, I''m not sure why you''re getting ''undeclared identifier'' instead of ''undefined external'' but yes, you need to link with the correct libraries to use DirectX. If you are using Visual C++ 6.0, go into Project->Settings->Link and find the input libraries. (Can''t remember the exact name.) It will have a whole bunch of .lib files listed already. You need to add d3d8.lib, dxguid.lib, and any others you might need. You can find all this information in the DirectX help under "Introducing DirectX"->"Programming DirectX"->"Compiling DirectX Samples"

Share this post


Link to post
Share on other sites
yes, you need to include a library for direct3D.

If you are using VisC++ it should be under Project->Settings and then the Link tab. Where it says object/library modules enter d3d8.lib

Also, make sure your compiler knows which directory your directX lib files are in. (You can do that under Tool->Options->Directories in VisC++)

[ Demonic Pillbug ]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!