Page 1 of 3 123 LastLast
Results 1 to 10 of 23

Thread: Whats the deal with "byte"?

  1. #1
    Senior Member Regular Contributor
    Join Date
    May 2002
    Posts
    189

    Whats the deal with "byte"?

    I've been reading tutorials on loading MD2's and they say things like "byte vertices[3]" They are visual c++ tutorials too (I'm using Visual C++). However, when I try to do byte vertices[3] in my code it whines and complains. I asked a friend and he said to just use unsigned chars instead. Will they act the same exact way? When I multiply em and stuff will they act the same as a "byte"? Thanks

  2. #2
    Member Contributor
    Join Date
    Apr 2002
    Posts
    94

    Re: Whats the deal with "byte"?

    They should behave the same. A byte is always 8 bits so "unsigned char" should work the same since it is also 8 bits.
    P4 2Ghz, GEFORCE4, 512 Meg RAM, WIN2000, VStudio 6.0

  3. #3
    Member Contributor
    Join Date
    Jun 2001
    Posts
    64

    Re: Whats the deal with "byte"?

    Learn assembly language and you will see why
    people use typedefs like byte, word, and dword.

  4. #4
    Senior Member Regular Contributor
    Join Date
    May 2002
    Posts
    189

    Re: Whats the deal with "byte"?

    Or better than learning assembly language, how about you teach me assembly language?

    Well ok I guess I'll keep trying with chars

  5. #5
    Junior Member Newbie
    Join Date
    Sep 2002
    Posts
    28

    Re: Whats the deal with "byte"?

    Originally posted by 31337:
    I asked a friend and he said to just use unsigned chars instead. Will they act the same exact way? When I multiply em and stuff will they act the same as a "byte"? Thanks
    They 'should' act the same, but I'd recommend creating a header file w/ all the standard types (unsigned/signed char, unsigned/signed int, double, float, etc.) typedef'd. The reason being that an 'int' is not necessarily a 32-bit (4 byte) value. The same applies for the other types, so you need to account for that, assuming you're trying to be cross-platform.

    This becomes an issue when you try loading a file and dump it directly into a structure. If the size is not what you expected, you're in trouble.

  6. #6
    Member Contributor
    Join Date
    Dec 2001
    Location
    Raleigh, NC, USA
    Posts
    72

    Re: Whats the deal with "byte"?

    A "BYTE" is an unsigned char. Here is how it looks in the header.
    Code :
    //Some C/C++ header...
     
    typedef unsigned char BYTE;
    So using BYTE or usigned char will yield the result you need. By the way, aside from MD2 loading, you know anything about actually animating models? I can load and display/rotate/move them for hours, but I can't figure out animation.
    -Sephiroth

  7. #7
    Senior Member Regular Contributor
    Join Date
    May 2002
    Posts
    189

    Re: Whats the deal with "byte"?

    No sorry I havn't done animation yet (gametutorials.com has some great tutorials on it though)

    My question is this: I am fread()ing these "bytes" into unsigned chars, and then I need to multiply these unsigned chars by floats and I need to get floats. Is this going to work?

    I asked another programmer and he said it wouldn't. He said I would need to convert the binary numbers or something and I don't know what he's talking about. Oh well I'll just use unsigned chars for now I guess.

  8. #8
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: Whats the deal with "byte"?

    ... and then I need to multiply these unsigned chars by floats and I need to get floats. Is this going to work?
    Yes, it will work. The integer types will be converted to floats before multiplication, and the return type is, of course, a float.

  9. #9
    Senior Member Regular Contributor
    Join Date
    May 2002
    Posts
    189

    Re: Whats the deal with "byte"?

    Guys!!!! To use bytes you need to include windows.h, and seeing as how my game is for windows...

    So I included windows.h and now I'm using bytes.

  10. #10
    Member Contributor
    Join Date
    Dec 2001
    Location
    Raleigh, NC, USA
    Posts
    72

    Re: Whats the deal with "byte"?

    Not all compilers use "BYTE" typedefs. I have seen several that just give you the basic types with a few others, or just the basic types alone. I personally have all the types that I am aware of with Borland, but once again, each distro has it's own flavor, kind of like Linux.
    -Sephiroth

Page 1 of 3 123 LastLast

Similar Threads

  1. What's the deal with clEnqueueWriteBufferRect?
    By vincentfpgarcia in forum OpenCL
    Replies: 4
    Last Post: 01-30-2013, 02:55 AM
  2. What's the deal with SketchUp?
    By GiantBen in forum COLLADA
    Replies: 6
    Last Post: 07-06-2010, 06:05 PM
  3. So now whats the deal with openGL in linux?
    By in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 10-15-2004, 05:16 AM
  4. whats the deal with bitmaps
    By mdog1234 in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 01-23-2003, 08:33 AM
  5. Can't deal with systems DLL's
    By Bruno in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 05-04-2000, 10:32 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean