Jump to content
  • Advertisement
Sign in to follow this  
Narcis

DirectX 8 Error

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

I compiled an example DirectX application after setting up the DirecX 8 files with my compiler and I get...
C:/directx8/dxfile.h:240: error: stray '\26' in program
Incase this is relavent, heres the program source...
[source lang=cpp]
// direct3d.exe - this project will attempt to play around with primitives and the 
// camera a bit...
#include <windows.h>
#include <d3d8.h>
#include <d3dx8.h>
#include <iostream>

using namespace std;

// WINDOWS GLOBALS
HINSTANCE g_hInstance;


// DIRECT3D GLOBALS
LPDIRECT3D8 pD3D;
LPDIRECT3DDEVICE8 pDevice;

D3DXMATRIX matProj;
D3DXMATRIX matCamera;
D3DXVECTOR3 vecCameraSource;
D3DXVECTOR3 vecCameraTarget;

// FUNCTION PROTOTYPES
int Init3DEnvironment ( HWND hWnd );
void SetupCamera ( void );
void RenderScene ( void );


// WINDOW MESSAGE PROCEDURE!
LRESULT CALLBACK WinProc ( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) {

	switch ( msg ) {

	case WM_CLOSE:

		DestroyWindow ( hWnd );
		return 0;

		break;

	case WM_DESTROY:

		PostQuitMessage ( 0 );
		return 0;

		break;

	}

	return DefWindowProc ( hWnd, msg, wParam, lParam );

}

// MAIN WINDOW PROCEDURE!
int WINAPI WinMain ( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) {

	HWND hWnd;
	MSG msg;
	WNDCLASSEX wc;

	// set the instance global
	g_hInstance = hInstance;

	// fill the wc class members
	wc.cbClsExtra = 0;
	wc.cbSize = sizeof(WNDCLASSEX);
	wc.cbWndExtra = 0;
	wc.hbrBackground = (HBRUSH) (COLOR_WINDOW+11);
	wc.hCursor = LoadCursor ( g_hInstance, IDC_ARROW );
	wc.hIcon = LoadIcon ( g_hInstance, IDI_APPLICATION );
	wc.hIconSm = LoadIcon ( g_hInstance, IDI_APPLICATION );
	wc.hInstance = g_hInstance;
	wc.lpfnWndProc = WinProc;
	wc.lpszClassName = "WndClass";
	wc.lpszMenuName = NULL;
	wc.style = NULL;

	// register the class
	if ( !RegisterClassEx ( &wc ) ) {
		MessageBox ( NULL, "Fatal error, could not register window class!\nThis program will terminate now.", "Fatal Error", MB_OK|MB_ICONEXCLAMATION );
		return 1;
	}

	// open a window
	hWnd = CreateWindowEx ( 0, "WndClass", "Direct3D Test", WS_VISIBLE|WS_OVERLAPPED|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_SYSMENU, CW_USEDEFAULT, CW_USEDEFAULT, 800, 600, NULL, NULL, g_hInstance, NULL );

	if ( hWnd == NULL ) {
		MessageBox ( NULL, "Fatal error, could not create main window!\nThis program will terminate now.", "Fatal Error", MB_OK|MB_ICONEXCLAMATION );
		return 1;
	}

	// Show and update window
	ShowWindow ( hWnd, nCmdShow );
	UpdateWindow ( hWnd );

	Init3DEnvironment ( hWnd );

	while ( GetMessage ( &msg, hWnd, 0, 0 ) > 0 ) {

		RenderScene ( );

		TranslateMessage ( &msg );
		DispatchMessage ( &msg );

	}

	return msg.lParam;

}


// INITIALIZE THE 3D ENVIRONMENT
int Init3DEnvironment ( HWND hWnd )
{
	// create the direct3d interface
	if ( ( pD3D = Direct3DCreate8 ( D3D_SDK_VERSION ) ) == NULL ) {
		return 0;
	}
	// D3DDISPLAYMODE OBJECT
	D3DDISPLAYMODE d3ddm;
	pD3D->GetAdapterDisplayMode ( D3DADAPTER_DEFAULT, &d3ddm );
	D3DPRESENT_PARAMETERS d3ddp;
	ZeroMemory ( &d3ddp, sizeof(d3ddp) );
	d3ddp.BackBufferFormat = d3ddm.Format;
	d3ddp.Windowed = TRUE;
	d3ddp.SwapEffect = D3DSWAPEFFECT_FLIP;
	if( FAILED ( pD3D->CreateDevice ( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
    hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3ddp, &pDevice ) ) ) {
        return 0;
    }
    return 1;
}

// SET UP A CAMERA!
void SetupCamera ( void )
{

}

void RenderScene ( void )
{
	pDevice->Clear ( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB ( 0, 0, 0 ), 1, 0 );
	pDevice->BeginScene();
	pDevice->EndScene();
	pDevice->Present( NULL, NULL, NULL, NULL );
}

Share this post


Link to post
Share on other sites
Advertisement
I would recommend just using DirectX 9. That error means to look at line 240 of the file it shows. Your program isn't doing anything wrong (from a quick glance) so it could just be that your computer has the DirectX 9 runtimes, but you're using the DirectX 8 headers. To switch to DX9, with what you have now, would only require changing a bunch of 8's to 9's (like Direct3DCreate8 to Direct3DCreate9 and LPDIRECT3D8 to LPDIRECT3D9). So far you haven't hit anything that should stop you.

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!