Skip to main content
gamedev.net
🔒 Locked

BYTE

Started by Marty666 16 replies 750+ views
Original Post
Marty666
Marty666
I''ve got a class that looks like this: class Landscape { public: Landscape(char* filename, int width, int height); ~Landscape(); void SetWidth(int NewWidth); void SetHeight(int NewWidth); int GetWidth(); int GetHeight(); Draw(); private: int Width, Height; BYTE Data[Width*Height]; }; when i change the last variable (DATA[Width*Height]) to int instead of BYTE it works just fine, but when i use BYTE it gives 8 errors: (16) : error C2146: syntax error : missing '';'' before (16) : error C2501: ''BYTE'' : missing storage-class or type specifiers (16) : error C2327: ''Landscape::Width'' : member from enclosing class is not a type name, static, or enumerator (16) : error C2065: ''Width'' : undeclared identifier (16) : error C2327: ''Landscape::Height'' : member from enclosing class is not a type name, static, or enumerator (16) : error C2065: ''Height'' : undeclared identifier (16) : error C2057: expected constant expression (16) : error C2501: ''Data'' : missing storage-class or type specifiers Error executing cl.exe. What is wrong? Thanx, Marty
_ /__ /|| | || MtY | ||_____|/Marty
lilKen
lilKen
beware , the compiler is case sensitive, because it doesnt recognize BYTE as a type of variable it considers it to be a variable , you should use byte instead of BYTE , anyway consider that the use of byte in that class might reduce the memory usage but also limits you to 256 levels of height?(byte is an integer type)


---
sorry for not using proper english , I'm from latin roots

[edited by - lilken on February 18, 2003 9:41:08 AM]
---sorry for not using proper english , I'm from latin roots
niyaw
niyaw
#include <windows.h>, or use 'unsigned char' instead. BYTE is not a build-in datatype in c++ as it is in pascal.

[edited by - niyaw on February 18, 2003 9:50:01 AM]
niyaw
niyaw
quote:
Original post by lilKen
beware , the compiler is case sensitive, because it doesnt recognize BYTE as a type of variable it considers it to be a variable , you should use byte instead of BYTE

c++ doesn''t define ''byte'' either. ''unsigned char'' is what would work.
niyaw
niyaw
yes, my mistake.
eldee
eldee
alternatively, you can
typedef BYTE unsigned char
but since there might be a possibility of clashing, you should
call it something else, like MYBYTE or something

-eldee
;another space monkey;
[ Forced Evolution Studios ]

::evolve::

Do NOT let Dr. Mario touch your genitals. He is not a real doctor!

Dtag
Dtag
the actual problem is that his variable Data is "dynamic" but it can only be static. You cant dynamically allocate a variable like this:
BYTE Data[Width*Height];
you'd need to define Data as a pointer to a byte array
byte *pData;
and when you know the width and height of the landscape, use pData=new byte[Width*Height];
remember to delete it using
delete [] pData;

[edited by - Dtag on February 18, 2003 10:22:30 AM]
Pipo DeClown
Pipo DeClown
quote:
Original post by Marty666
when i change the last variable (DATA[Width*Height]) to int instead of BYTE it works just fine, but when i use BYTE it gives 8 errors...


it works with ints

v0rtex
v0rtex
Use:
unsigned char Data[w*h];
or
#define BYTE unsigned char

BYTE and unsigned char *ARE* the same.
-------------------------------------------

Lords of Genesis | 3D Online RPG in development
http://www.lordsofgenesis.tk
Lords of Genesis | 3D Online RPG in developmenthttp://www.lordsofgenesis.tk
Marty666
Marty666
Thanx for all the replies, it works now... BYTE was indeed a windows.h thing.
Another problem came up. When i resize a glut window it turns gray, while the clearcolor is 0,0,0,0... it only happenes when I also do drawing (triangles or quads)in my glutDisplayFunc. Also when i resize the aspect changes, but i used the following code, windW and windH are GLint. FOV is a const GLint = 45.

GLfloat aspect = windW/windH;
gluPerspective(FOV, aspect, 1.0, 100.0);

Strange stuff eh? Sometimes (when I resize again the triangles or quads are partly visible).

Marty
_ /__ /|| | || MtY | ||_____|/Marty

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.