• 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.

Brad8383

24bit problems

14 posts in this topic

First the problem then the code. The problem is with my 24bit pixel plotting code. The results are something like using a 555 function with a 565 card. if red is 255 and g,b are 0 i get blue. If its only blue i get blue(obviously not a problem), and if its all green it turns out yellow. Now for the code. its set up right in 24bit, Pitch is the pitch, Buffer is a uchar value that holds ddsd.lpSurface. void SetPix24(int x, int y, int r, int g, int b) { PixAdr = (x+x+x)+y*Pitch; Buffer[PixAdr] = b; Buffer[PixAdr+1] = g; Buffer[PixAdr+2] = r; }
0

Share this post


Link to post
Share on other sites
It looks like you are using a BYTE array to do the work. Make a RGB struct and then use an RGB pointer. That way, you can handle 24 bit the same way you would handle 8 bit.

struct RGB24
{
BYTE blue;
BYTE green;
BYTE red;
};

RGB24 *buffer; // off screen buffer

void SetPixel24(int x, int y, RGB24 color)
{
int PixAddr = x + y * Pitch;
buffer[PixAddr] = color;
}

This will work in C++, should work in C with a few changes.
This is how I do it, but i you want to stick to your way, try PixAdr = (x + (y * Pitch)) * 3;

Domini
0

Share this post


Link to post
Share on other sites
buffer = (RGB24 *)ddsd.lpSurface;

When I redo my web page, I''ll include the source to a RGB16 and RGB24 class. Lots of overloaded operators and conversion stuff. Makes it so easy to do 16bit and 24 bit graphics.

Domini
0

Share this post


Link to post
Share on other sites
Well I got that somewhat working. I dont know why but i had to divide the pitch by 3 because plotting at 50,50 was really 50, 150. But the color problem is exactly the same as it was. Could you send me a small exe that plotted a single red pixel. If the pixel is red then the problem is my code and if it turns out blue then its my hardware.
0

Share this post


Link to post
Share on other sites
Try to find out the mask for each of the three colors (write them to a file , or something.).They''re in the DDPIXELFORMAT struct, I think you get the struct in some call to the surface, don''t remember wich, sorry.
There is a dwRBitMask (or something like that), a dwGBitMask and a dwBBitMask which should be something like 0xFF0000, 0x00FF00,0x0000FF for 24 bit(remember to write them if hex format). if they aren''t, your card either has a weird format or is in another format than 24 bit.
0

Share this post


Link to post
Share on other sites

You had to divide the pitch by three because pitch
is always the length of a line in bytes.
Because buffer is an RGB24*, buffer[PixAddr]
is the same physical memory location as
((BYTE *)buffer) + (PixAddr*3).

As for your color problem, try changing RGB24 to:

struct RGB24
{
BYTE red;
BYTE green;
BYTE blue;
};
0

Share this post


Link to post
Share on other sites
On every card have used, blue is first, and if Pitch is the width of the buffer in pixels you shouldn''t have to divide by anything. If Pitch is the (width * 3) that may be the problem.

Domini
0

Share this post


Link to post
Share on other sites
I think that Pitch is the lPitch from the ddsd struct, wich is the width of the image in bytes, not in pixels. So you have to divide by 2 for 16 bit color, 3 for 24, 4 for 32.
0

Share this post


Link to post
Share on other sites
Yeah he''s right. On my 16bit plotting code i divide by 2. But even when i get the coords right the colors are still distorted.
0

Share this post


Link to post
Share on other sites
Have you tried

void SetPixel24(int x, int y, RGB24 color)
{
int PixAddr = (x + x + x) + y * Pitch;
buffer[PixAddr] = color;
}

Pitch being 3 times the width and buffer being a RGB24 *
If that doesn''t work, the only thing I can think of, is somewhere in your code, PixAddr is has been either incremented or decremented, causing the alignment to be off. I believe blue is first, you can try switching it with red.

Domini
0

Share this post


Link to post
Share on other sites
Yep ive tried your methods and all the other peoples at xtreme games. Right now the code was set up to plot using 32bits and the last 8 being 0. It works on my friends computer perfectly. I have a stealth 2 s220 and it probably doesnt work right in 24bit. What would happen if i set it in 24bit mode without checking the errors and it didnt support it? Oh yeah and how can i tell if the card needs to use your RGB24 method(using exactly 24bits) and using 32 bits but having the last 8 set to 0?
0

Share this post


Link to post
Share on other sites
You have been using 32bit modes, not 24 bit ones. With the 32 bit modes I belive that extra 8 bits is an alpha channel. I don''t have much experience with 32 bit modes, but I''ll see what I can find out.

Domini
0

Share this post


Link to post
Share on other sites
Yes but when i tried 24bit with your RGB24 method and the method in TWGPG it gave the same results. Remember on some cards though 24bit is represented with 32 bits cause some cards cant address that way. At least thats what ive read. But anyway it works perfect on my friends computer and I do have an old card. Im not really going to use this anyway but I wanted to put it in my wrapper just to be complete.
0

Share this post


Link to post
Share on other sites
I am creating a windows wrapper that handles the overhead and Direct X. It works with 24 and 16 bit modes, so I have a RGB16 and a RGB24 and two sets of my graphics functions. You can do the same thing and call your RGB32 graphics functions if the mode is 32 bpp. I may add RGB32 to my wrapper.

Domini
0

Share this post


Link to post
Share on other sites