Jump to content
  • Advertisement
  • entries
    707
  • comments
    1173
  • views
    436749

Update

Sign in to follow this  
Programmer16

146 views

Ok, I'm almost finished with the engine.

As stated in my last post, I have the input module fully implemented.

I was working on the sound module yesterday, but I had some minor problems. First I was using the wrong lib files, and now only a tenth of the file seems to be playing (I am trying to set the system up so that its streaming.) My sound is an explosion, and it comes out sounding like a machine gun (when looping) or nothing at all when loop is off. But, sound is my lowest priority right now. I haven't fully discarded sound though, if needed I can reimplement DirectMusic and just stick with wav files (at least there would be sound.)

Right now I'm working on the graphics module. I'm going to do the texture manager and maybe some helper classes and then move onto the GUI. Right now though, I am pondering about my graphics module. I have the main class set up so that it stores every state for the Direct3D device:

Texture* m_pTextureStages[8];
D3DRENDERSTATETYPE m_RenderStates[210];
D3DTEXTURESTAGESTATETYPE m_TextureStates[8][33];
D3DSAMPLERSTATETYPE m_SamplerStates[8][14];

First, you'll notice that my renderstate array is over twice as big as it needs to be (thats because the last renderstate is defined as 209). I was thinking of implementing this as a std::map, but I'm not sure. Bah, I can always change it at a later time. Moving on!

I'm fairly certain that I won't be able to get this game finished within the month, but I think that I'll have a good measure of what I can do. I mean, it has only been six days (practically all of which I have had this tooth infection) since I set the deadline and I've fully implemented my DirectInput module, almost fully implemented my Graphics module, learned how to load an Ogg file, learned a method for doing weighted device selection, learned/implemented LUA, implemented a sloppy GUI, and actually made a game (while trying to figure out how to get the different modules to work together, I hacked together an extendable system and made a pong game with it.) Nothing I would be willing to show anybody (the code anyway), but I learned a lot.

I've been thinking about my list (from the 5th) and I'm going to redo it for 2 reasons. The list looks like a 2 year old threw it together (for instance, I mention that there will be 3 skills, but then hint that there might be more skills. This sounds good, until you realize that I was only planning 3 skills.) So, expect a new list pretty soon (no later than Friday.)

Edit: I just realized that my m_RenderStates, m_TextureStageStates, and m_SamplerStates should use the DWORD/unsigned int type, not the state id type.

Edit: I figured I'd post a little example that uses the engine so far:

#include
#include
#include "dftCommon.h"
#include "dftInput.h"
#include "dftGraphics.h"

HWND g_WndHandle = 0;
dft::Graphics g_Graphics;
dft::Input g_Input;

void EventProc(dft::InputEvent Event);

int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
dft::CreateLog();

WNDCLASS WndClass;
memset(&WndClass, 0, sizeof(WNDCLASS));
WndClass.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
WndClass.hCursor = LoadCursor(0, IDC_ARROW);
WndClass.hIcon = LoadIcon(0, IDI_APPLICATION);
WndClass.hInstance = GetModuleHandle(0);
WndClass.lpfnWndProc = DefWindowProc;
WndClass.lpszClassName = "dftWindow";
if(!RegisterClass(&WndClass))
return 0;

g_WndHandle = CreateWindowEx(0, WndClass.lpszClassName, WndClass.lpszClassName, WS_POPUP | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, 800, 600, 0, 0, WndClass.hInstance, 0);
if(!g_WndHandle)
return 0;

if(!g_Graphics.Create(g_WndHandle, 800, 600, true)) return 0;
if(!g_Input.Create(g_WndHandle)) return 0;

dft::Texture::SetDeviceComPtr(g_Graphics.GetDeviceComPtr());
g_Input.SetEventProc(EventProc);

MSG Msg;
memset(&Msg, 0, sizeof(MSG));
while(1)
{
if(PeekMessage(&Msg, 0, 0, 0, PM_REMOVE))
{
if(Msg.message == WM_QUIT)
break;
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
else
{
g_Input.Update();

if(g_Input.KeyDown(dft::IK_F1))
PostQuitMessage(0);

g_Graphics.GetDeviceComPtr()->Clear(0, 0, D3DCLEAR_TARGET, 0xff00ff00, 1.0f, 0);
g_Graphics.GetDeviceComPtr()->Present(0, 0, 0, 0);
}
}

dft::FinishLog();
return 0;
}

void EventProc(dft::InputEvent Event)
{
if(Event.m_nMessage == dft::IM_KEYDOWN && Event.m_ucKey == dft::IK_ESCAPE)
PostQuitMessage(0);
}




You may notice that I haven't implemented a window class, and I don't plan to. Windows take like 20 seconds to make, and the only thing you could wrap is code to resize the client area in case Direct3D is going to be in windowed mode. I've tried doing a window class several different ways, and they just don't work. BUT, my Engine class will implement its own window, so that the user does not have to make his own. Although, I have thought about deriving a class from WNDCLASS and including a default constructor that fills the class. Then I would just have to set the values (primarily lpszClassName and lpfnWndProc.)
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!