473,322 Members | 1,540 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Difference between "float" and "GLfloat" ?

Anyone know why for openGL applications must be used GLfloat (and GLint,
etc...) instead float, int, etc..?

thx,

Manuel
Dec 31 '05 #1
8 8855
Manuel wrote:
Anyone know why for openGL applications must be used GLfloat (and GLint,
etc...) instead float, int, etc..?

thx,

Manuel


Portability. The GL Red Book says:

"Implementations of OpenGL have leeway in selecting which C data type to
use to represent OpenGL data types. If you resolutely use the OpenGL
defined data types throughout your application, you will avoid
mismatched types when porting your code between different implementations."
Dec 31 '05 #2
W Marsh wrote:
Portability. The GL Red Book says:

"Implementations of OpenGL have leeway in selecting which C data type to
use to represent OpenGL data types. If you resolutely use the OpenGL
defined data types throughout your application, you will avoid
mismatched types when porting your code between different implementations."

Thanks.
But this is a problem with C++ too?
If I declare an "int" under windows, maybe different from an "int" under
linux or OSX ?
Regards,

Manuel
Dec 31 '05 #3
Manuel wrote:
W Marsh wrote:
Portability. The GL Red Book says:

"Implementations of OpenGL have leeway in selecting which C data type
to use to represent OpenGL data types. If you resolutely use the
OpenGL defined data types throughout your application, you will avoid
mismatched types when porting your code between different
implementations."


Thanks.
But this is a problem with C++ too?
If I declare an "int" under windows, maybe different from an "int" under
linux or OSX ?
Regards,

Manuel


It may be. Even a char can have more than 8-bits.
Dec 31 '05 #4

Manuel wrote:
W Marsh wrote:
Portability. The GL Red Book says:

"Implementations of OpenGL have leeway in selecting which C data type to
use to represent OpenGL data types. If you resolutely use the OpenGL
defined data types throughout your application, you will avoid
mismatched types when porting your code between different implementations."

Thanks.
But this is a problem with C++ too?
If I declare an "int" under windows, maybe different from an "int" under
linux or OSX ?


Yes. There is no requirement for an int to be the same size on every
platform.

sizeof returns a number of bytes. You are guaranteed that

sizeof char == 1
sizeof char <= sizeof short <= sizeof int <= sizeof long
CHAR_BIT >= 8

where CHAR_BIT, available by including the <climits> or <limits.h>
header, is the number of bits in a char (i.e. in a byte).

I believe there are also some *minimum* size guarantees for the
integral types. I'm not sure what they are, or whether they are
specified as a number of bits, a number of bytes, or a range of values
that must be accomodated.

Gavin Deane

Dec 31 '05 #5
Manuel wrote:
W Marsh wrote:
Portability. The GL Red Book says:

"Implementations of OpenGL have leeway in selecting which C data type
to use to represent OpenGL data types. If you resolutely use the
OpenGL defined data types throughout your application, you will avoid
mismatched types when porting your code between different
implementations."

Thanks.
But this is a problem with C++ too?
If I declare an "int" under windows, maybe different from an "int" under
linux or OSX ?


Yes. This is why there are typedefs in the various API's that use C
and C++ to nail this down on a particular implementation. Even in
the standard language we have things like size_t.

The later version of the C standard even includes some "predefined"
typedefs that assign traits to various integer types for example.
Dec 31 '05 #6
On 31 Dec 2005 06:37:11 -0800, "Gavin Deane" <de*********@hotmail.com>
wrote in comp.lang.c++:

Manuel wrote:
W Marsh wrote:
Portability. The GL Red Book says:

"Implementations of OpenGL have leeway in selecting which C data type to
use to represent OpenGL data types. If you resolutely use the OpenGL
defined data types throughout your application, you will avoid
mismatched types when porting your code between different implementations."

Thanks.
But this is a problem with C++ too?
If I declare an "int" under windows, maybe different from an "int" under
linux or OSX ?


Yes. There is no requirement for an int to be the same size on every
platform.

