Archived

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

Why No Blue...

This topic is 5648 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

Can anyone assist. I have setup and rendered a spinning box...that works fine. I used the RGBA color set yellow to start... again, no problem, I got a nice yellow spinning box. I can get Red, and Green and mixtures of the two, BUT as soon as I set them to Blue I get the background color...ie No color. The Alpha setting is correct. Any ideas? Oh, and the hardware is working fine. Cheers SpRiTe Snippet of code Initialization below: D3DPRESENT_PARAMETERS d3dpp; D3DDISPLAYMODE d3ddm; D3DXMATRIX matProj, matView; D3DLIGHT8 Light; BYTE *Ptr; sVertex Verts[16] = { { -100.0f, 100.0f, -100.0f, 0.0f,0.0f,-1.0f, D3DCOLOR_RGBA(255,255,255,255) }, { 100.0f, 100.0f, -100.0f, 0.0f,0.0f,-1.0f, D3DCOLOR_RGBA(255,255,255,255) }, { -100.0f, -100.0f, -100.0f, 0.0f,0.0f,-1.0f, D3DCOLOR_RGBA(255,255,255,255) }, { 100.0f, -100.0f, -100.0f, 0.0f,0.0f,-1.0f, D3DCOLOR_RGBA(255,255,255,255) }, { 100.0f, 100.0f, -100.0f, 1.0f,0.0f,0.0f, D3DCOLOR_RGBA(255,255,255,255) }, { 100.0f, 100.0f, 100.0f, 1.0f,0.0f,0.0f, D3DCOLOR_RGBA(255,255,255,255) }, { 100.0f, -100.0f, -100.0f, 1.0f,0.0f,0.0f, D3DCOLOR_RGBA(255,255,255,255) }, { 100.0f, -100.0f, 100.0f, 1.0f,0.0f,0.0f, D3DCOLOR_RGBA(255,255,255,255) }, { 100.0f, 100.0f, 100.0f, 0.0f,0.0f,1.0f, D3DCOLOR_RGBA(255,255,255,255) }, { -100.0f, 100.0f, 100.0f, 0.0f,0.0f,1.0f, D3DCOLOR_RGBA(255,255,255,255) }, { 100.0f, -100.0f, 100.0f, 0.0f,0.0f,1.0f, D3DCOLOR_RGBA(255,255,255,255) }, { -100.0f, -100.0f, 100.0f, 0.0f,0.0f,1.0f, D3DCOLOR_RGBA(255,255,255,255) }, { -100.0f, 100.0f, 100.0f, -1.0f,0.0f,0.0f, D3DCOLOR_RGBA(255,255,255,255) }, { -100.0f, 100.0f, -100.0f, -1.0f,0.0f,0.0f, D3DCOLOR_RGBA(255,255,255,255) }, { -100.0f, -100.0f, 100.0f, -1.0f,0.0f,0.0f, D3DCOLOR_RGBA(255,255,255,255) }, { -100.0f, -100.0f, -100.0f, -1.0f,0.0f,0.0f, D3DCOLOR_RGBA(255,255,255,255) } }; // Do a windowed mode initialization of Direct3D if((g_pD3D = Direct3DCreate8(D3D_SDK_VERSION)) == NULL) return FALSE; if(FAILED(g_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm))) return FALSE; ZeroMemory(&d3dpp, sizeof(d3dpp)); d3dpp.Windowed = TRUE; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.BackBufferFormat = d3ddm.Format; d3dpp.EnableAutoDepthStencil = TRUE; d3dpp.AutoDepthStencilFormat = D3DFMT_D16; if(FAILED(g_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &g_pD3DDevice))) return FALSE; // Set the rendering states g_pD3DDevice->SetRenderState(D3DRS_LIGHTING, TRUE); g_pD3DDevice->SetRenderState(D3DRS_ZENABLE, TRUE); // Create and set the projection matrix D3DXMatrixPerspectiveFovLH(&matProj, D3DX_PI/4.0f, 1.33333f, 1.0f, 1000.0f); g_pD3DDevice->SetTransform(D3DTS_PROJECTION, &matProj); // Create and set the view matrix D3DXMatrixLookAtLH(&matView, \ &D3DXVECTOR3(0.0f, 0.0f, -500.0f), \ &D3DXVECTOR3(0.0f, 0.0f, 0.0f), \ &D3DXVECTOR3(0.0f, 1.0f, 0.0f)); g_pD3DDevice->SetTransform(D3DTS_VIEW, &matView); // Create the vertex buffer and set data g_pD3DDevice->CreateVertexBuffer(sizeof(sVertex)*16, 0, \ VERTEXFVF, D3DPOOL_DEFAULT, &g_pVB); g_pVB->Lock(0,0, (BYTE**)&Ptr, 0); memcpy(Ptr, Verts, sizeof(Verts)); g_pVB->Unlock(); // Set light data, color, position, and range ZeroMemory(&Light, sizeof(Light)); Light.Type = D3DLIGHT_POINT; Light.Diffuse.r = Light.Ambient.r = 0.5f; Light.Diffuse.g = Light.Ambient.g = 0.5f; Light.Diffuse.b = Light.Ambient.b = 0.0f; Light.Diffuse.a = Light.Ambient.a = 1.0f; Light.Range = 1000.0f; Light.Attenuation0 = 0.5f; Light.Position.x = 300.0f; Light.Position.y = 0.0f; Light.Position.z = -600.0f; // Set and enable the light g_pD3DDevice->SetLight(0, &Light); g_pD3DDevice->LightEnable(0, TRUE); return TRUE;

Share this post


Link to post
Share on other sites