|
Hi.
First I would like to say that I am quite the beginner using C++. I have just started to learn DirectX and I have a problem compiling. Maybe this post should be put in the Graphics forum but I don’t know if it is really a Graphics problem.
I went through the tutorial called “Beginning Direct3D by Vahid Kazemi” found here codeproject.com[^] and it worked great. I am currenly reading a book called “Introduction to 3D game programming with DirectX 9.0 by Frank D. Luna”. In the beginning of this book there is a tutorial/sample project that basically is the same as the one by Vahid Kazemi only structured a bit differently. It has the basic framework that I am supposed to build the rest of the tutorials in the book on. Now I am having some problems getting the project form the book to compile.
Here is the compiler error:
-----
1>Linking...
1>Main.obj : error LNK2019: unresolved external symbol "bool __cdecl d3d::InitD3D(struct HINSTANCE__ *,int,int,bool,enum _D3DDEVTYPE,struct IDirect3DDevice9 * *)" (?InitD3D@d3d@@YA_NPAUHINSTANCE__@@HH_NW4_D3DDEVTYPE@@PAPAUIDirect3DDevice9@@@Z) referenced in function _WinMain@16
1>C:\Users\Stian H. Haug\Documents\Visual Studio 2008\Projects\Spill Programmering\Spillprogrammering - Sample One\Debug\Spillprogrammering - Sample One.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://c:\Users\Stian H. Haug\Documents\Visual Studio 2008\Projects\Spill Programmering\Spillprogrammering - Sample One\Spillprogrammering - Sample One\Debug\BuildLog.htm"
1>Spillprogrammering - Sample One - 2 error(s), 0 warning(s)
-----
Judgeing by the error i thought it might be a linking error. However I managed to compile the tutorial by Vahid Kazemi and I have included all the same files, .lib and such that I included in that tutorial.
Here is my WinMain loop where I call the InitD3D() function.
int WINAPI WinMain(HINSTANCE hinstance,
HINSTANCE prevInstance,
PSTR cmdLine,
int showCmd)
{
if(!d3d::InitD3D(hinstance, 800, 600, true, D3DDEVTYPE_HAL, &Device))
{
::MessageBox(0, "InitD3D() - FAILED", 0, 0);
return 0;
}
if(!Setup())
{
::MessageBox(0, "Setup() - FAILED", 0, 0);
return 0;
}
d3d::EnterMsgLoop( Display );
Cleanup();
Device->Release();
return 0;
}
Here is the prototype in my header file:
bool InitD3D(
HINSTANCE hInstance,
int width, int height,
bool windowed,
D3DDEVTYPE deviceType,
IDirect3DDevice9** device);
I belive the InitD3D()function is implemented in one of these files:
#include <d3d9.h>
#include <d3dx9.h>
I have included them both.
If anyone can help me with understanding this problem it would be great. If you want me to post the whole code i can.
Thanks!
modified on Sunday, November 22, 2009 3:38 PM
|
|
|
|
|
stianhh wrote: I belive the InitD3D()function is implemented in one of these files:
You need to verify which it is! From the error messages you have posted there is no implementation of d3d::InitD3D() , so you need to find out if it is implemented in one of your source files, or is part of a library/dll that should be available to the linker. The article you refer to shows a local implementation of this function.
|
|
|
|
|
Seems the example in the book mentioned a .cpp file implementing the InitD3D() function that had to be downloaded from the books homepage. Sorry but the way it was written in the book didn't make me think twice about weather the function was implemented in the included files or not.
Thanks for the help!
|
|
|
|
|
Generally speaking the .h files should only contain declarations. All the implementation code should be in the .cpp files.
And yes, I do know that ATL does it the other way, but that is a foul abomination that should be wiped from the face of the earth.
|
|
|
|
|
stianhh wrote: I have just started to learn DirectX and I have a problem compiling.
It's not really at compilation but rather at linking.
You probably forgot to link to the direct3D library. Did you follow these steps described at the begining of the article ?
If you use Microsoft Visual C++ create an empty Win32 project and in the Project Properties>Linker>Input>Additional Dependencies add d3d8.lib (main direct3d library), d3dx8.lib (extensions to the main library) and winmm.lib (windows multimedia library).
|
|
|
|
|
Hi,
I need to search for a file in a specific directory. This directory would also have subdirectories in it. Can I have a API / code snippet for this.
Thanks in advance.
|
|
|
|
|
There is no single API to do that, however this[^] MSDN sample may help.
-Suhredayan
|
|
|
|
|
FindFirstFile、FindNextFile
|
|
|
|
|
In addition to FindFirstFile, you could use FileExists to search each directory for a match. If you intend to search subdirectories, you still need to to identify them.
#include <sys stat.h=""> //for FileExists
bool FileExists(char * const strFilename) {
struct stat stFileInfo;
bool blnReturn;
int intStat;
// Attempt to get the file attributes
intStat = stat(strFilename,&stFileInfo);
if(intStat == 0) {
// We were able to get the file attributes
// so the file obviously exists.
blnReturn = true;
}
else {
// We were not able to get the file attributes.
// This may mean that we don't have permission to
// access the folder which contains this file. If you
// need to do that level of checking, lookup the
// return values of stat which will give you
// more details on why stat failed.
blnReturn = false;
}
return(blnReturn);
}
|
|
|
|
|
I wrote a program in C++ to store student details. Basically it stores 5 student's registration numbers with their GPAs and there are other functions in the program too.
I'm trying to convert the code to work in 'C' but I'm getting too many errors, especially where the arrays are concerned.
It would be very helpful if anyone could point me in the right direction or even give me a piece of the converted "C" code because that way I'll know what to change as I know C++ but I don't know C.
A piece of my C++ code i.e. the case1 statement is as follows:
#include*stdio.h
#include*stdlib.h
int main()
{
const int size = 5;
float gpa[size],sum=0,avg;
int i,regno[size],reg,flag=0;
char value;
while(value!='0')
{//start of while
cout<<"\t\t\t---MAIN MENU---\n\n\n\n";
cout<<"\n\nPress 1 to enter GPA(s) and registration number(s)";
cout<<"\n\nPress 2 to upgrade GPA(s)";
cout<<"\n\nPress 3 to display average of all the entered GPAs";
cout<<"\n\nPress 4 to display all the GPAs and regestration numbers";
cout<<"\n\nPress 5 to display registration number(s) of GPA of 4 holders";
cout<<"\n\nPress 0 to exit the program";
cout<<"\n\n\n\n\nEnter value = ";
cin>>value;
if(value=='0')
{
break;
}
switch(value)
{
case '1':
for(i=0;i*is less than*size;i++)
{
cout<<"\t\t\tENTER DATA\n\n\n\n";
cout<<"\n\n\nEnter GPA of student: "<<i+1<<" :="" ";
="" cin="">>gpa[i];
cout<<"\n\n\nEnter registration number of student: "<<i+1<<" :="" ";
="" cin="">>regno[i];
}
cout<<"\n\n\n\t\tPress any key to go back to the main menu";
getch();
break;
}
}
modified on Sunday, November 22, 2009 12:11 AM
|
|
|
|
|
You aren't using any of the C++ language features as such. Simply use printf instead of cout and scanf instead of cin . Search for examples on usage of these functions. They're not very difficult anyway.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
hivicky wrote: I know C++ but I don't know C.
I think you may be slightly confused; apart from cin and cout your code is C not C++.
|
|
|
|
|
"C" language do not support stream read and write(cin/cout), you can use "printf" & "scanf".
Example:
C++
cout<<"\t\t\tENTER DATA\n\n\n\n";
C
printf("\t\t\tENTER DATA\n\n\n\n");
|
|
|
|
|
Hello, i have a main dialog that calls to a modal dialog , and i want to initialize the controls (their variables associated) but in this modal dialog there isn't a OnInitDialog like in the main dialog , why? so how can i do initialize the controls? .thanks.
|
|
|
|
|
Oh, i found the solution, so easy, i'm newbie!
|
|
|
|
|
Hi,
I'm developing a reconciliation software. I have to find the matching items using some rules. However, some items represent sum of other items but I don't know which are they. So, I need to find, by trial and error, the numbers that represent the another number.
List 1 : 10, 300, 50
List 2 : 5, 50,20,25,150,5,30,50,5,20
Here 10 = 5 + 5
300 = 50 + 150 + 25 + 5 + 50 + 20
50 = 20 + 30
There may be hundreds of such number like in List 2 and dozens likes List 1. My job is to find which number make up the numbers in List 1 base only on the numbers. Can any one knows about any algorithm to achieve this task.
Thanks
Md. Humayuon Kabir Hemoo
|
|
|
|
|
What comes in my mind is simply brute force: take a number from list 1 and try every combination in list 2. There are many ways to optimize this because it tries many combinations are surely wrong. for example: sort your list 2 and stop trying combinations if the sum gets bigger then the number from list 1.
If your list 2 numbers have more characteristics (they are not completely random) maybe you can find rules so more needless combinations can be avoided.
I hope this gives you a good start...
Rozis
|
|
|
|
|
Try sorting all #s first. Then for each element in list 1, search for a match in list 2. Upon finding it, remote the item from both lists. So if there are 3 50's in list 1 and 8 50's in list 2, you should be left with 0 in list 1 and 5 in list 2.
Then with your new list 1 and 2, try to reconcile the largest items first. You should do sweeps assuming that an item in list is the sum of two #s. Then after trying this for all items, then look at sums of three #s...
You will loop over the combinations using (d-1) dimensional arrays where d is the # of items in the sum.
Note that this does not guarantee that it will find the right solution.... The correct algorithm is more complex.
You could mark each # as being utilized for sum of k #s in the other list. Then you have to search multiple cases until you find your most explanatory match...
Depending on what other information you have, there may be an even better method.
|
|
|
|
|
Both of replies are very helpful. I think I have got the point. Thank you very very much.
Md. Humayuon Kabir Hemoo
|
|
|
|
|
when i am executing following code:
#include "stdafx.h"
#include "stdio.h"
#include
using namespace std ;
class Derived;
typedef void (Derived::*callbackf)() ;
class Base;
typedef map<base*, callbackf*=""> MYLIST;
class Base
{
public:
Base(void){};
MYLIST mylist;
void Attach(Base* p, callbackf* voidpt){mylist[p] = voidpt;};
~Base(void){};
};
class Derived : public Base
{
public:
void onMoving(){};
Derived(void)
{
callbackf ponMoving = &Derived::onMoving;
Attach(this, &ponMoving);
};
~Derived(void){};
};
int _tmain(int argc, _TCHAR* argv[])
{
Base *b;
b= new Derived();
MYLIST::iterator itr;
itr = b->mylist.begin();
for (itr = b->mylist.begin(); itr != b->mylist.end(); itr++)
{
Base* clsOb = (*itr).first;
callbackf fn = b->mylist[(*itr).first];
(*clsOb.*fn)();
}
return 0;
}
I am getting two errors:
'initializing' : cannot convert from 'void *' to 'callbackf'
'newline' : cannot convert from 'Base *__w64 ' to 'Derived *__w64 '
'.*' : cannot dereference a 'callbackf' on a 'Base'
Can anybody pls help?
modified on Sunday, November 22, 2009 11:38 PM
|
|
|
|
|
Could you please format your code using the "code block" tag (and please, read the posting guidelines at the top of this message board).
|
|
|
|
|
I have tried to compile this code and get 35 errors. I think you need to work on correcting the basics, particularly the typedefs at the beginning.
|
|
|
|
|
I've got DLL which invokes SHGetSpecialFolderPath() function with CSIDL_LOCAL_APPDATA parameter in DLL load handler.
When the DLL is loaded from windows application, ASP.NET application, or windows service and queried that special folder, it returns different locations for that special folder. Moreover in XP and Vista those locations are different.
Is there a way to find out these locations with some specific function when invoked from windows application?
Чесноков
|
|
|
|
|
Correct me if im wrong but SHGetSpecialFolderPath() returns a userrelated folder. The organization of users is different on XP then under Vista. This is the reason you will get different folders. But what is your problem with that?
Rozis
|
|
|
|
|
yes, user related folder, I know it is different.
>>Is there a way to find out these 3 locations with some specific function when invoked from windows application?
Чесноков
|
|
|
|