473,387 Members | 1,624 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,387 software developers and data experts.

define struct

Hello
what's going on here and some basic questions:
- define...unfortunately i haven't found it in my book so what exactly
does this?
- then SKYBOXVERTEX is declared...i understand the first struct but i
can only
guess what's going on from here on: SKYBOXVERTEX pBoxList[ 8 ] =
- I get the error: `WORD' undeclared (first use this function) Why? and
how shall I do it correctly?
THANKS and regards
Michael
#define BOXSIZE 384.0f*4.0f
#define BOXHEIGHT 256.0f*4.0f
#define BOXSTART -128.0f*4.0f

typedef struct
{
GLfloat x, y, z;
}SKYBOXVERTEX;
SKYBOXVERTEX pBoxList[ 8 ] =
{
{ -BOXSIZE, BOXSIZE, BOXSTART },
{ BOXSIZE, BOXSIZE, BOXSTART },
{ BOXSIZE, -BOXSIZE, BOXSTART },
{ -BOXSIZE, -BOXSIZE, BOXSTART },
{ -BOXSIZE, BOXSIZE, BOXSTART + BOXHEIGHT },
{ BOXSIZE, BOXSIZE, BOXSTART + BOXHEIGHT },
{ BOXSIZE, -BOXSIZE, BOXSTART + BOXHEIGHT },
{ -BOXSIZE, -BOXSIZE, BOXSTART + BOXHEIGHT },
};

#define nIndices (4 * 6)
WORD pIndices[ nIndices ] =
{
0, 1, 5, 4,
1, 2, 6, 5,
2, 3, 7, 6,
3, 0, 4, 7,
6, 7, 4, 5,
1, 0, 3, 2
};
Oct 14 '05 #1
2 4281
On Fri, 14 Oct 2005 10:14:27 +0200, Michael Sgier <sg***@nospam.ch>
wrote:
Hello
what's going on here and some basic questions:
- define...unfortunately i haven't found it in my book so what exactly
does this?
- then SKYBOXVERTEX is declared...i understand the first struct but i
can only
guess what's going on from here on: SKYBOXVERTEX pBoxList[ 8 ] =
- I get the error: `WORD' undeclared (first use this function) Why? and
how shall I do it correctly?
THANKS and regards
Michael
#define BOXSIZE 384.0f*4.0f From now on, if BOZSIZE appears, substitute it by 384.0f*4.0f

#define BOXHEIGHT 256.0f*4.0f
#define BOXSTART -128.0f*4.0f

typedef struct
{
GLfloat x, y, z;
}SKYBOXVERTEX;
SKYBOXVERTES is an alias for a struct formed by three GLfloats called
x,y and z
SKYBOXVERTEX pBoxList[ 8 ] =
pBoxList is a sequence of eight structures of the kind defined above
{
{ -BOXSIZE, BOXSIZE, BOXSTART }, The first, pBoxList[0], has an x=-384.0f*4.0f; and y and z
=384.0f*4.0f { BOXSIZE, BOXSIZE, BOXSTART },
{ BOXSIZE, -BOXSIZE, BOXSTART },
{ -BOXSIZE, -BOXSIZE, BOXSTART },
{ -BOXSIZE, BOXSIZE, BOXSTART + BOXHEIGHT },
{ BOXSIZE, BOXSIZE, BOXSTART + BOXHEIGHT },
{ BOXSIZE, -BOXSIZE, BOXSTART + BOXHEIGHT },
{ -BOXSIZE, -BOXSIZE, BOXSTART + BOXHEIGHT },
};

#define nIndices (4 * 6) Form now in, everywhere there is nIndices written, (4*6) is meant WORD pIndices[ nIndices ] = pIndices is a sequence of 4*6=24 WORD { whose values are, beginning with the first,
pIndices[0]=0,pIndices[1]=1,pIndices[2]=5;.... 0, 1, 5, 4,
1, 2, 6, 5,
2, 3, 7, 6,
3, 0, 4, 7,
6, 7, 4, 5,
1, 0, 3, 2
};

You should have read a C++manual, ot the FAQ of this list.
Oct 14 '05 #2
"Zara" <yo****@terra.es> wrote in message
news:ri********************************@4ax.com...
On Fri, 14 Oct 2005 10:14:27 +0200, Michael Sgier <sg***@nospam.ch>
wrote:
[snip]
- I get the error: `WORD' undeclared (first use this function) Why?
Probably because the WORD type is not defined anywhere.
and how shall I do it correctly?
WORD is not a native type so you need to define it ahead of where you use
it, and preferably before any structs as well. WORD is usually understood to
mean a 16-bit, or 2-byte, unsigned integer, so it's usual to typedef the
equivalent built-in type, e.g.,
typedef unsigned short WORD;

I've guessed that 'unsigned short' is 16 bits wide, but this depends on the
compiler.

Alternatively, forget WORD and just use a native type like unsigned int
instead, unless there's a reason it has to be a 16-bit type (highly unlikely
from what you've posted).
#define BOXHEIGHT 256.0f*4.0f
#define BOXSTART -128.0f*4.0f

typedef struct
{
GLfloat x, y, z;
}SKYBOXVERTEX;
[snip]
WORD pIndices[ nIndices ] =

You should have read a C++manual,
A C manual would be a better bet, I'd suggest. :-)
ot the FAQ of this list.


DW

Oct 14 '05 #3

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

Similar topics

3
by: theotyflos | last post by:
Hi all, I have the following: /*--- SNIP ---*/ typedef struct Argument_s { char *address; int type;
0
by: ooze | last post by:
typedef unsigned long PARAM; typedef PARAM SAP; typedef struct qnode { struct qnode *next; struct qnode *prev; } QNODE;
42
by: baumann | last post by:
hi all, typedef int (*pfunc)(int , int); pfunc a_func; i know it's ok, but how can define a_func without typedef statement? thanks .
5
by: Daniel Rudy | last post by:
What is the purpose of having a #define inside a struct? typedef struct { uByte bLength; uByte bDescriptorType; uWord wTotalLength; uByte bNumInterface;...
10
by: Ben | last post by:
Hello, Is it possible to define a struct that has a type of itself in it? So is it possible and if so how to do what I'm trying to do here?: typedef struct mystruct { int a; mystruct *b;...
12
by: djhong | last post by:
Following is a snippet of a header file. Here, #define are inside struct evConn{} Any advantage of putting them inside struct block? Looks like there is no diff in scoping of each...
4
by: _mario.lat | last post by:
for struct: struct in6_addr { uint8_t s6_addr; }; is provided a costant: #define IN6ADDR_LOOPBACK_INIT {{{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}}} what does means {{{, and }}}?
23
by: anon.asdf | last post by:
Hello! In the following code-snippet, is it possible to initialize each element of arr, with STRUCT_INIT? struct mystruct { int a; char b; };
5
by: maker.rain1 | last post by:
Hello All, I have come across a problem as explained below in a sample. Please help me if anyone has any ideas to solve this. I have a #define as defined below. #define MAX 200 int...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.