Page 1 of 1

SMaterial Error

Posted: Thu Nov 03, 2005 12:43 am
by Fhqwhgads
Okay I get this error...
(206) : error C2228: left of '.Texture1' must have class/struct/union type
(207) : error C2228: left of '.Lighting' must have class/struct/union type
for this code...

Code: Select all

SMaterial* loadTexture(char* name){
	SMaterial *texture;
	texture.Texture1 = Driver->getTexture(name);
	texture.Lighting = true;
	return texture;
}
Any ideas?

Posted: Thu Nov 03, 2005 1:09 am
by Spintz

Code: Select all

SMaterial* loadTexture(char* name){ 
   SMaterial* texture = new SMaterial();
   texture->Texture1 = Driver->getTexture(name); 
   texture->Lighting = true; 
   return texture; 
} 

Posted: Thu Nov 03, 2005 2:18 am
by Fhqwhgads
oooah. Ok that makes sense! That fixed that error. But now I get this error :P

Code: Select all

LINK : warning LNK4098: defaultlib "LIBCMT" conflicts with use of other libs; use /NODEFAULTLIB:library

RGame_Main.obj : error LNK2001: unresolved external symbol "class irr::scene::IAnimatedMesh * __cdecl loadModel(char *,struct irr::video::SMaterial *,class irr::scene::IAnimatedMeshSceneNode *)" (?loadModel@@YAPAVIAnimatedMesh@scene@irr@@PADPAUSMate
rial@video@3@PAVIAnimatedMeshSceneNode@23@@Z)
Release/RGame.exe : fatal error LNK1120: 1 unresolved externals
I have no idea what that means. I am using msvc++6

Posted: Thu Nov 03, 2005 12:28 pm
by Spintz
not linking to right correct .lib.

have you changed the engine and recompiled it?

Posted: Thu Nov 03, 2005 3:49 pm
by Fhqwhgads
Nope. Haven't touched the code at all. Is there a lib file I need? The game worked fine as is befor I added this code.

Posted: Thu Nov 03, 2005 5:29 pm
by pfo
use /NODEFAULTLIB:library
The answer's right there, just tell your compiler to ignore LIBCMT

Posted: Thu Nov 03, 2005 8:06 pm
by FlyHigh
pfo wrote:
use /NODEFAULTLIB:library
The answer's right there, just tell your compiler to ignore LIBCMT
Thats the warning not the error. I wouldn't suggest using switches just because the compiler tells you to. (As in this it its a hack round a problem that doesn't exist, not the solution)

As for your error you need to link the library correctly, either through project settings or a pragma statement, see tutorial 1 for more details.

Posted: Thu Nov 03, 2005 8:23 pm
by Fhqwhgads
Okay, fixed the warning. I added Irrlicht.lib to the list of librarys but that didn't work. and I have the #pragma in my code.

Posted: Fri Nov 04, 2005 12:46 am
by Fhqwhgads
Okay..I think I figured it out.

When you load a texture through Driver->getTexture() you need to load it into material.Texture1and inside my function I was returning SMaterial when I needed to be returning ITexture type.

Posted: Fri Nov 04, 2005 12:59 am
by Guest
you should read some c++ tutorials/books before you start writing 3d games....

Posted: Fri Nov 04, 2005 1:54 am
by Fhqwhgads
...

I have. I have c++ for dummies because I am a dummie(if you couldn't tell form my posts). I recoded my whole project(an read in my devblog..in my sig) just to get into a OOP structure.

Only reason why I post about these errors is becuase I know c++, I jsut don't code often enough to reconize the errors. But now I know what the errors mean and how to fix them, and how to look them up on MSDN.