Jump to content
  • Advertisement
Sign in to follow this  
nicoritsche

include problem with dxutgui.h

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

When I include "dxutgui.h" (dx user interface classes) in my own ui class header - call it "ui.h" - which I incude in my main application I get lots of compilation errors in "dxutgui.h". Many types are not found and I don't know why. The error messages start with: " syntax error : identifier 'D3DCOLOR' " (line 94). When I implement my classes directly in ui.h there is no problem. Can somebody help me? Thanks a lot. Nico (Im using vs 2005 beta 2)

Share this post


Link to post
Share on other sites
Advertisement
Hi Nico,
The easiest way is to use the "Sample browser" from the DX SDK to create your base project/solution.

If you don't want to use the sample browser for creating your project, then add the .cpp files from the SDK folder:
(SDK root)\Samples\C++\Common to your project.
Also add the above folder to your projects include directories.

That folder on my system for example, is:
C:\Program Files\Microsoft DirectX 9.0 SDK (April 2005)\Samples\C++\Common

That is for the DXUT / DXUTGUI functions.

*** edit***
D3DCOLOR is defined in d3d9types.h which is included d3d9.h

both headers are in the directory (SDK root)\Include

You need to add this directory to your projects include directories.

That folder on my system for example, is:
C:\Program Files\Microsoft DirectX 9.0 SDK (April 2005)\Include

HTH,
Cambo_frog

[Edited by - Cambo_frog on July 30, 2005 1:55:57 PM]

Share this post


Link to post
Share on other sites
Hi Cambo_frog,

thanks for your answer, but I already did all that you suggested me to do.
All the necessary headers are found and the files from the common folder are
included in my project.

This works:

mainapp.cpp includes mygui.h,
mygui.h includes dxutgui.h,
mygui implementation is in the header (I don't want this!)

This doesn't work:

mainapp.cpp includes mygui.h,
mygui.h includes dxutgui.h,
mygui implementation is in mygui.cpp (I want this! ;-))

I set up an empty test program, where myapp.cpp contains only an empty winmain func. and the include statement for mygui.h and mygui.h contains only the include statement for dxutgui.h.
The problem is the same: As soon as I add a "mygui.cpp" I get the errors.

Nico

Share this post


Link to post
Share on other sites
Hi Nico,
Before you include DXUTGui.h in any files, you will need to include other header files first. Probably:
#include <windows.h>
#include <d3d9.h>
#include <d3dx9.h>
#include "DXUT.h"

... as a *minimum* ( probably lots of others ).

I suggest creating a main header file (which includes you other headers) to be compiled in to a pre-compiled header.

The SDK samples do this using the dxstdafx.h file, which will be something like this:

//--------------------------------------------------------------------------------------
// File: DxStdAfx.h
//
// Desc: Standard includes and precompiled headers for DXUT
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//--------------------------------------------------------------------------------------
#pragma once
#ifndef DXSDK_STDAFX_H
#define DXSDK_STDAFX_H

#ifndef STRICT
#define STRICT
#endif

// If app hasn't choosen, set to work with Windows 98, Windows Me, Windows 2000, Windows XP and beyond
#ifndef WINVER
#define WINVER 0x0410
#endif
#ifndef _WIN32_WINDOWS
#define _WIN32_WINDOWS 0x0410
#endif
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0500
#endif

#pragma warning( disable : 4100 ) // disable unreference formal parameter warnings for /W4 builds

#include <windows.h>
#include <assert.h>
#include <wchar.h>
#include <mmsystem.h>
#include <commctrl.h> // for InitCommonControls()
#include <shellapi.h> // for ExtractIcon()
#include <new.h> // for placement new
#include <math.h>
#include <limits.h>
#include <stdio.h>
#include <multimon.h>

// CRT's memory leak detection
#if defined(DEBUG) | defined(_DEBUG)
#include <crtdbg.h>
#endif


// Enable extra D3D debugging in debug builds if using the debug DirectX runtime.
// This makes D3D objects work well in the debugger watch window, but slows down
// performance slightly.
#if defined(DEBUG) | defined(_DEBUG)
#ifndef D3D_DEBUG_INFO
#define D3D_DEBUG_INFO
#endif
#endif

// Direct3D includes
#include <d3d9.h>
#include <d3dx9.h>
#include <dxerr9.h>

