473,241 Members | 4,405 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,241 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 8841
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: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.