sizeof returns a number of bytes. You are guaranteed that

sizeof char == 1
sizeof char <= sizeof short <= sizeof int <= sizeof long
CHAR_BIT >= 8

where CHAR_BIT, available by including the <climits> or <limits.h>
header, is the number of bits in a char (i.e. in a byte).

I believe there are also some *minimum* size guarantees for the
integral types. I'm not sure what they are, or whether they are
specified as a number of bits, a number of bytes, or a range of values
that must be accomodated.


They are specified by a range of values, but if look at the binary
representation of the values you can easily work out the minimum
number of bits, although the actual bit usage may be greater because
padding bits are allowed in all but the "char" types.

You can see the ranges for all the integer types, including the C
"long long" type that is not part of C++, yet, here:

http://www.jk-technology.com/c/inttypes.html#limits

You can easily work out the required minimum number of bits from the
required ranges:

char types, at least 8 bits
short int, at least 16 bits
int, at least 16 bits
long, at least 32 bits
long long (C since 1999, not official in C++) 64 bits

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Jan 1 '06 #7
Jack Klein wrote:
You can see the ranges for all the integer types, including the C
"long long" type that is not part of C++, yet, here:

http://www.jk-technology.com/c/inttypes.html#limits

You can easily work out the required minimum number of bits from the
required ranges:

char types, at least 8 bits
short int, at least 16 bits
int, at least 16 bits
long, at least 32 bits
long long (C since 1999, not official in C++) 64 bits


Thanks Jack. A useful reference.

Gavin Deane

Jan 1 '06 #8
Ron Natalie wrote:
But this is a problem with C++ too?
If I declare an "int" under windows, maybe different from an "int"
under linux or OSX ?

Yes. This is why there are typedefs in the various API's that use C
and C++ to nail this down on a particular implementation. Even in
the standard language we have things like size_t.


Thanks.
But I've some difficult yo understand the problem.

Maybe a loop go "out of size"?
The problem is not limited to openGL, but it is about all multiplatform
application?
If yes...how solve the problem without using GLtypes?

Can you show an example where using various "int types" can crash or
ruin the application?

Thanks!

Jan 2 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

34
by: yensao | last post by:
Hi, I have a hard time to understand difference and similarities between Relational database model and the Object-Oriented model. Can somebody help me with this? Thank you in advance. ...
21
by: b83503104 | last post by:
Hi, Can someone tell me the difference between single quote and double quote? Thanks
26
by: Frank | last post by:
For my website i would like to display the age of my son in years, months, days and hours. For now i manage to get a result for totals. Like the total number of days. This is the beginning: ...
21
by: Rich | last post by:
I was considering C# for developing a scientific application, but I have noticed a ~30% difference between VC++ .NET and C# on the same machine, under identical conditions: double a = 0,b = 0, c...
4
by: jamesyreid | last post by:
Hi, I'm really sorry to post this as I know it must have been asked countless times before, but I can't find an answer anywhere. Does anyone have a snippet of JavaScript code I could borrow...
3
by: bbawa1 | last post by:
Hi, I have a table which has a field ItemsReceived of type datetime. I have a grid view which has two columns. In first column i have to show the data from field ItemsReceived and in second...
12
by: Petronius | last post by:
Hallo, does anyone have an idea how to implement difference lists in Javascript? Thanks allot in advance
5
by: Julius | last post by:
Hej dudes, I need to calc the difference between two timestamps / dates ... For example what i need to calculate: Date 1: 2007.11.06 - 20:13:04 Date 2: 2007.11.07 - 21:13:04 Difference:...
9
by: viki1967 | last post by:
Hi all! This new forum its great! :) Congratulations !!! My answer: why this my code not working? Nothing error but not work the difference.... : <html>
11
by: cmb3587 | last post by:
I have two arrays and I'm trying to create a 3rd array that is the difference between the two arrays Ex: arrayA: 3 5 8 9 arrayB: 3 4 6 9 difference of A-B: 5 8 however, my...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.