Jump to content
  • Advertisement


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


Artificial Palettes and a BS lPitch

This topic is 6948 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello all... I''m trying to code an artificial palette system so that I can use palette effects (such as fire, water) in a 16 bit RGB environment. i do it like this int Palette[256]; //full of RGB16BIT(r,g,b) values (integers) int surface[width*height]; //the surface And then draw to a DirectX surface by locking it and getting a pointer to the video memory... But problems arise... the ddsd.lPitch value is 2048!!! How can this be seeing as the surface is 640*480??? 2048 / 640 = 3.2!!! 3.2 bytes per pixel??? In 16 bit colour mode!!!??? What on earth is going on here? Also, when I lock the surface, each pixel *should* be 2 bytes, yes? because 16 bits = 2 bytes.... ..and an integer is 2 bytes also... but when I try to draw using this logic, absolutely nothing appears on the screen.... I AM GOING CRAZY *argh* (gasps for air) anyway, If anyone knows what is going on here, I would love to know! -wiseGuy-

Share this post

Link to post
Share on other sites
I think you are slightly misled... pitch is not necessarily (surface width * pixel size) in bytes. Pitch also can contain any arbitrary amount of extra padding that the drivers/video card want in order to make the surface fit nicely into the card''s architecture (usually a power of 2). That is why you have width and pitch separately, because you don''t know how much padding will be there.

And no, a standard ''int'' is not 2 bytes, unless you have an old system. In a 32-bit environment (or Windows 95 ), an int is 32 bits = 4 bytes. Does DirectX even run in a 16-bit environment? Your DirectX surface probably is 1280 bytes wide, with padding to make it up to 2048. Which will be difficult for your routine to copy the normal surface in there cos your normal surface is 2560 bytes wide... What you probably want is to use a short int if you''re doing 16 bit graphics. Hope that gives you some idea of what to change.

Share this post

Link to post
Share on other sites
(deadly silence...)

The penny drops.

Okay, I have learned what I know of C++ from textbooks that take a DOS approach, so forgive me on the 2 bytes account...

As for lPitch, well I guess I was a little confused...

So, in this magical world of 32 bits, what are some normal sizes? Is a char still one byte? (and for that matter, is a byte still eight bits?) So now a short is not 1 but 2 bytes...

Is there a table somewhere that I can find sizes of stuff (all my books say that an int is 2 bytes)?

And does this mean that when (if?) we have 64 bit operating systems, an int will be 8 bytes?

Am i even on the right track here?

But anyway: Thanks a heap Kylotan!


Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!