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

PsYcHoPrOg

16-Bit Shifting

4 posts in this topic

I did not understand several parts of the code that I looked at from one of the articles. One of those parts were the "N<<=1" in the for loop. The other part is in the next part, outside of the for loop. Why do the variables for the rgb16->position.rgbBlue, rgb->position.rgbRed, and rgb->position.rgbGreen equal what he made them equal. And why does rgb->position.rgbBlue = 0? Anyway, the code is in the next post. By the way, don''t comment on some of the syntax errors in the code. I took it directly from an article.
0

Share this post


Link to post
Share on other sites

<
char r=0, g=0, b=0;
for(int n = 1; n<65536; N<<=1)
{
IF(ddsd.ddpfPixelFormat.dwRBitMask & N)
++R;
IF(ddsd.ddpfPixelFormat.dwRBitMask & N)
++G;
IF(ddsd.ddpfPixelFormat.dwRBitMask & N)
++B;
}

// THIS IS THE PART THAT ASSUMES THE FORMAT IS RGB
RGB16->dwRBitMask = ddsd.ddpfPixelFormat.dwRBitMask;
rgb16->Position.rgbRed = g + b;

rgb16->dwGBitMask = ddsd.ddpfPixelFormat.dwGBitMask;
rgb16->Position.rgbGreen = b;

rgb16->dwBBitMask = ddsd.ddpfPixelFormat.dwBBitMask;
rgb16->Position.rgbBlue = 0;
>
0

Share this post


Link to post
Share on other sites
firstly N<<1 multiples N by 2. << is the shift left operator. ie it shifts the variable a certain number of places to the left. eg if you have the binary number 0010 and use 0010<<1 you get 0100. As each digit is a power of 2 this multiples the number by two. In the example 2 becomes 4. Hope that makes sense.

For the second part, this is because of how the colour information for the pixel is stored. For 16 bit pixels it is usually RRRRRGGGGGGBBBBB. The mask that DDraw returns is 1111100000000000 for red, 11111100000 for green and 11111 for blue. The for loop sets B to 5, G to 6 and R to 5 ie the number of bits for each colour value. BTW the code in the for loop is wrong, the second and third bitmasks should be for green and blue respectively.

The start position for red is therefore the number of bits for green and the number of bits for blue. ie g+b. The start position for green is the number of bits for blue ie b. As blue is the first colour its start position is 0.

This may be better explained in the 16bit pixel plotting articles here on GameDev.net under the developer resources section.

No sense being pessimistic. It wouldn''t work anyway.
0

Share this post


Link to post
Share on other sites
n<<=1 does this

for time thru n = 1 = 00000000000000000000000000000001b
after 1st n<<=1: n = 2 = 00000000000000000000000000000010b
after 2nd n<<=1: n = 4 = 00000000000000000000000000000100b
and so on...

65536 = 00000000000000010000000000000000b


color bits: RRRRRGGGGGGBBBBB for RGB16 565
red position starts after the blue and green bits.
green position starts after the blue bits.
blue position starts at the beginning.


maybe this''ll help somehow


0

Share this post


Link to post
Share on other sites