Unity HammerEngine development questions.

This topic is 3100 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hey guys. Even though I'm not very new to the comunity I still haven't had the chance to talk and share info with you guys. I'd like to change that since we're all here to make games and learn from one another. I made this topic because I've started working on my second GameEngine since the first one didn't turn out exactly as I wanted and now I have more experience. I'd like to put all my questions and stuff I figure out here so anyone can see the eventual problems and solutions. First of all my game engine is called HammerEngine but it might change (not the important right now). Next in line, I work with Visual Studio 2008 c++(for the engine programming) and I also make C# bindings. I use OpenGL for graphics. The engine uses deferred lighting. I want to split it up as Hammer3D,HammerInput,HammerPhysics,HammerAi etc. Currently only Hammer3D and HammerInput are in development. Hammer3D let's you bind the a engine to a HWND or creates a window for you and binds an engine to it. HammerInput takes a HWND and attaches a input loop to it so that you don't have to do anything but call functions like KeyDown(KEY_A) First problem: I'm not sure on how to make a window that updates automatically without me having to call a certain function. My code for the example looks like this:
#include <windows.h>
#include "..\..\..\Hammer3D\Hammer3D.h"
#include "..\..\..\HammerInput\HammerInput.h"

TEngine engine;

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hprev, PSTR cmdline, int ishow)
{
InitializeHammer3D();
InitializeHammerInput();
engine = CreateEngineWindow(800,600,32);
CreateInput(GetEngineHWND(engine));
while(!KeyDown(KEY_ESCAPE))
{
}
}

Problem is that I can't move or do anything with the window. Oh and for who might ask. HammerInput uses subclassing for getting acces to the input without calling something like Update(); Could anyone point me somewhere with this issue? Thank you. Edit: I found a way to do this but it has one problem. Using this function that is called on every function like KeyHit:
void SystemPoll(){
MSG msg;
while( PeekMessage( &msg,0,0,0,PM_REMOVE ) ){

switch( msg.message ){
case WM_KEYDOWN:case WM_KEYUP:
case WM_SYSKEYDOWN:case WM_SYSKEYUP:
switch( msg.wParam ){
case VK_SHIFT:
case VK_CONTROL:
break;
}
break;
}

TranslateMessage( &msg );
DispatchMessage( &msg );
}
}
This way the window works well but Im not sure what happens if for example you don't use any of those functions. It's a good temporary solution but not the best i think. [Edited by - LorinAtzberger on December 25, 2009 8:20:12 AM]

Share on other sites
What's the problem with simply putting an update function in the main loop? Assuming that the user will call an optional function is not a good way to design a solid API. However, if you clearly state that users are required to invoke UpdateHammer3D() or a similarly named function each loop cycle, chances are most people will catch that right away.

EDIT: Another way is to start a background thread that constantly calls PeekMessage(), but if you do you will have to be careful to lock any shared data. For example, the thread that handles window messages will need to lock the keyboard state (as will KeyDown) to ascertain that the list of pressed keys will be in a consistent state.

[Edited by - Windryder on December 25, 2009 5:49:54 PM]

Share on other sites
Yeah but what game doesn't require any input? Even the close button of the window can be called unsing pollsystem. And even more if there are problems with this I can add it on flip function as well since that has to be called in each loop to flip the buffers.

Share on other sites
Quote:
 Original post by LorinAtzbergerYeah but what game doesn't require any input? Even the close button of the window can be called unsing pollsystem. And even more if there are problems with this I can add it on flip function as well since that has to be called in each loop to flip the buffers.

So call it when you flip? ;) I don't really see the problem.

Share on other sites
Yeap I did that. Works like a charm.
I've reached the material/texture part and I have another problem.
First of all using visual studio for the engine I have the solution and the projects.
First I have Hammer3D and HammerInput and then in Test\Cpp I have the c++ tests projects.
I want to have all my test data into HammerEngine\Debug\Data but for instance if I don't copy the Data folder to HammerEngine\Tests\CPP\Material\ it can't find the file. Although if I run it without any debug it doesn't have that problem anymore.
I've set all the output folders and intermadiate folders to Hammer\Debug and nothing seems to work. Searching on google didn't get me anywhere but maybe I'm not searching right.
Does anyone have an ideea?

1. 1
2. 2
3. 3
4. 4
Rutin
17
5. 5

• 11
• 27
• 12
• 12
• 11
• Forum Statistics

• Total Topics
631407
• Total Posts
2999913
×