Jump to content
  • Advertisement
Sign in to follow this  
braclayrab

DirectX

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

Trying my first DX program. Just creating a window. I'm using VC++. Everything compiles but when I try to run the executable i get an error from windows: The instruction at "0x77e12660" referenced memory at "-xcccccccc". The memory could not be "read". Click on OK to terminate the program Click on CANCEL to debug the program ************************************************ //Here's the source code // Code taken from "Beginning DirectX9: Chapter 2 #include <windows.h> HINSTANCE hInst; HWND wndHandle; bool initWindow( HINSTANCE hInstance); LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM); int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { if (!initWindow( hInstance)) return false; MSG msg; ZeroMemory (&msg, sizeof(msg)); while (msg.message!=WM_QUIT ) { while (GetMessage(&msg, wndHandle, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } } return (int) msg.wParam; } bool initWindow( HINSTANCE hInstance ) { WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = (WNDPROC)WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = 0; wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName = NULL; wcex.hIconSm = 0; RegisterClassEx(&wcex); wndHandle = CreateWindow( "DirectXExample", "DirectXExample", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 640, 480, NULL, NULL, hInstance, NULL); if(!wndHandle) return false; ShowWindow(wndHandle, SW_SHOW); UpdateWindow(wndHandle); return true; } LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_DESTROY: PostQuitMessage(0); break; } return DefWindowProc(hWnd, message, wParam, lParam); }

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
You haven't initialised the lpszClassName member of the WNDCLASSEX structure - it needs to be set to the same class name that you use to create the window with in the CreteWindow() call.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!