// DirectSound includes
#include <mmsystem.h>
#include <mmreg.h>
#include <dsound.h>

// strsafe.h deprecates old unsecure string functions. If you
// really do not want to it to (not recommended), then uncomment the next line
//#define STRSAFE_NO_DEPRECATE

#ifndef STRSAFE_NO_DEPRECATE
#pragma deprecated("strncpy")
#pragma deprecated("wcsncpy")
#pragma deprecated("_tcsncpy")
#pragma deprecated("wcsncat")
#pragma deprecated("strncat")
#pragma deprecated("_tcsncat")
#endif

#include <strsafe.h>

#include "DXUT.h"
#include "DXUTmisc.h"
#include "DXUTenum.h"
#include "DXUTmesh.h"
#include "DXUTgui.h"
#include "DXUTsettingsDlg.h"
#include "DXUTSound.h"

#if defined(DEBUG) | defined(_DEBUG)
#ifndef V
#define V(x) { hr = x; if( FAILED(hr) ) { DXUTTrace( __FILE__, (DWORD)__LINE__, hr, L#x, true ); } }
#endif
#ifndef V_RETURN
#define V_RETURN(x) { hr = x; if( FAILED(hr) ) { return DXUTTrace( __FILE__, (DWORD)__LINE__, hr, L#x, true ); } }
#endif
#else
#ifndef V
#define V(x) { hr = x; }
#endif
#ifndef V_RETURN
#define V_RETURN(x) { hr = x; if( FAILED(hr) ) { return hr; } }
#endif
#endif

#ifndef SAFE_DELETE
#define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } }
#endif
#ifndef SAFE_DELETE_ARRAY
#define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p); (p)=NULL; } }
#endif
#ifndef SAFE_RELEASE
#define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } }
#endif

#endif // !defined(DXSDK_STDAFX_H)




You will see there are lots of other headers and defines before DXUTGui.h is included.

I still think it would be easier to create your base project from one of the samples and adapt it to your needs.

Try using the "EmptyProject" sample as your base. Open the SDK sample browser, navigate to the "EmptyProject" sample and click it's "install project" link.
In the dialog that opens, name the project "MyUI" and choose a location for your project and click the install button.

In Visual Studio, select "Open solution" from the file menu. Navigate to the folder you created your project in and select the "MyUI_2003" solution.

VS 2005 may have a different format for solution files than VS 3003.If it does, then VS 2005 will probably have a conversion function for older solution files and ask if you want to convert the solution.

***EDIT***
Note: I am using the April 2005 SDK

HTH and good luck,
Cambo_frog

Share this post


Link to post
Share on other sites
Hi

thanks! After including "dxstdafx.h" my program works fine.
To your suggestion: I actually started from the Custom UI Sample from
the sdk.
At the moment I'm extending the dx ui classes to suit my needs.
And I also built a higher level user interface class, that's
why I have my own gui header + cpp.

nico

Share this post


Link to post
Share on other sites
Quote:
Original post by nicoritsche
Hi

thanks! After including "dxstdafx.h" my program works fine.
To your suggestion: I actually started from the Custom UI Sample from
the sdk.
At the moment I'm extending the dx ui classes to suit my needs.
And I also built a higher level user interface class, that's
why I have my own gui header + cpp.

nico

Hi Nico,
Glad you got it sorted.
I wrote some code to extend the functionality of the CDXUTEditBox class to edit float, double, int, unsigned values etc, possibly keeping them within a certain range (min, max). Are you doing something like that by any chance?

If you need any help, just post in this forum.

Good Luck,
Cambo_frog


Share this post


Link to post
Share on other sites
Hi Cambo_frog,

>>I wrote some code to extend the functionality of the CDXUTEditBox class to edit >>float, double, int, unsigned values etc, possibly keeping them within a certain >>range (min, max). Are you doing something like that by any chance?

No, but what you do sounds useful to me. Are you interested in sharing code?
So far I added a panel class representing an invisible panel which can hold several controls and which is notified at mouse entering/leaving. I had to
modify some of the dxutgui clsses for that.
From that I derived a panel that can be pinned/unpinned. When pinned it is always
shown, when unpinned it becomes visible on mouse enter and invisible on mouse leave.

best regards
nico

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!