Having trouble with WinAPI....

Started by
4 comments, last by Techieman 10 years, 10 months ago

Hello,

I'm currently rewritting a part of the ClockGear-Game-Engine ( a private project made by my friend and me ).

We decided to create a XNA like Game class. This class contains another class called cgWindow. That's the problem.

I can create a Window, but we cannot put our game logic there without functionpointers to classmethods.

So we decided to create functions like IsOpened...

How ever the class should look like this:

[attachment=16006:Window.png]

I have no Idea how to put this into working Code.

Are there any ressource that can help me with that problem?

Thanks Techie

It's not a shame to make mistakes. As a programmer I am doing mistakes on a daily basis. - JonathanKlein

Advertisement

Which part specifically is causing the problem?

My guess is that you're having difficulty because the window procedure must be static, but you want to have access to the window object and it's members. One solution is described here.

Well the WindowProcedure it self not. I've problems with calling the Game Logic. Since I have an XNA like Game Class I don't want to use Functionpointer.

I've now Idea how to Implement things like this:


while( Window.IsOpened ){
// Do such things
// Exploding Clowns.
}

I end up here:


ShowWindow( m_hWnd, NULL ); 

After this I've no Idea how to put the gamelogic into the loop.

I hope I've properly formulated my problem.

Thanks Techie

It's not a shame to make mistakes. As a programmer I am doing mistakes on a daily basis. - JonathanKlein

Since nobody is answering, I'll specify my problem:

How do I implement something like this into my code/class :


while( Window.IsOpen() ){
// Exploding Clowns 
}

I have no idea how to get this in common with my Messageloop.

Any ideas?

Thanks Techie

It's not a shame to make mistakes. As a programmer I am doing mistakes on a daily basis. - JonathanKlein

I can create a Window, but we cannot put our game logic there without functionpointers to classmethods.

... while( Window.IsOpen() ){

Are you familiar with the game loop, and how it works?

General window programming is event driven. The human does something to generate an event, it gets passed to the appropriate UI control, the control gets the event, processes it until it is finished, and you are done.

A game loop follows the pattern of the game engine running in a time-driven loop. Game systems and objects can register with the engine that they want to be included. Those systems perform a tiny bit of processing and return control as fast as reasonable.

The message loop you described above would surrender control to the window indefinitely until the processing is complete. That is fine for an event-driven window program, but contrary to the design of most time-driven games.

Sorry, I don't get the gist, how this may work blink.png

EDIT: Well, strange phenomen: Whenever I try something, I don't get the gist. So I writte a topic in the forum and in the next moment I understand it or I have got a possible solution that just has to be tested. LOL! PeekMessage... seems usefull, though.

It's not a shame to make mistakes. As a programmer I am doing mistakes on a daily basis. - JonathanKlein

This topic is closed to new replies.

Advertisement