Hey guys,
Thanks for your help, I was trying Omid's suggestions when I realized that something is actually being drawn, but incorrecly. In the center of the black screen is a very, very, very dark green (almost black, which is why I didn't see it with the sun shining on my monitor) rectangle in the middle of the screen. However, this is not my texture! I can't get pictures on the post or I would show you... It is almost the same color as the top left corner of the texture. However, when I change the color of the top left pixel in my texture the application renders a bizarre single color that seems to be some sort of mix between the colors of the changed pixel and the other colors. Just in case anything changed, I reposted my code:
void Engine::testrender(){ LPDIRECT3DTEXTURE9 texture; LPDIRECT3DVERTEXBUFFER9 g_pVB; if( FAILED( D3DXCreateTextureFromFile( m_d3dDevice, "test.bmp", &texture ) ) ) MessageBox(NULL, "Failed to load texture", "Error", MB_OK); m_d3dDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR ); m_d3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR ); CUSTOMVERTEX g_Vertices[] = { { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }, { 1.0f, 0.0f, 0.0f, 1.0f, 0.0f }, { 0.0f, 1.0f, 0.0f, 0.0f, 1.0f }, { 1.0f, 1.0f, 0.0f, 1.0f, 1.0f } /*{50.0f, 50.0f, 0.5f, 1.0f, 0.0f, 0.0f}, {250.0f, 50.0f, 0.5f, 1.0f, 16.0f, 0.0f}, {50.0f, 400.0f, 0.5f, 1.0f, 0.0f, 16.0f}, {250.0f, 400.0f, 0.5f, 1.0f, 16.0f, 16.0f}*/ }; if( FAILED( m_d3dDevice->CreateVertexBuffer( sizeof(g_Vertices) * sizeof(CUSTOMVERTEX), 0, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &g_pVB, NULL ) ) ) MessageBox(NULL, "Failed to create vb", "error", MB_OK); // Fill the vertex buffer. CUSTOMVERTEX* pVertices; if( FAILED( g_pVB->Lock( 0, 0, (void**)&pVertices, 0 ) ) ) MessageBox(NULL, "Failed to lock vb", "Error", MB_OK); // copy the vertices into the buffer memcpy( pVertices, g_Vertices, sizeof(g_Vertices) ); // unlock the vertex buffer g_pVB->Unlock(); D3DXMATRIX matView; // the view matrix D3DXMATRIX matProj; // the projection matrix D3DXVECTOR3 cameraPosition; // the position of the camera D3DXVECTOR3 cameraLook; /*D3DXMatrixPerspectiveFovLH(&matProj, D3DX_PI/4, 640/480, 0.1f, 50.0f); m_d3dDevice->SetTransform(D3DTS_PROJECTION, &matProj);*/ cameraPosition = D3DXVECTOR3(0.0f, 0.0f, -10.0f); cameraLook = D3DXVECTOR3(0.0f, 0.0f, 0.0f); D3DXMatrixLookAtLH(&matView, &cameraPosition, //Camera Position &cameraLook, //Look At Position &D3DXVECTOR3(0.0f, 1.0f, 0.0f)); //Up Direction m_d3dDevice->SetTransform(D3DTS_VIEW, &matView); m_d3dDevice->SetRenderState( D3DRS_LIGHTING, FALSE ); m_d3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE ); m_d3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE ); /*D3DXMATRIX matRot; D3DXMatrixRotationY(&matRot, timeGetTime()/1000.0f); D3DXMATRIX matWorld; D3DXMatrixMultiply(&matWorld, &matRot, &matView); pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );*/ if(FAILED(m_d3dDevice->SetTexture( 0, texture ))) MessageBox(NULL,"Couldn't set texture", "Error", MB_OK); if(FAILED(m_d3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX ))) MessageBox(NULL,"Couldn't set FVF", "Error", MB_OK); if(FAILED(m_d3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof(CUSTOMVERTEX) ))) MessageBox(NULL,"Couldn't set stream source", "Error", MB_OK); if(D3DERR_INVALIDCALL == (m_d3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 ))) MessageBox(NULL,"Error drawing","Error",MB_OK);}
Thanks for your help,
tlak