difference between u32 vs s32 and pointer in irrlicht

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
caiten
Posts: 6
Joined: Sun Sep 02, 2012 6:37 pm

difference between u32 vs s32 and pointer in irrlicht

Post by caiten »

HI ALL

i am newbie .i have question;
+how to use u32 and s32 ?
+IrrlichtDevice *irrDevice .how to pointer *irrDevice use ?
IrrlichtDevice is class or struct ? i can't find in include file

thankss. my english is bad
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: difference between u32 vs s32 and pointer in irrlicht

Post by CuteAlien »

Hi caiten,

u32 and s32 (or irr::u32 and irr::s32 with explicit namespace) are just typedefs for integer types with 32-bit size.
IrrlichtDevice documentation is here: http://irrlicht.sourceforge.net/docu/cl ... evice.html
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: difference between u32 vs s32 and pointer in irrlicht

Post by Mel »

-u32 and s32 are unsigned and signed 32 bits integers and can be used as such.
You should program more so you get used to pointers, classes and structs. :)
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
d3jake
Posts: 198
Joined: Sat Mar 22, 2008 7:49 pm
Location: United States of America

Re: difference between u32 vs s32 and pointer in irrlicht

Post by d3jake »

I agree with mel: Get used to working with classes and structs before using the engine; you'll thank yourself later.
The Open Descent Foundation is always looking for programmers! http://www.odf-online.org
"I'll find out if what I deleted was vital here shortly..." -d3jake
caiten
Posts: 6
Joined: Sun Sep 02, 2012 6:37 pm

Re: difference between u32 vs s32 and pointer in irrlicht

Post by caiten »

CuteAlien wrote:Hi caiten,

u32 and s32 (or irr::u32 and irr::s32 with explicit namespace) are just typedefs for integer types with 32-bit size.
IrrlichtDevice documentation is here: http://irrlicht.sourceforge.net/docu/cl ... evice.html
but i replace u32 and s32 in example :

Code: Select all

IrrlichtDevice *irrDevice = createDevice(EDT_OPENGL,
                                          dimension2d<irr::u32>(1000, 1000),
                                          16,
                                          false,
                                          true,
                                          0);
visual studio display:

1>main.cpp(25): error C2664: 'irr::createDevice' : cannot convert parameter 2 from 'irr::core::dimension2d<T>' to 'const irr::core::dimension2d<T> &'
1> with
1> [
1> T=irr::s32
1> ]
1> and
1> [
1> T=irr::u32
1> ]
1> Reason: cannot convert from 'irr::core::dimension2d<T>' to 'const irr::core::dimension2d<T>'
1> with
1> [
1> T=irr::s32
1> ]
1> and
1> [
1> T=irr::u32
1> ]
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: difference between u32 vs s32 and pointer in irrlicht

Post by hybrid »

Well, the error clearly says that you pass in s32, not u32. While your code fragment shows it different. So either you have some more createDevice somewhere, or you didn't compile the code you showed here.
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: difference between u32 vs s32 and pointer in irrlicht

Post by Mel »

C++ enforeces the strict usage of types, so you can't exchange from u32 to s32 in a template freely because they end being diferent types. And besides, it is not safe to cast s32 variables to u32 variables because there is the posibility that the sign can't be converted properly.

The createDevice function parameters have their own types, as all of the classes and structs in Irrlicht and in C++ in general, and you should use parameters of the proper type only. That is basic programming knowledge. Get used to it.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
caiten
Posts: 6
Joined: Sun Sep 02, 2012 6:37 pm

Re: difference between u32 vs s32 and pointer in irrlicht

Post by caiten »

thanksss all you
Post Reply