[ENet-discuss] QUERY: enet vs STL
Ruud van Gaal
ruud at racer.nl
Sun Jan 6 13:31:35 PST 2008
> Date: Sat, 05 Jan 2008 14:41:06 +0100
> From: Bjørn <bjorn at lindeijer.nl>
> Subject: Re: [ENet-discuss] QUERY: enet vs STL
> To: Discussion of the ENet library <enet-discuss at cubik.org>
> Message-ID: <477F88F2.4010405 at lindeijer.nl>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Andrew Wan schreef:
> > Quick question. Does enet include any queuing/buffering? My Windows
> > App is event-driven and so I like to update the display
> ONLY if there
> > is any change in the global game state. Otherwise if I keep on
> > refreshing the Windows App display on every packet received
> then the
> > WinApp loses mouse-drags, mouse-events, etc. and the whole WinApp
> > flickers continuously. So I want to get around this by queuing up
> > events when the client receives them.
> >
> > I tried using STL <queue> but couldn't get it working..
> maybe it's C++
> > only and my Allegro/WinApp is C. Do you have any other suggestiongs?
>
> You obviously need to use a C++ compiler when you want to use
> std::queue.
Sounds like that isn't a real solution. You need something like (pseudo):
bool gameStateChanged;
void HandleENet()
{
while(getpacket())
handlepacket(); <= modifies gameStateChanged if needed
}
void HandleGame()
{
YourGameStep();
}
void main()
{
while(1){ HandleENet(); HandleGame(); if(gameStateChanged)Redraw(); }
}
Besides, flickering windows indicate single-buffer use. Double buffering
would always resolve that. But you should just not let packet entry by
itself trigger a redraw. Add more logic.
Cheers,
Ruud
More information about the ENet-discuss
mailing list