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

clrscr

Color

14 posts in this topic

Is there a way I can get OpenGL to use what most graphics programs use for color, i.e. instead of saying full red = 1.0,have full red = 256. If this post if confusing, let me know and I''ll try and clarify things. P.S. This is what I use for color now: glColor3f(0.0f,0.0f,0.0f); "You can observe a lot just by watching."- Yogi Berra
0

Share this post


Link to post
Share on other sites
How about making your own function:

  
void my_glColor3f(float r, float g, float b)
{
glColor3f((r/256),(g/256),(b/256));
}


Hope this helps...

---------------

I finally got it all together...
...and then forgot where I put it.
0

Share this post


Link to post
Share on other sites
In fact, i think that bitshifting right by 8 would be faster. I''m not sure about this, and the compiler may do it for you, but if you want to impress someone, do this:

  
void my_glColor3f(float r, float g, float b)
{
glColor3f((r>>8),(g>>8),(b>>8));
}


P.S. I may have this wrong...

---------------

I finally got it all together...
...and then forgot where I put it.
0

Share this post


Link to post
Share on other sites
Certainly. Use glColor3b or glColor4b. But do not do this. All 3D API''s convert integral color components, coordinates, and angles to floating-point internally, so there''s theoretically a performance hit to using integral values. Beyond that, eventually we''ll have more than 8 bits per channel, so 0 to 255 will no longer be enough. The 0.0 to 1.0 range is not only neutral to the actual color depth, but also happens to be in the API''s (and hardware also, most likely) native format. Furthermore, not "everyone" uses 0 to 255--in fact, I''d say that most people use floating-point. I don''t see how anything could be more intuitive than values that are effectively percentages; 50% of 0.0 to 1.0 = 0.5, as opposed to 50% = 128 of 0 to 255.

Use floating-point. Just get used to it and I promise that, eventually, you''ll never look back again. Soon everything will be floating point...
0

Share this post


Link to post
Share on other sites
Dividing by 256 would work, but NOT bitshifting. This is because you want to do floating-point division, not integer division. And when you divide, divide by 256.0 instead of 256 so that it will give you the fractional part. Otherwise you''ll get either 0 or 1.
0

Share this post


Link to post
Share on other sites
And to squeeze out every bit of nano seconds from your cpu...

Precompute the values in a table so instead of dividing everytime you want to set a calor which can at times be per vertex, you refernce to the index....

Unless dividing is very fast???
0

Share this post


Link to post
Share on other sites
quote:
P.S. I may have this wrong...


...what more can I say?

---------------

I finally got it all together...
...and then forgot where I put it.
0

Share this post


Link to post
Share on other sites

Do not divide by 256. You will get a slight performance hit out of it.

multiply by 0.00390625f or do what Admiral Binary stated and place all the values in a lookup table first

float c_lookup[256];
for(unsigned char j=0;j<256;j++)
c_lookup[j]=i*0.00390625f;

then when you use the colours, lets say you have a colour which is

unsigned char red=250;
unsigned char green=8;
unsigned char blue=97;

you would just use

glColour3f(c_lookup[red],c_lookup[green],c_lookup[blue]);





Beer - the love catalyst
good ol' homepage"

Edited by - Dredge-Master on December 13, 2001 11:52:58 PM
0
Just get comfortable with floating-point. Even multiplication and array access will introduce performance degradation. Just use floating-point; using integers to describe colors is archaic.
0

Share this post


Link to post
Share on other sites
Hi,

Modern OpenGL drivers are optimised for Q3, so storing the colour information in the same format as the game is almost guaranteed to be fastest.

4 bytes packed into an int, not floats. Also D3D takes colour in this form, so I think it''s the way to go.
0

Share this post


Link to post
Share on other sites
That''s a shortsighted way of thinking. Beyond that, not all drivers are optimized for Q3. In fact—arguably—no drivers are except for ATI''s. We also mustn''t forget that Windows is not the only OpenGL platform.
0

Share this post


Link to post
Share on other sites
I''d say go with the real numbers and then just have some constant that represents 1/256 (.00390625). While the video cards have 8bit color components, the API that rests on top of them work in a different number format, and those API are usually highly optomized by highly paid professionals, which means you probably couldn''t out do their code.

:: Inmate2993
:: William C. Bubel
"Please refrain from bothering Booster."
0

Share this post


Link to post
Share on other sites