   Triangle is all black problem
  Hey guys,I had this big problem that was trying to solve... it ended up being a lot more difficult then expected.Anyways I decided to simplify the problem... so I started to takes things out in my code and leave only the bare essentials.The problem now is that my triangle which I am rendering is coming out all black but I've clearly set a color for it.I have no idea why it is all black.Can you guys help with this?MAIN APPLICATION ENTRY#include "BaseWindow.h"#include "Direct3DUtility.h"#include "Camera.h"#include "Direct3DInput.h"#include "Skydome.h"BaseWindow *baseWindow = NULL;IDirect3DDevice9 *D3DDevice = NULL;Direct3DUtility *direct3DUtility = NULL;Camera *camera = NULL;Direct3DInput *direct3DInput = NULL;IDirect3DVertexBuffer9* VBSkydome = NULL;Skydome* skydome = new Skydome();//--- Function Prototypes ---//// ... Code omittedint WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd ){baseWindow = new BaseWindow;baseWindow->registerWindowClass();baseWindow->createWindow();direct3DUtility = new Direct3DUtility;direct3DUtility->init3D( hInstance, baseWindow->getHandle(), &D3DDevice );direct3DUtility->initDeviceState( &D3DDevice );camera = new Camera;camera->setCamView( &D3DDevice, D3DXVECTOR3( 0.0f, 0.0f, -5.0f ), D3DXVECTOR3( 0.0f, 0.0f, 0.0f ), D3DXVECTOR3( 0.0f, 1.0f, 0.0f ));camera->setCamProj( &D3DDevice );skydome = new Skydome();skydome->GenerateDome_1();initStars();baseWindow->show();direct3DInput = new Direct3DInput;direct3DInput->initDirectInput( hInstance, baseWindow->getHandle() );MSG msg;ZeroMemory( &msg, sizeof( MSG ));while( msg.message != WM_QUIT ){if( PeekMessage( &msg, 0, 0, 0, PM_REMOVE )){TranslateMessage( &msg );DispatchMessage( &msg );}else{updateGame();renderGame();Yield();}}UnregisterClass( baseWindow->getClassName(), hInstance );cleanUp();return 0;}void getInput(){// ... Code omitted}void renderGame(){D3DDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB( 255, 255, 255 ), 1.0f, 0 );D3DDevice->BeginScene();D3DDevice->SetStreamSource( 0, VBSkydome, 0, sizeof( skydome->getSkydomeVertices_1() ));D3DDevice->SetFVF( VERTEX_FVF_Sky );if( FAILED( D3DDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 1 ))){MessageBox( 0, "FAILED", 0, 0 );}D3DDevice->EndScene();D3DDevice->Present( NULL, NULL, NULL, NULL );}void updateGame(){SetCursorPos( 500, 400 );}void initStars(){void* ptr_Skydome;if( FAILED( D3DDevice->CreateVertexBuffer( 3 * sizeof( SkydomeVertex1 ), 0, VERTEX_FVF_Sky, D3DPOOL_MANAGED, &VBSkydome, NULL ) )){MessageBox( 0, "FAILED", 0, 0 );}if( FAILED( VBSkydome->Lock( 0, 3 * sizeof( skydome->getSkydomeVertices_1() ), ( void** ) &ptr_Skydome, 0 ))){MessageBox( 0, "FAILED", 0, 0 );}memcpy( ptr_Skydome, skydome->getSkydomeVertices_1(), 3 * sizeof( skydome->getSkydomeVertices_1() ));if( FAILED( VBSkydome->Unlock() )){MessageBox( 0, "FAILED", 0, 0 );}}void cleanUp(){// ... Code omitted}SKYDOME.H FILE#ifndef SKYDOME_H#define SKYDOME_H#include "SkydomeStruct.h"class Skydome{public:~Skydome();Skydome();void GenerateDome_1();SkydomeVertex1* getSkydomeVertices_1();int getNumVertices();private:int NumVertices;SkydomeVertex1 vertices1[ 3 ];};#endifSKYDOME.CPP FILE#include "Skydome.h"Skydome::~Skydome(){// ... Code omitted}Skydome::Skydome(){// .. Code omitted}void Skydome::GenerateDome_1(){Trace( "\n GenerateDome 1" );vertices1[ 0 ].setSky( D3DXVECTOR3( 0.0f, 0.5f, 1.0f ), D3DCOLOR_XRGB( 255, 0, 0 ));vertices1[ 1 ].setSky( D3DXVECTOR3( 0.5f, 0.0f, 1.0f ), D3DCOLOR_XRGB( 0, 255, 0 ));vertices1[ 2 ].setSky( D3DXVECTOR3( -0.5f, 0.0f, 1.0f ), D3DCOLOR_XRGB( 0, 0, 255 ));}SkydomeVertex1* Skydome::getSkydomeVertices_1(){return vertices1;}int Skydome::getNumVertices(){return NumVertices;}SKYDOMESTRUCT.H FILE#include <d3d9.h>#include <d3dx9.h>struct SkydomeVertex1{void setSky( D3DXVECTOR3 p, D3DCOLOR c ){pos = p;color = c;}D3DXVECTOR3 pos;    // vertex positionD3DCOLOR color;};#define VERTEX_FVF_Sky (D3DFVF_XYZ|D3DFVF_DIFFUSE)DIRECT3DUTILITY.CPP FILEvoid Direct3DUtility::initDeviceState( IDirect3DDevice9 **D3DDevice ){// Set default rendering states( *D3DDevice )->SetRenderState( D3DRS_LIGHTING, FALSE );( *D3DDevice )->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );}// ... The rest of the code for this class is omitted.Many thanks for any help you can offer here guys.   
