Hello all,
I'm trying to use a class from Intel called SPVector3.
It hass some optimiztions for Vector Math that uses SSE.
The problem is that its declared like this:
class SPVector3 {
public:
union {
__m128 vec;
struct {
float x,y,z;
// float _spacer_;
};
};
SPVector3() {}
SPVector3(const SPVector3& v) : vec(v.vec) {}
SPVector3(const __m128 &m) : vec(m) {}
SPVector3(const F32vec4 &m) : vec(m) {}
SPVector3(const float x, const float y, const float z) :
vec(F32vec4(0.0f,z,y,x)) {}
SPVector3(const float *arr) :
vec(_mm_loadl_pi(_mm_movelh_ps(_mm_load_ss(arr+2), _mm_load_ss(arr+2)),
(__m64*)arr)) {}
operator __m128() const { return vec; }
operator F32vec4() const { return vec; }
// functions and operators...
};
But I need to pass a pointer to an opengl fuction that looks like:
void glVertexPointer(
GLint size, //The number of coordinates per vertex
GLenum type, //The data type of each coordinate in the array
GLsizei stride, //The byte offset between consecutive vertices
const GLvoid *pointer
);
How can I convert from SPVector3 to this pointer ?
wpr 2 2055
"whisper" <ml**********@yahoo.com.br> wrote in message
news:6a**************************@posting.google.c om... I'm trying to use a class from Intel called SPVector3. It hass some optimiztions for Vector Math that uses SSE.
The problem is that its declared like this:
class SPVector3 { public: union { __m128 vec; struct { float x,y,z; // float _spacer_; }; };
.... };
But I need to pass a pointer to an opengl fuction that looks like:
void glVertexPointer( GLint size, //The number of coordinates per vertex GLenum type, //The data type of each coordinate in the array GLsizei stride, //The byte offset between consecutive vertices const GLvoid *pointer );
This should not be a problem (leaving portability aside).
My guess would be to try:
- size = 3.
- type = GL_FLOAT or something like that.
- stride = sizeof(SPVector3)
- pointer = address of the first element (or & firstElem->x)
-- http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form
whisper wrote: Hello all,
I'm trying to use a class from Intel called SPVector3. It hass some optimiztions for Vector Math that uses SSE.
The problem is that its declared like this:
class SPVector3 { public: union { __m128 vec; struct { float x,y,z; // float _spacer_; }; };
SPVector3() {} SPVector3(const SPVector3& v) : vec(v.vec) {} SPVector3(const __m128 &m) : vec(m) {} SPVector3(const F32vec4 &m) : vec(m) {} SPVector3(const float x, const float y, const float z) : vec(F32vec4(0.0f,z,y,x)) {} SPVector3(const float *arr) : vec(_mm_loadl_pi(_mm_movelh_ps(_mm_load_ss(arr+2), _mm_load_ss(arr+2)), (__m64*)arr)) {} operator __m128() const { return vec; } operator F32vec4() const { return vec; }
// functions and operators... };
But I need to pass a pointer to an opengl fuction that looks like:
void glVertexPointer( GLint size, //The number of coordinates per vertex GLenum type, //The data type of each coordinate in the array GLsizei stride, //The byte offset between consecutive vertices const GLvoid *pointer );
How can I convert from SPVector3 to this pointer ?
SPVector3 only contains one vector, not an array of vectors, which would be
what glVertexPointer expects, unless you really want an array with only one
single vector. If you have an array of SPVector3, you should be able to do:
glVertexPointer(3, GL_FLOAT, sizeof(SPVector3), yourarray);
Btw, I'd say this is more an OpenGL question than a standard C++ question,
so x-post and f'up2 comp.graphics.api.opengl. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: David |
last post by:
Some developers in my group are using UNIONS to define their data
types in a C++ program for an embedded system. Are there any pro and
cons in doing this when you can define a CLASS to do the same...
|
by: Neil Zanella |
last post by:
Hello,
I would like to know whether the following C fragment is legal in
standard C and behaves as intended under conforming implementations...
union foo {
char c;
double d;
};
|
by: rohit |
last post by:
Hi,
In my couple of years of experience, I have never found a single
instance where I needed to use unions and bitfields(though I have used
structures).I was just imagining where would these find...
|
by: Koen |
last post by:
Hi!
Does anyone know what the standard says about the way unions are
stored in C? I mean the following:
Let's say you have a union with a double and a char field:
union MyUnion_t
{
double...
|
by: qwerty2_reverse_iterator |
last post by:
Is this a bug with the ms compiler (V7.1)? (It seems so at least.)
I get errors when I don't initialize all the const pointer fields of an
anonymous union in a struct. Example:
//T2.h...
|
by: Hallvard B Furuseth |
last post by:
I'm getting horribly lost in the strict aliasing rules.
Is this code correct?
struct A { int x; };
struct B { int x, y; };
int foo( struct A *a ) {
struct B *b = (struct B *) a;
return b->x...
|
by: bluejack |
last post by:
A recent post asking for help with unions reminded me of this
component of the C language that I have only used a couple of times,
and those almost entirely out of personal whim -- Unions for the...
|
by: Old Wolf |
last post by:
Ok, we've had two long and haphazard threads about unions recently,
and I still don't feel any closer to certainty about what is permitted
and what isn't. The other thread topics were "Real Life...
|
by: Chad |
last post by:
Okay, so like recently the whole idea of using a Union in C finally
sunk into my skull. Seriously, I think it probably took me 2 years to
catch on what a Union really is. Belated, I mentioned this...
|
by: pereges |
last post by:
Hello, can some one please guide me a little into using unions. I read
about unions in K & R but I am finding it difficult to apply to my
problem at hand. I want to save up some space by using...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |