   Win32 Question
  I am in the middle of attempting to create a WIN32 program that creates two 3D wire cubes and positions them in 3D space.  I am doing this so I have to create the functions to rotate, translate, and convert to screen space.  Here is my problem.  I am getting nothing to show up on my screen.  It doesn't make any since.  The only thing that shows up is 0 FPS, but I implemented logging and it is definately cycling through the program correctly.  If anyone can help me I would greatly appreciate it.//Main.cpp#include "CPolygon.h"#include <windows.h>#include "Vector3.h"#include "Cube.h"#include "Win32.h"int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow){Engine *g_engine = new Engine();if(!g_engine->InitEngine(hInstance, lpCmdLine, iCmdShow)){::MessageBoxA(0,"Engine could not be initialized","Error",MB_OK);return 0;}g_engine->BeginGame();if(!g_engine->ShutDown()){::MessageBox(0,"Game could not be shut down", "Error",MB_OK);}delete g_engine;return 0;}//Win32.cpp#include "Win32.h"#include "resource.h"Engine::Engine(){DisableLogging();WriteToLog("Constructor for engine entered");m_hWnd = NULL;width = 400;height = 400;degrees = 60;m_hWnd = NULL;  //Main window handle;m_hdcFrameBuffer= NULL;//Frame Buffer Device Contextm_hbmFrameBuffer= NULL;//Frame buffers Bitmapm_hbmSelectOut = NULL;cubes[0] = new Cube(4);cubes[1] = new Cube(6);cubes[0]->WorldPos.x = 8;cubes[0]->WorldPos.y = 7;cubes[0]->WorldPos.z = 12;cubes[1]->WorldPos.x = -8;cubes[1]->WorldPos.y = -7;cubes[1]->WorldPos.z = 25;}Engine::~Engine(){WriteToLog("Engine Destructor");delete cubes[0];cubes[0] = NULL;delete cubes[1];cubes[1] = NULL;//Destructor}bool Engine::InitEngine(HANDLE hInstance, LPCTSTR lpCmdLine, int iCmdShow){WriteToLog("Initializing Engine");PI = 3.141592654f;if(!CreateWin())return false;//Set view matrix to equal 0//Set projection matrix to all 0'sfor(int i = 0; i<4; i++){for(int j = 0; j<4; j++){viewMatrix[j] = 0;projMatrix[j] = 0;}}//Create Projection matrix with 60 degree viewportfloat AspectRatio = (float)width/height;double radians = degrees * (PI/180);projMatrix[0][0]=(float)(1/(tan(radians/2)*AspectRatio));projMatrix[1][1]=(float)(1/(tan(radians/2)));projMatrix[2][2] = 1;return true;}bool Engine::CreateWin(){WriteToLog("Creating Window");LPTSTR WindowTitle = _T("Adam Larson's Software Render");USHORTWidth = 400;USHORTHeight = 400;HDChDC = NULL;RECT rc;//Register the new windows classWNDCLASS wc;wc.style= CS_BYTEALIGNCLIENT | CS_HREDRAW | CS_VREDRAW;wc.lpfnWndProc= StaticWndProc;wc.cbClsExtra= 0;wc.cbWndExtra= 0;wc.hInstance= (HINSTANCE)GetModuleHandle(NULL);wc.hIcon= LoadIcon(wc.hInstance, MAKEINTRESOURCE(IDI_ICON));wc.hCursor= LoadCursor(NULL, IDC_ARROW);wc.hbrBackground= (HBRUSH) GetStockObject(BLACK_BRUSH);wc.lpszClassName= WindowTitle;wc.lpszMenuName = NULL;RegisterClass(&wc);//Create the rendering windowm_hWnd = CreateWindow(WindowTitle, WindowTitle, WS_OVERLAPPEDWINDOW,CW_USEDEFAULT, CW_USEDEFAULT, Width, Height, NULL,LoadMenu( wc.hInstance,MAKEINTRESOURCE(IDR_MENU1)),wc.hInstance,this);if(!m_hWnd)return false;//Retrieve teh final client size of the window::GetClientRect(m_hWnd, &rc );m_nViewX= rc.left;m_nViewY= rc.top;m_nViewWidth= rc.right - rc.left;m_nViewHeight= rc.bottom-rc.top;//Build the frame bufferif(!BuildFrameBuffer(width, height))return false;//Show the windowShowWindow(m_hWnd, SW_SHOW);//Successreturn true;}bool Engine::BuildFrameBuffer(ULONG Width, ULONG Height){WriteToLog("Entering BuildFrameBuffer");HDC hDC = ::GetDC( m_hWnd );if(!m_hdcFrameBuffer ) m_hdcFrameBuffer = ::CreateCompatibleDC( hDC );//Create a bitmap that is compatible with the application windowm_hbmFrameBuffer = CreateCompatibleBitmap( hDC, Width, Height );if( !m_hbmFrameBuffer )return false;//Select bitmap into the device contextm_hbmSelectOut = (HBITMAP)::SelectObject(m_hdcFrameBuffer, m_hbmFrameBuffer);//Release the window DC and set the frame buffer DC so that it renders transparently::ReleaseDC( m_hWnd, hDC );::SetBkMode( m_hdcFrameBuffer, TRANSPARENT );return true;}void Engine::ClearFrameBuffer(ULONG Color){WriteToLog("Entering ClearFrameBuffer");    LOGBRUSH logBrush;    HBRUSH   hBrush = NULL, hOldBrush = NULL;   // Set up the rendering brush    logBrush.lbStyle = BS_SOLID;   // Set up the colour, converted to BGR & stripped of alpha    logBrush.lbColor = 0x00FFFFFF & RGB2BGR( Color );   // Create the rendering brush    hBrush = ::CreateBrushIndirect( &logBrush );    if (!hBrush) return;    // Select into the frame buffer DC    hOldBrush = (HBRUSH)::SelectObject( m_hdcFrameBuffer, hBrush );    // Draw the rectangle    Rectangle( m_hdcFrameBuffer, m_nViewX, m_nViewY, m_nViewWidth, m_nViewHeight );   // Destroy rendering brush    ::SelectObject( m_hdcFrameBuffer, hOldBrush );    ::DeleteObject( hBrush );}void Engine::PresentFrameBuffer(){WriteToLog("Entering PresentFrameBuffer()");HDC hDC = NULL;//Retrieve the DC of the windowhDC = ::GetDC(m_hWnd);//Blit the frame buffer to the screen::BitBlt(hDC, m_nViewX, m_nViewY, m_nViewWidth, m_nViewHeight,m_hdcFrameBuffer, m_nViewX, m_nViewY, SRCCOPY);//Clean up ::ReleaseDC(m_hWnd, hDC);}int Engine::BeginGame(){WriteToLog("Entering BeginGame()");MSG msg;//Start main loopwhile(1){//Check if received messageif( PeekMessage(&msg, NULL, 0,0, PM_REMOVE)){if(msg.message == WM_QUIT)break;TranslateMessage( &msg);DispatchMessage(&msg);}else{FrameAdvance();}}return 0;}LRESULT CALLBACK Engine::StaticWndProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam){if(Message == WM_CREATE ) SetWindowLong(hWnd, GWL_USERDATA, (LONG)((CREATESTRUCT FAR*) lParam)->lpCreateParams);Engine *Destination = (Engine*)GetWindowLong( hWnd, GWL_USERDATA);if(Destination)return Destination->DisplayWndProc(hWnd, Message, wParam, lParam);//No destination foundreturn DefWindowProc(hWnd, Message, wParam, lParam);}LRESULT Engine::DisplayWndProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam){WriteToLog("DisplayWndProc");float fAspect;float radians = degrees * (PI/180);//Determine message typeswitch(Message){case WM_CREATE:break;case WM_CLOSE:PostQuitMessage(0);break;case WM_DESTROY:PostQuitMessage(0);break;case WM_SIZE:WriteToLog("Entering WM_SIZE");//Store any viewport sizeswidth = LOWORD(lParam);height = HIWORD(lParam);//Set up new perspective projection matrix//Create Projection matrix with 60 degree viewportfAspect = (float)width/(float)height;projMatrix[0][0]=1/(tan(radians/2)*fAspect);projMatrix[1][1]=1/(tan(radians/2));projMatrix[2][2] = 1;//Rebuild the new frame bufferBuildFrameBuffer(width, height);break;case WM_KEYDOWN://Key pressedswitch(wParam){case VK_ESCAPE:PostQuitMessage(0);return 0;}case WM_COMMAND://Process Menu itemsswitch(LOWORD(wParam)){default:break;}default:return DefWindowProc(hWnd,Message,wParam,lParam);}//End Message Switchreturn 0;}bool Engine::ShutDown(){WriteToLog("Shutting Down Application");    // Destroy the frame buffer and associated DC's    if ( m_hdcFrameBuffer && m_hbmFrameBuffer )    {   ::SelectObject( m_hdcFrameBuffer, m_hbmSelectOut );   ::DeleteObject( m_hbmFrameBuffer );   ::DeleteDC( m_hdcFrameBuffer );    } // End if    // Destroy the render window    if ( m_hWnd ) DestroyWindow( m_hWnd );   // Clear all variables    m_hWnd    = NULL;    m_hbmFrameBuffer    = NULL;    m_hdcFrameBuffer    = NULL;   // Shutdown Success    return true;}void Engine::FrameAdvance(){TCHARlpszFPS[30];WriteToLog("Entering Frame Advance()");m_Timer.Tick( 60.0f);//AnimateObjects();ClearFrameBuffer(0x00FFFFFF); //Clears with bright whitefor( ULONG i = 0; i<2; i++){//Loop through each polygonfor(ULONG f = 0; f<6; f++){DrawPrimitive(cubes->sides[f], cubes->WorldPos);}}m_Timer.GetFrameRate( lpszFPS);TextOut( m_hdcFrameBuffer, 5, 5, lpszFPS, strlen(lpszFPS));PresentFrameBuffer();}void Engine::DrawPrimitive(CPolygon &pPoly, CVector3 &worldMatrix){WriteToLog("Entering DrawPrimitive");CVector3 vtxPrevious, vtxCurrent;for(USHORT v = 0; v<4+1; v++){vtxCurrent = pPoly.p[v%4];WorldTransform(vtxCurrent,worldMatrix);ProjectionTransform(vtxCurrent);vtxCurrent.x = vtxCurrent.x*m_nViewWidth/2 + m_nViewX + m_nViewWidth/2;vtxCurrent.y = vtxCurrent.y = -vtxCurrent.y * m_nViewWidth/2 + m_nViewY+m_nViewHeight/2;if(v==0){vtxPrevious = vtxCurrent;continue;}DrawLine(vtxPrevious,vtxCurrent);vtxPrevious = vtxCurrent;}}void Engine::DrawLine(CVector3 &v1, CVector3 &v2){WriteToLog("Drawing Line");LOGPEN logPen;HPEN hPen = NULL, hOldPen = NULL;ULONG Color = 0;//Set up rendering penlogPen.lopnStyle = PS_SOLID;logPen.lopnWidth.x = 1;logPen.lopnWidth.y = 1;//Set up the color converted to BGR & stripped of alphalogPen.lopnColor = 0x00FFFFFF & RGB2BGR(Color);//Create the rendering penhPen = ::CreatePenIndirect(&logPen);if(!hPen)return;//Select into the frame buffer DChOldPen = (HPEN)::SelectObject(m_hdcFrameBuffer,hPen);//Draw the line segmenMoveToEx(m_hdcFrameBuffer, (long)v1.x, (long)v1.y,NULL);LineTo( m_hdcFrameBuffer, (long)v2.x,(long)v2.y);//Destroy rendering pen::SelectObject(m_hdcFrameBuffer, hOldPen);::DeleteObject( hPen);}void Engine::WorldTransform(CVector3 &v, CVector3 &World){WriteToLog("Entering World Transform");v.x += World.x;v.y += World.y;v.z += World.z;}void Engine::ProjectionTransform(CVector3 &v){WriteToLog("Entering Screen and ProjectionTransform()");v.x /=v.z; //Converts to 2D screen spacev.y /=v.z;//Convert to screen coordinatesv.x = v.x*m_nViewWidth/2 + m_nViewX + m_nViewWidth/2;v.y = -v.y*m_nViewHeight/2 + m_nViewY+m_nViewHeight/2;v.x = projMatrix[0][0]*v.x+projMatrix[1][0]*v.x+projMatrix[2][0]*v.x;v.y = projMatrix[0][1]*v.y+projMatrix[1][1]*v.y+projMatrix[2][1]*v.y;v.z = projMatrix[0][2]*v.z+projMatrix[1][2]*v.x+projMatrix[2][2]*v.z;}void Engine::EnableLogging(){//Setting name of log filename = "EngineLog.txt";filename = name;fileJustOpened = true;f_log = true;}void Engine::WriteToLog(std::string a){if(f_log){if(filename == name){if(fileJustOpened){fout.open(filename.c_str());fout<<a<<"\n";fout.close();fileJustOpened = false;}else{fout.open(filename.c_str(),std::ios::app);fout<<a<<"\n";fout.close();fileJustOpened = false;}}else{//Engine not logged}}}void Engine::DisableLogging(){f_log = false;}//Cube.cpp#include "Cube.h"Cube::Cube(){//initialize all variables to zeroWorldPos.x = 0;WorldPos.y = 0;WorldPos.z = 0;sides[0].p[0].x = -2; sides[0].p[0].y = 2; sides[0].p[0].z = -2;sides[1].p[1].x = 2; sides[1].p[1].y = 2; sides[1].p[1].z = -2;sides[2].p[2].x = 2; sides[2].p[2].y = -2; sides[2].p[2].z = -2;sides[3].p[3].x = -2; sides[3].p[3].y = -2; sides[3].p[3].z = -2;sides[4].p[4].x = 2; sides[4].p[4].y = 2; sides[4].p[4].z = 2;sides[5].p[5].x = -2; sides[5].p[5].y = 2; sides[5].p[5].z = 2;sides[6].p[6].x = -2; sides[6].p[6].y = -2; sides[6].p[6].z = 2;sides[7].p[7].x = 2; sides[7].p[7].y = -2; sides[7].p[7].z = 2;float degreesX, degreesY, degreesZ;degreesX = 30;degreesY= 5;degreesZ = 17;RotX = degreesX*(3.14f/180.0f);RotY = degreesY*(3.14f/180.0f);RotZ = degreesZ*(3.14f/180.0f);}Cube::Cube(int size){//initialize all variables to zeroWorldPos.x = 0;WorldPos.y = 0;WorldPos.z = 0;float coord = (float)size/2;sides[0].p[0].x = -coord; sides[0].p[0].y = coord; sides[0].p[0].z = -coord;sides[0].p[1].x = coord; sides[0].p[1].y = coord; sides[0].p[1].z = -coord;sides[0].p[2].x = coord; sides[0].p[2].y = -coord; sides[0].p[2].z = -coord;sides[0].p[3].x = -coord; sides[0].p[3].y = -coord; sides[0].p[3].z = -coord;sides[1].p[0].x = coord; sides[1].p[0].y = coord; sides[1].p[0].z = coord;sides[1].p[1].x = -coord; sides[1].p[1].y = coord; sides[1].p[1].z = coord;sides[1].p[2].x = -coord; sides[1].p[2].y = -coord; sides[1].p[2].z = coord;sides[1].p[3].x = coord; sides[1].p[3].y = -coord; sides[1].p[3].z = coord;sides[2].p[0].x = -coord; sides[2].p[0].y = coord; sides[2].p[0].z = coord;sides[2].p[1].x = coord; sides[2].p[1].y = coord; sides[2].p[1].z = coord;sides[2].p[2].x = coord; sides[2].p[2].y = coord; sides[2].p[2].z = -coord;sides[2].p[3].x = -coord; sides[2].p[3].y = coord; sides[2].p[3].z = -coord;sides[3].p[0].x = coord; sides[3].p[0].y = coord; sides[3].p[0].z = -coord;sides[3].p[1].x = coord; sides[3].p[1].y = coord; sides[3].p[1].z = coord;sides[3].p[2].x = coord; sides[3].p[2].y = -coord; sides[3].p[2].z = coord;sides[3].p[3].x = coord; sides[3].p[3].y = -coord; sides[3].p[3].z = -coord;sides[4].p[0].x = -coord; sides[4].p[0].y = -coord; sides[4].p[0].z = -coord;sides[4].p[1].x = -coord; sides[4].p[1].y = -coord; sides[4].p[1].z = coord;sides[4].p[2].x = coord; sides[4].p[2].y = -coord; sides[4].p[2].z = coord;sides[4].p[3].x = coord; sides[4].p[3].y = -coord; sides[4].p[3].z = -coord;sides[5].p[0].x = -coord; sides[5].p[0].y = coord; sides[5].p[0].z = coord;sides[5].p[1].x = -coord; sides[5].p[1].y = coord; sides[5].p[1].z = -coord;sides[5].p[2].x = -coord; sides[5].p[2].y = -coord; sides[5].p[2].z = -coord;sides[5].p[3].x = -coord; sides[5].p[3].y = -coord; sides[5].p[3].z = coord;float degreesX, degreesY, degreesZ;degreesX = 30;degreesY= 5;degreesZ = 17;RotX = degreesX*(3.14f/180.0f);RotY = degreesY*(3.14f/180.0f);RotZ = degreesZ*(3.14f/180.0f);}Cube::~Cube(){//Destructor}void Cube::scaleCube(int value){for(int i = 0; i<8; i++){sides.p.x *= value;sides.p.y *= value;sides.p.z *= value;}}//Vector3.cpp//===============================//CVector3.cpp//Written by Adam Larson//===============================#include "Vector3.h"#include <math.h>#include <iostream>CVector3::CVector3():x(0.0f),y(0.0f),z(0.0f){}CVector3::CVector3(float X, float Y, float Z){x = X;y = Y;z = Z;}CVector3::CVector3(CVector3 &v){x = v.x;y = v.y;z = v.z;}CVector3::~CVector3(){//Destructor Data here}//==============================//Function: length//returns the length of the vector//==============================float CVector3::length(CVector3 &v){return sqrt((v.x*v.x)+(v.y*v.y)+(v.z*v.z));}//==============================//Function Normalize//Returns normalized vector//==============================CVector3 CVector3::Normalize(CVector3 &v){float len = length(v);CVector3 temp;temp.x = v.x/len;temp.y = v.y/len;temp.z = v.z/len;return temp;}//===============================//Function AddVectors//Return New vector//===============================CVector3 CVector3::AddVectors(CVector3 &v1, CVector3 &v2){CVector3 temp;temp.x = v1.x+v2.x;temp.y = v1.y+v2.y;temp.z = v1.z+v2.z;return temp;}//================================//Function SubtractVectors//Returns new vector//================================CVector3 CVector3::SubtractVectors(CVector3 &v1, CVector3 &v2){CVector3 temp;temp.x = v1.x - v2.x;temp.y = v1.y - v2.y;temp.z = v1.z = v2.z;return temp;}//==================================//Function ScalarMultiply//Returns vector multiplied by scalar//==================================CVector3 CVector3::ScalarMultiply(CVector3 &v, float scalar){CVector3 temp;temp.x = v.x*scalar;temp.y = v.y*scalar;temp.z = v.z*scalar;return temp;}//==================================//Function CrossProduct//Returns vector of cross product of//2 vectors//==================================CVector3 CVector3::CrossProduct(CVector3 &v1, CVector3 &v2){CVector3 temp;temp.x = (v1.y*v2.z)-(v1.z*v2.y);temp.y = (v1.z*v2.x)-(v1.x*v2.z);temp.z = (v1.x*v2.y)-(v1.y*v2.x);return temp;}//======================================//Function Dot Product//Returns a vector of the Dot Product of//2 vectors//=======================================float CVector3::DotProduct(CVector3 &v1, CVector3 &v2){CVector3 temp1, temp2;temp1 = Normalize(v1);temp2 = Normalize(v2);return ((temp1.x*temp2.x)+(temp1.y*temp2.y)+(temp1.z*temp2.z));}//=====================================//Function Print//=====================================void CVector3::print(CVector3 &v){std::cout<<"("<<v.x<<"  "<<v.y<<"  "<<v.z<<")";}//Win32.h#ifndef _WIN32_H#define _WIN32_H#include <windows.h>#include "CTimer.h"#include "Vector3.h"#include <math.h>#include "Cube.h"#include "CPolygon.h"#include <fstream>#include <iostream>#include <string>#define RGB2BGR( Color ) (Color & 0xFF000000) | ((Color & 0xFF0000) >> 16) | (Color & 0x00FF00) | ((Color & 0x0000FF) << 16)class Engine{public://public functionsEngine();~Engine();//Destructorbool InitEngine(HANDLE hInstance, LPCTSTR lpCmdLine, int iCmdShow);   //Sets up enginevoid DrawLine(CVector3 &v1, CVector3 &v2);int BeginGame();LRESULTDisplayWndProc(HWND hWnd, UINT Message, WPARAM wParam,LPARAM lParam );void EnableLogging();  //Added function to enable writing to a filevoid WriteToLog(std::string a);  //Writes string a to filevoid DisableLogging();//public variablesfloat viewMatrix[3][3];float projMatrix[3][3];bool ShutDown();float PI;private:bool CreateWin(); // Creates application windowbool BuildFrameBuffer(ULONG Width, ULONG Height);//Creates Frame Buffervoid ClearFrameBuffer(ULONG Color = 0x00FFFFFF);//Clears the buffer to bright whitevoid PresentFrameBuffer();  //Blits the Frame Buffer to the screenvoid FrameAdvance();void DrawPrimitive(CPolygon &pPoly, CVector3 &worldMatrix);int width, height;  //Screen width and heightint degrees;void WorldTransform(CVector3 &v, CVector3 &World);void ProjectionTransform(CVector3 &v);  //Converts to screen space//Stores the two cubesCube*cubes[2];ULONGm_nViewX;//X position of render viewportULONGm_nViewY;//Y position of render viewportULONGm_nViewWidth;//Width of render viewportULONGm_nViewHeight;//Height of render viewportHWNDm_hWnd;   //Main window handle;HDCm_hdcFrameBuffer;//Frame Buffer Device ContextHBITMAPm_hbmFrameBuffer;//Frame buffers BitmapHBITMAPm_hbmSelectOut;//Used for selecting out of the DCCTimerm_Timer;//Variables for loggingstd::string filename; //Used to setup the ability to log eventsstd::ofstream fout;  //ofstream variable to output to file;bool fileJustOpened;  //Variable to detect when the file was first openedstd::string name;  //Set file name here for log filebool f_log;//===================================//Private Static Functions//===================================static LRESULT CALLBACK StaticWndProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam);};#endifIf anyone is interested here is a link to the entire source code.  I am using VS 2005.  I have limited bandwidth so if it is unavailable please :) try back in an hour.[link] http://www.geocities.com/adam_autum/HelpMe.zip [/link]   
  I'm having a look at it just now. Just a hint - don't include .ncb files in the zip - they're for the classwizard, and you don't need them. That should shrink the zip down to a tiny size.   ;  Thank you for taking the time to look at it.  I will try to remember to remove .ncb files from now on.  Thanks for the tip :)   ;float viewMatrix[3][3];float projMatrix[3][3];// Snipfor(int i = 0; i<4; i++){for(int j = 0; j<4; j++){viewMatrix[j] = 0;projMatrix[j] = 0;}}You're getting a buffer overflow, which is setting width and height to zero. That causes the aspect ratio to be infinity, which causes your projection matrix to be completely fubar, which causes your vertices to get transformed to invalid positions.   ;Quote:Original post by Evil Steve *** Source Snippet Removed ***You're getting a buffer overflow, which is setting width and height to zero. That causes the aspect ratio to be infinity, which causes your projection matrix to be completely fubar, which causes your vertices to get transformed to invalid positions.Thank you for spotting that, I have been looking at this code for hours.;  Changing DrawPrimitive() to comment out lines 311 and 312 seems to almost get the cube displaying, after making both matrices 4x4 arrays, but I don't really understand the maths behind this properly, so I can't help much more. I'll keep tinkering with it though.The debugger is your friend [wink]EDIT: Changing the second cubes WorldPos.Y to 8 kinda helps. Although there's still something wrong.   ;  I changed the code like this:for(int i = 0; i<3; i++){for(int j = 0; j<3; j++){viewMatrix[j] = 0;projMatrix[j] = 0;}}Does it work for you when you change it this way?   ;  See my above post (Yes).   ;Quote:Original post by Evil SteveChanging DrawPrimitive() to comment out lines 311 and 312 seems to almost get the cube displaying, after making both matrices 4x4 arrays, but I don't really understand the maths behind this properly, so I can't help much more. I'll keep tinkering with it though.The debugger is your friend [wink]EDIT: Changing the second cubes WorldPos.Y to -8 kinda helps. Although there's still something wrong.Thanks for helping me out :)Is the FPS showing correctly on yours?I still get a blank screen with 0 FPS showing, I just don't understand why the BackBuffer isn't presenting itself.;  I made a typo - I meant changing to 8, not -8. The backbuffer is presenting, from what I can see, but I still get 0 FPS. Again - learn to use the debugger, it makes life a lot easier.Another edit:// Calculate Frame Ratem_FPSFrameCount++;m_FPSTimeElapsed += m_TimeElapsed;if ( m_FPSTimeElapsed > 1.0f) {m_FrameRate= m_FPSFrameCount;m_FPSFrameCount= 0;m_FPSTimeElapsed= 0.0f;} // End If Second ElapsedThe code in that block never executes, because FPSTimeElapsed is never >0. Looks like your timer code is broken too, unfortunately.   