( *D3DDevice )->SetRenderState( D3DRS_LIGHTING, FALSE );when there's no lighting doesn't it make sense that everything is black ? put out all light around you and see what color everything is ;)also notice : Quote:MSDN states next : D3DRS_LIGHTING    TRUE to enable Direct3D lighting, or FALSE to disable it. The default value is TRUE. Only vertices that include a vertex normal are properly lit; vertices that do not contain a normal employ a dot product of 0 in all lighting calculations. and unless I'm mistaken, you don't have normals...   ;  I have my light set to 'FALSE' because I wanted to use the default setting configuration set by DirectX.I just wanted to clarify this... when set to FALSE that means everything will be lit evenly basically yeh?And when you have it set to TRUE that means you are using your custom light settings, hence everything will be dark/black unless you have set lights/materials in your screen approriately.I am pretty sure this is correct... So yep in my screen my triangle should have color to it since my light is set to FALSE.I am pretty sure in this situation I don't need to worry about 'normals' yet (but correct me if I am wrong).I am keeping it simple, the vertices for my triangle has position and color. The color is definitely not black.Any other suggestions?   ;  What other D3D states are you setting?Do you set the texture to NULL?It's not lighting related, more than likely a renderstate not being set.   ;Quote:Original post by RabidDogWhat other D3D states are you setting?Nothing else. Only what I have in my code in OP is what I've set... so only 2 D3D states are being set (light = false, cull = none).Quote:Original post by RabidDogDo you set the texture to NULL?Ahhh... I have't loaded any textures at all. I am not applying any textures to the triangle. I am not completely sure if this is what you are asking...It's not lighting related, more than likely a renderstate not being set.   ;  I'm not sure what the default values are for the D3D states. I have a function that goes through and resets them to what I need. I'm looking through it to see what could cause this...Not sure if these will help, but they can't hurt.SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID );SetRenderState(D3DRS_SHADEMODE, D3DSHADE_GOURAUD );SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_DISABLE );RE the texture, you mentioned this was a cut down version of your original code, just wondered if something texture related may have been left in and it's just stretching a single black pixel over the triangle.   ;Quote:Original post by RabidDogRE the texture, you mentioned this was a cut down version of your original code, just wondered if something texture related may have been left in and it's just stretching a single black pixel over the triangle.Yeh my original code did have textures set and they did render as expected. I am cutting back my code to the bare essentials. My original code was trying to implement a sphere geometry (I am sure you have seen my numerous posts hehe).Yeh this is so fustrating ><I change a line of code to test something out... the result was nothing being render to the screen. So I reverted back to the old code and now nothing is being rendered at all now. Well, the background color for the window works as intended but the triangle that was originally there is not being rendered anymore, EVEN AFTER UNDOING THE CHANGES.The more I try to debug and fix my code... the worst it gets it seems ><I've decided to make a new project and copy and paste code incrementally over to see I can fix it that way at the moment.I will revisit this post in case you guys do happen to see where I have gone wrong in my code, in the meantime I start new project.So if its not too much trouble, and you have some worthwhile suggestions I would still have to hear from you :)   ;  Have you tried running the DirectX control panel and not only using the directx debug libs but bumping up the debug output.I can't remember if this is all you need to do or if you need to define a debug macro, but if it works it will print out some debugging info to the output window.   ;Quote:Original post by RabidDogHave you tried running the DirectX control panel and not only using the directx debug libs but bumping up the debug output.I can't remember if this is all you need to do or if you need to define a debug macro, but if it works it will print out some debugging info to the output window.Yep I have done this.When the application is running... there is no abnormal information I can see that is coming out.This is what shows when I ran the application btwIt is weird that is accepting my position information but not my color information ><I've finished starting fresh project btw and I get the same result regardless :(Any other possible suggestions?   ;  Hmmm, ok I got some info from the debug after bumping the debug output to max (it was on lowest before).I am gonna try to decipher this hopefully have this resolved.Quote:Direct3D9: (WARN) :Stream 0 stride and vertex size, computed from the current vertex declaration or FVF, are different, which might not work with pre-DX8 driversAt least I have something to work with here :)   