• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 303
  • Last Modified:

White looks blue and other colors look wrong in DirectX 8.1 using VB

I am using VB 6.0 and DirectX 8.1a to render scenes of 3D primitives.  In order to save the resulting images to file, I am using GetFrontBuffer and SaveSurfaceToFile with a device mode of D3DFMT_A8R8G8B8 (32-bit color).  The problem is that all of my color assignments are off.  My white's are cyan (128,255,255) and my other colors are off.  I imagine this has to do with using 32-bit color and not accounting for the alpha channel.  However, I get red when I give it either &HFFFF0000 or &HFF00FF00 or &HFF0000FF!  I'm obviously a beginner at this and must be missing something basic.  How can I get the colors I expect when assigning long values?  I have tried assigning materials and ambient lights without any effect.
0
BlueAlex
Asked:
BlueAlex
  • 3
  • 2
1 Solution
 
joachimcCommented:
It seems like you are not using the color values at all. Have you set an FVF that is using vertex colors ?
0
 
BlueAlexAuthor Commented:
My FVF declaration is as follows
Public Const FVF = D3DFVF_XYZRHW Or D3DFVF_TEX1 Or D3DFVF_DIFFUSE Or D3DFVF_SPECULAR

I describe my tranformed and lit vertices with
Type TLVERTEX
    x As Single
    y As Single
    z As Single
    rhw As Single
    color As Single
    specular As Long
    tu As Single
    tv As Single
End Type

All of the resultant colors are in the reds and greens with a little blue (as if I am shifted down or losing a few bits).  It seems like I am somehow getting confused with the 32-bit storage for DirectX colors (with the alpha channel).  I updated my graphics card drivers and even tried using DirectX 9 on a Windows 2000 machine but got the same result (so I'm sure it is a bug in my code).  
0
 
joachimcCommented:
I see that you are using color as Single. That is a floating point number isn't it ? The color should be the same as the specular. A long is a 32 bit unsigned integer ? In that case that is the one you want.

/Joachim
0
 
BlueAlexAuthor Commented:
That appears to be exactly the problem. Thanks!
0
 
joachimcCommented:
and the points ?
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now