• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Archived

This topic is now archived and is closed to further replies.

Aldacron

32bit TGA loader

9 posts in this topic

I don't have any tutorials, but I can offer advice via email if you're interested in working out where you're going wrong - I can probably also send you a few snippets of source. I've never read in compressed files, but from what I understand they just use simple RLE encoding. Also you might want to check out Truevision's official specification which you can get in PDF format, if you haven't already. My address is phoenix@divineweb.com, if you're interested.

Regards

Starwynd

0

Share this post


Link to post
Share on other sites
Thanks, but I finally got it working. For some reason my header struct was weighing in at 20 bytes, although it should have been 18. I still can't figure what I did wrong. Anyway, I just loaded the header a byte at a time and everything works now.
0

Share this post


Link to post
Share on other sites
Well, if you want to make your life that much easier, this is why you had a 20 byte struct when you only specified 18: struct alignment. The compiler tries to make access easier on your program by aligning members of structures on certain boundaries. In Visual C++ 6.0 the default is 8-bte boundaries. This will cause the compiler to add padding to the struct in the middle to make it nice. If you have Visual C++, you can use:

#pragma pack(push, original)
#pragma pack(1)

right before the structure definition and:

#pragma pack(pop, original)

right after, and that will change the struct alignment to 1-byte, which is exactly what you need.

- Splat

0

Share this post


Link to post
Share on other sites
Yeah. Reading will go a long way to helping you program. Right now, almost find the best way to learn more (aside from programming my game engine / game) is to traverse these messageboards and try to solve EVERYONE's problem, no matter how hard. I mean, I've posted 32 (now 33) messages since I found this place 2.5 weeks ago. And I've learned A LOT.

- Splat

0

Share this post


Link to post
Share on other sites
Explain how you came up with 20 bytes... if the compiler packs to 8-byte boundries, wouldn't it either be 16 or 24 bytes?

Are you sure you didn't have a regular int somewhere where you needed a short int or something?

Mason McCuskey
Spin Studios
www.spin-studios.com

[This message has been edited by mason (edited October 26, 1999).]

0

Share this post


Link to post
Share on other sites
I am curious of how it was packed to 20 as well.

The default packing size for Win32 (or 95/NT) is at 8 byte boundries.

If you are using Win 3.X the packing size is at 2 byte boundries, which would have kept the size at 18.

-Gilderoot

[This message has been edited by Gilderoot (edited October 26, 1999).]

0

Share this post


Link to post
Share on other sites
mason: Trust me on this one - he had the structure right. How do I know? Because I didn't believe him and wrote the struct out to spec, and found it's size was 20. The key thing to understand is that the 8-byte alignment setting is the maximum data type that the compiler will align on a data type boundary.

So, say we have a short (2 byte). Ideally, we want its address to be a multiple to 2 (aligned). Or a long (4 bytes) on a multiple of 4. What 8-byte alignment says is that: "compiler, you can align any data type that is less than or equal to 8 bytes"

So if it gets an 8 byte data member that is off by one byte forward, it will add its maximum of 7 bytes padding to get that type on an 8 byte boundary.

With the TGA header, the first short is 3 bytes in (unaligned). There goes one byte padding. Then, after than padding, the third short is 9 bytes in, so we have another byte of padding. This pushes the key elements of width, height, and bits per pixel exactly one short back, which really messes up your header ;(

However, setting the compiler's packing settings fixes all this. In fact, in the Windows header files they use this setting for several key structures that are commonly read in from files.

- Splat

Oh yeah, Gilderoot, the packing size of 2 bytes would NOT work because the compiler would still align the shorts (which are 2 bytes)

[This message has been edited by Splat (edited October 26, 1999).]

0

Share this post


Link to post
Share on other sites
I did a sizeof to get the 20 byte result. I triple checked my struct with the TGA specs and was at a total loss.

Of course, when I made the call with an 18 instead of sizeof(TGA_HEADER), the results were fine for the first few entries, but got out of whack near the middle. Now I understand why, thanks to the explanation from Splat.


0

Share this post


Link to post
Share on other sites
Can anyone point me to a 32bit TGA loader, or perhaps a tutorial on how to write one? My attempts repeatedly fail and I'm getting frustrated.

Thanks.

0

Share this post


Link to post
Share on other sites