dxFoo

Members
  • Content count

    422
  • Joined

  • Last visited

Community Reputation

100 Neutral

About dxFoo

  • Rank
    Banned
  1. My somewhat farewell :)

    I've been thinking hard on my progress over the last five years in game programming. I started with C and did a ton of studying on DirectX and I'm still at an introduction level. It's a tough subject so much that it's not adding up to what I need to know for software development. I'm in Computer Science and I see myself getting a software development job afterwards. It's sad but that's life. There's 99 jobs in software, and maybe one job in games. I came to the realization that I have to be extremely good to be accepted in that 1%. Considering I haven't made much other than Pong, and considering I need a job in a few years, I'm going to start going the less stressful route and start learning about software more. There's much better developers than me that can make tomarrow's games. I'll be always looking forward to my at-home hobby in game development. I have this cool 2d RPG I'm always dreaming about, so that will keep me feeling good on the game side of things. I couldn't care less if I get a job in gaming or not. It's still a fun area to explore while I have a realiable/stable job. So, I'm saying farewell for a while, and I just wanted to say thanks for the help and support over my many stumbling years in studying game programming. I'll still be around sometimes because software does always require a graphics library at times, even if it's not specifically games. But what's cool is I can always take what I learned in software and apply it to my game I hope to build someday. As a gift, I give you a great website filled with a ton of game e-books that helped me out plenty. I hope you find it helpful in your own adventure in life. Keep persuing what you enjoy. I will too, even if it's at home while off work. [link to illegal ebooks removed - Kaz] Merry Christmas, Phil [Edited by - Kazgoroth on December 19, 2005 1:55:01 AM]
  2. Hi, I got into GBA development last week and am really enjoying this. I am curious if there's a site of unofficial games that others can view w/ the VisualBoy Advanced emulator. Or, if you have some too, I'd really like to see what you came up with. Thanks! dxfoo
  3. HamSDK is really cool, too. The SDK comes with Visual HAM, Visual Boy Advanced for an emulator, and a few other cool stuff like a map editor. Harbour's website has the link, and he uses this with his ebook. It's a fun machine to work with - reminds me of the good ol' DOS32 gaming days.
  4. That was it! I never did my message processing his way before, but it makes sense now. If I process a message I'm looking for, I should return 0 before DefWindowProc tries to return something. Thanks again.
  5. Thanks Dave, I'll look into that.
  6. Okay, I found a solution, although it's different from the book's source code. Before, you had to press escape and it would send a WM_CLOSE message. But still it had to go through all that code in the block. So, I moved the escape check to the bottom of the code block. When I ran the program, it closed fine. I wonder what I'm doing different then if his source code works fine with the escape check on the top.
  7. The break was a good idea; however, the problem still occures. Here's the source code from the book. Maybe you can help pinpoint what I'm doing different then. I'll do the same. // DEMO6_3.CPP basic full-screen pixel plotting DirectDraw demo // INCLUDES /////////////////////////////////////////////// #define WIN32_LEAN_AND_MEAN // just say no to MFC #define INITGUID // make sure directX guids are included #include <windows.h> // include important windows stuff #include <windowsx.h> #include <mmsystem.h> #include <iostream.h> // include important C/C++ stuff #include <conio.h> #include <stdlib.h> #include <malloc.h> #include <memory.h> #include <string.h> #include <stdarg.h> #include <stdio.h> #include <math.h> #include <io.h> #include <fcntl.h> #include <ddraw.h> // include directdraw // DEFINES //////////////////////////////////////////////// // defines for windows #define WINDOW_CLASS_NAME "WINCLASS1" // default screen size #define SCREEN_WIDTH 640 // size of screen #define SCREEN_HEIGHT 480 #define SCREEN_BPP 8 // bits per pixel #define MAX_COLORS 256 // maximum colors // TYPES ////////////////////////////////////////////////////// // basic unsigned types typedef unsigned short USHORT; typedef unsigned short WORD; typedef unsigned char UCHAR; typedef unsigned char BYTE; // MACROS ///////////////////////////////////////////////// #define KEYDOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0) #define KEYUP(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 0 : 1) // initializes a direct draw struct #define DD_INIT_STRUCT(ddstruct) { memset(&ddstruct,0,sizeof(ddstruct)); ddstruct.dwSize=sizeof(ddstruct); } // GLOBALS //////////////////////////////////////////////// HWND main_window_handle = NULL; // globally track main window HINSTANCE hinstance_app = NULL; // globally track hinstance // directdraw stuff LPDIRECTDRAW7 lpdd = NULL; // dd object LPDIRECTDRAWSURFACE7 lpddsprimary = NULL; // dd primary surface LPDIRECTDRAWSURFACE7 lpddsback = NULL; // dd back surface LPDIRECTDRAWPALETTE lpddpal = NULL; // a pointer to the created dd palette LPDIRECTDRAWCLIPPER lpddclipper = NULL; // dd clipper PALETTEENTRY palette[256]; // color palette PALETTEENTRY save_palette[256]; // used to save palettes DDSURFACEDESC2 ddsd; // a direct draw surface description struct DDBLTFX ddbltfx; // used to fill DDSCAPS2 ddscaps; // a direct draw surface capabilities struct HRESULT ddrval; // result back from dd calls DWORD start_clock_count = 0; // used for timing // these defined the general clipping rectangle int min_clip_x = 0, // clipping rectangle max_clip_x = SCREEN_WIDTH-1, min_clip_y = 0, max_clip_y = SCREEN_HEIGHT-1; // these are overwritten globally by DD_Init() int screen_width = SCREEN_WIDTH, // width of screen screen_height = SCREEN_HEIGHT, // height of screen screen_bpp = SCREEN_BPP; // bits per pixel char buffer[80]; // general printing buffer // FUNCTIONS ////////////////////////////////////////////// LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { // this is the main message handler of the system PAINTSTRUCT ps; // used in WM_PAINT HDC hdc; // handle to a device context char buffer[80]; // used to print strings // what is the message switch(msg) { case WM_CREATE: { // do initialization stuff here // return success return(0); } break; case WM_PAINT: { // simply validate the window hdc = BeginPaint(hwnd,&ps); // end painting EndPaint(hwnd,&ps); // return success return(0); } break; case WM_DESTROY: { // kill the application, this sends a WM_QUIT message PostQuitMessage(0); // return success return(0); } break; default:break; } // end switch // process any messages that we didn't take care of return (DefWindowProc(hwnd, msg, wparam, lparam)); } // end WinProc /////////////////////////////////////////////////////////// int Game_Main(void *parms = NULL, int num_parms = 0) { // this is the main loop of the game, do all your processing // here // for now test if user is hitting ESC and send WM_CLOSE if (KEYDOWN(VK_ESCAPE)) SendMessage(main_window_handle,WM_CLOSE,0,0); // plot 1000 random pixels to the primary surface and return // clear ddsd and set size, never assume it's clean memset(&ddsd,0,sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); if (FAILED(lpddsprimary->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL))) { // error return(0); } // end if // now ddsd.lPitch is valid and so is ddsd.lpSurface // make a couple aliases to make code cleaner, so we don't // have to cast int mempitch = (int)ddsd.lPitch; UCHAR *video_buffer = (UCHAR *)ddsd.lpSurface; // plot 1000 random pixels with random colors on the // primary surface, they will be instantly visible for (int index=0; index < 1000; index++) { // select random position and color for 640x480x8 UCHAR color = rand()%256; int x = rand()%640; int y = rand()%480; // plot the pixel video_buffer[x+y*mempitch] = color; } // end for index // now unlock the primary surface if (FAILED(lpddsprimary->Unlock(NULL))) return(0); // sleep a bit Sleep(30); // return success or failure or your own return code here return(1); } // end Game_Main //////////////////////////////////////////////////////////// int Game_Init(void *parms = NULL, int num_parms = 0) { // this is called once after the initial window is created and // before the main event loop is entered, do all your initialization // here // create IDirectDraw interface 7.0 object and test for error if (FAILED(DirectDrawCreateEx(NULL, (void **)&lpdd, IID_IDirectDraw7, NULL))) return(0); // set cooperation to full screen if (FAILED(lpdd->SetCooperativeLevel(main_window_handle, DDSCL_FULLSCREEN | DDSCL_ALLOWMODEX | DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT))) { // error return(0); } // end if // set display mode to 640x480x8 if (FAILED(lpdd->SetDisplayMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP,0,0))) { // error return(0); } // end if // clear ddsd and set size memset(&ddsd,0,sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); // enable valid fields ddsd.dwFlags = DDSD_CAPS; // request primary surface ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; // create the primary surface if (FAILED(lpdd->CreateSurface(&ddsd, &lpddsprimary, NULL))) { // error return(0); } // end if // build up the palette data array for (int color=1; color < 255; color++) { // fill with random RGB values palette[color].peRed = rand()%256; palette[color].peGreen = rand()%256; palette[color].peBlue = rand()%256; // set flags field to PC_NOCOLLAPSE palette[color].peFlags = PC_NOCOLLAPSE; } // end for color // now fill in entry 0 and 255 with black and white palette[0].peRed = 0; palette[0].peGreen = 0; palette[0].peBlue = 0; palette[0].peFlags = PC_NOCOLLAPSE; palette[255].peRed = 255; palette[255].peGreen = 255; palette[255].peBlue = 255; palette[255].peFlags = PC_NOCOLLAPSE; // create the palette object if (FAILED(lpdd->CreatePalette(DDPCAPS_8BIT | DDPCAPS_ALLOW256 | DDPCAPS_INITIALIZE, palette,&lpddpal, NULL))) { // error return(0); } // end if // finally attach the palette to the primary surface if (FAILED(lpddsprimary->SetPalette(lpddpal))) { // error return(0); } // end if // return success or failure or your own return code here return(1); } // end Game_Init ///////////////////////////////////////////////////////////// int Game_Shutdown(void *parms = NULL, int num_parms = 0) { // this is called after the game is exited and the main event // loop while is exited, do all you cleanup and shutdown here // first the palette if (lpddpal) { lpddpal->Release(); lpddpal = NULL; } // end if // now the primary surface if (lpddsprimary) { lpddsprimary->Release(); lpddsprimary = NULL; } // end if // now blow away the IDirectDraw4 interface if (lpdd) { lpdd->Release(); lpdd = NULL; } // end if // return success or failure or your own return code here return(1); } // end Game_Shutdown // WINMAIN //////////////////////////////////////////////// int WINAPI WinMain( HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow) { WNDCLASSEX winclass; // this will hold the class we create HWND hwnd; // generic window handle MSG msg; // generic message HDC hdc; // graphics device context // first fill in the window class stucture winclass.cbSize = sizeof(WNDCLASSEX); winclass.style = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW; winclass.lpfnWndProc = WindowProc; winclass.cbClsExtra = 0; winclass.cbWndExtra = 0; winclass.hInstance = hinstance; winclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); winclass.hCursor = LoadCursor(NULL, IDC_ARROW); winclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); winclass.lpszMenuName = NULL; winclass.lpszClassName = WINDOW_CLASS_NAME; winclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION); // save hinstance in global hinstance_app = hinstance; // register the window class if (!RegisterClassEx(&winclass)) return(0); // create the window if (!(hwnd = CreateWindowEx(NULL, // extended style WINDOW_CLASS_NAME, // class "DirectDraw Full-Screen Demo", // title WS_POPUP | WS_VISIBLE, 0,0, // initial x,y SCREEN_WIDTH,SCREEN_HEIGHT, // initial width, height NULL, // handle to parent NULL, // handle to menu hinstance,// instance of this application NULL))) // extra creation parms return(0); // save main window handle main_window_handle = hwnd; // initialize game here Game_Init(); // enter main event loop while(TRUE) { // test if there is a message in queue, if so get it if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { // test if this is a quit if (msg.message == WM_QUIT) break; // translate any accelerator keys TranslateMessage(&msg); // send the message to the window proc DispatchMessage(&msg); } // end if // main game processing goes here Game_Main(); } // end while // closedown game here Game_Shutdown(); // return to Windows like this return(msg.wParam); } // end WinMain ///////////////////////////////////////////////////////////
  8. Thanks, I was just thinking that and put it in the right order now, but the same exception shows up. I checked the debugger. this is what it found: color = 127 = unsigned mempitch = 2089890440 = int video_buffer = 0x7c90ee18 "(random ascii characters) = unsigned x = 2089890433 = int y = 10551296 (IN RED HIGHLIGHT) = int On second try, it said this all in red: color = 13 = unsigned mempitch = -1073741819 = int video_buffer = 0x6c65525c <Bad Ptr> = unsigned x = 233128856 = int y = 13 = int A yellow arrow was pointing at this line: video_buffer[x + y * mempitch] = color;
  9. I've been studying Direct Draw lately with my book, and I pretty much got the basics of a full screen app working. This source code below draws random colored pixels across the screen. In the beginning, I see a little hesitation but it runs smoothly after a few seconds. When I exit, I get the following exception: Unhandled exception at 0x0041204b in DirectX Application.exe: 0xC0000005: Access violation writing location 0x000002c4. Any help would be great. Thanks, dxfoo #define WIN32_LEAN_AND_MEAN // say no to mfc overhead #define INITGUID // Init guids #include <windows.h> // contains all window header files #include <windowsx.h> // window macros #include <iostream> // standard c++ stuff #include "ddraw.h" // Direct Draw header #define KEYDOWN(vk_code) (GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0 #define KEYUP(vk_code) (GetAsyncKeyState(vk_code) & 0x8000) ? 0 : 1 #define SCREEN_WIDTH 800 #define SCREEN_HEIGHT 600 #define SCREEN_BPP 8 // Globals const char g_szWinTitle[] = "DirectX Application"; // Window title const char g_szClassName[] = "WNDCLASS1"; // Parent window class const int WIDTH = 800; // Screen Width const int HEIGHT = 600; // Screen Height HWND g_hWnd = NULL; // Global handle to parent window HINSTANCE g_hInstance = NULL; // Global instance to application // DirectX Instances LPDIRECTDRAW7 lpdd = NULL; LPDIRECTDRAWSURFACE7 lpddsprimary = NULL; LPDIRECTDRAWPALETTE lpddpal; DDSURFACEDESC2 ddsd; PALETTEENTRY palette[256]; // Prototypes LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); void Game_Init(); void Game_Main(); void Game_Destroy(); // Main entry point for the application int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdArgs, int nCmdShow) { HWND hWnd = NULL; // Handle to parent window MSG msg; // Message structure // Define window class WNDCLASSEX wc; wc.cbClsExtra = 0; // Extra class space info wc.cbWndExtra = 0; // Extra window space info wc.cbSize = sizeof(WNDCLASSEX); // Size of the window class structure wc.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);// Background color wc.hCursor = LoadCursor(NULL, IDC_ARROW); // Cursor wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); // Icon (32x32) wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); // Icon (16x16) wc.hInstance = hInstance; // Window's instance wc.lpfnWndProc = WndProc; // Window procedure wc.lpszClassName = g_szClassName; // Class name wc.lpszMenuName = NULL; // Menu wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC | CS_DBLCLKS; // Window style // Register window class if (!RegisterClassEx(&wc)) { MessageBox(NULL, "Registering Class Window Failed!", g_szWinTitle, MB_OK | MB_ICONERROR); return 0; } // Create Window hWnd = CreateWindowEx(NULL, g_szClassName, g_szWinTitle, WS_POPUP | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, SCREEN_WIDTH, SCREEN_HEIGHT, NULL, NULL, hInstance, NULL); // Check for window creation error if (hWnd == NULL) { MessageBox(NULL, "Creating parent window failed!", g_szWinTitle, MB_OK | MB_ICONERROR); return 0; } // Show & Update Window ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); // Set globals g_hWnd = hWnd; g_hInstance = hInstance; Game_Init(); // Initialize game // Message Loop while (TRUE) { if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { // Check for a quit if (msg.message == WM_QUIT) return 0; TranslateMessage(&msg); // Translate any accelerated keys DispatchMessage(&msg); // Dispatch the message } // Do game logic here Game_Main(); } Game_Destroy(); return (int) msg.wParam; } // Window Procedure LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { PAINTSTRUCT ps; HDC hDC; // check the given message switch (msg) { case WM_CREATE: { } break; case WM_PAINT: { hDC = BeginPaint(hWnd, &ps); EndPaint(hWnd, &ps); } break; case WM_DESTROY: { PostQuitMessage(WM_QUIT); } break; default: break; } // Send back any unhandled events return DefWindowProc(hWnd, msg, wParam, lParam); } // Initialize game resources here void Game_Init() { // Create a direct draw 7.0 object interface DirectDrawCreateEx(NULL, (void **)&lpdd, IID_IDirectDraw7, NULL); // Set the cooperative level to full screen lpdd->SetCooperativeLevel(g_hWnd, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_ALLOWMODEX | DDSCL_ALLOWREBOOT); // Set display mode lpdd->SetDisplayMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, 0, 0); // Clear ddsd and set size memset(&ddsd, 0, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); ddsd.dwFlags = DDSD_CAPS; ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; // Create primary surface lpdd->CreateSurface(&ddsd, &lpddsprimary, NULL); // Fill a 8.8.8 palette entry for (int color = 1; color < 255; color++) { palette[color].peRed = rand() % 256; palette[color].peGreen = rand() % 256; palette[color].peBlue = rand() % 256; palette[color].peFlags = PC_NOCOLLAPSE; } // Set black palette color position palette[0].peRed = 0; palette[0].peGreen = 0; palette[0].peBlue = 0; palette[0].peFlags = PC_NOCOLLAPSE; // Set white palette color position palette[255].peRed = 255; palette[255].peGreen = 255; palette[255].peBlue = 255; palette[255].peFlags = PC_NOCOLLAPSE; // Create palette lpdd->CreatePalette(DDPCAPS_INITIALIZE | DDPCAPS_ALLOW256 | DDPCAPS_8BIT, palette, &lpddpal, NULL); // Set palette to primary surface lpddsprimary->SetPalette(lpddpal); } // Game logic here void Game_Main() { if (KEYDOWN(VK_ESCAPE)) SendMessage(g_hWnd, WM_CLOSE, 0, 0); // clean ddsd and set its size memset(&ddsd, 0, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); lpddsprimary->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL); int mempitch = (int)ddsd.lPitch; UCHAR *video_buffer = (UCHAR *)ddsd.lpSurface; // Plot 1000 random pixels to the primary surface for (int index = 0; index < 1000; index++) { UCHAR color = rand()%256; int x = rand()%SCREEN_WIDTH; int y = rand()%SCREEN_HEIGHT; video_buffer[x + y * mempitch] = color; } lpddsprimary->Unlock(NULL); Sleep(30); // sleep a bit } // Destroy game resources here void Game_Destroy() { if (lpdd) { lpdd->Release(); lpdd = NULL; } if (lpddsprimary) { lpddsprimary->Release(); lpddsprimary = NULL; } if (lpddpal) { lpddpal->Release(); lpddpal = NULL; } }
  10. Books to buy?

    Get #5 without the hesitation since people love to turn it down. It's the best reference book you could ever need on the job. I wouldn't get his earlier editions though.
  11. C++ vector problem

    Thanks, I got it going.
  12. C++ vector problem

    Yes, I finally began learning the STL! It took some time but I'm there. I'm familiar with C# ArrayList, etc., so I'm glad I can relate pretty well. I came across an odd error. If someone can spot it, I can only learn from it :) This program asks the user for a name and it tries to find it and gives out the person's age. It's basically a simple in-game database of player objects. Thanks in advanced for the help. #include <iostream> #include <string> #include <vector> using namespace std; class Common { public: string name; int age; Common(string name, int age) { this->name = name; this->age = age; }; }; int main() { Common PC1("Philly", 23); Common PC2("Jilly Dilly", 400); vector<Common> v(10); v.push_back(PC1); v.push_back(PC2); cout << "Enter a name to find: "; string sBuffer; cin >> sBuffer; bool found = false; for (unsigned short int i = 0; i < v.size(); i++) { if (v[i].name == sBuffer) { cout << "Found it! The age is " << v[i].age << "." << endl; found = true; } } if (!found) cout << "The requested name could not be found." << endl; system("pause"); return 0; } Error Message: ------ Build started: Project: Console Practice, Configuration: Debug Win32 ------ Compiling... Console Practice.cpp C:\Program Files\Microsoft Visual Studio 8\VC\include\vector(470) : error C2512: 'Common::Common' : no appropriate default constructor available C:\Program Files\Microsoft Visual Studio 8\VC\include\vector(467) : while compiling class template member function 'std::vector<_Ty>::vector(__w64 unsigned int)' with [ _Ty=Common ] .\Console Practice.cpp(23) : see reference to class template instantiation 'std::vector<_Ty>' being compiled with [ _Ty=Common ] Build log was saved at "file://c:\Documents and Settings\Owner\My Documents\Visual Studio 2005\Projects\Console Practice\Console Practice\Debug\BuildLog.htm" Console Practice - 1 error(s), 0 warning(s)
  13. Oh, that makes sense. It works now :) And Host would cast to a string here because of how Console::WriteLine() works. You could do sample->Host->ToString(), but it is redundent. Thanks for the help. Uri ^sample = gcnew Uri("http://www.google.com"); Console::WriteLine("Host: " + sample->Host); Console::WriteLine("Port: " + sample->Port); Console::WriteLine("Scheme: " + sample->Scheme);
  14. I got it. I removed the System.Net.dll and just used System.dll. The NET namespace is already contained inside. So, I guess now I ask what's the differences between mscorlib.dll and System.dll? And... System::Uri::Uri(System::String ^)' : cannot convert parameter 1 from 'System::Uri ^' to 'System::String ^' Wha? System::Uri sample = gcnew System::Uri("http://www.google.com"); Console::WriteLine("Host: " + sample.Host); Console::WriteLine("Port: " + sample.Port); Console::WriteLine("Scheme: " + sample.Scheme);