Jump to content

  • Log In with Google      Sign In   
  • Create Account

Maple Wan

Member Since 04 Sep 2013
Offline Last Active Nov 23 2014 11:49 PM

Posts I've Made

In Topic: Which game engine should I choose?

22 September 2013 - 07:38 PM


you can make interesting games with less than perfect tools (or tools that you develop yourself)

 

Thanks for your suggestion, I own the ambition to write a library for myself, in fact I'm doing now. So I think reading the opensource engine code is helpful to me.smile.png


In Topic: Which game engine should I choose?

22 September 2013 - 07:34 PM

Hmm... I think if you are just starting out and you just want to learn how to create games, you could get started fairly early by simply using freeGLUT or GLFW

That means you'd be learning the ground rules for 2D and 3D game development, however: It isn't really a shortcut to creating a game

 

In some cases people start early with text-based games (using the console window)

And in other cases people start out with SFML which I have heard makes it easy for you to create 2D games

Maybe you want to use pygame in Python, gamemaker just to get your feet wet and start creating a game right now...

There are alot of options here

 

I would take a look at the sticky threads, as they contain some great starting points

Pick a language and stick with it for a while, as you can't really go wrong.. smile.png

 

Note that i specifically mentioned freeGLUT and GLFW because they enable to you write cross-platform opengl games, however if you are a beginner you might want to take a look at the other options available also..

 

good luck

Pretty helpful suggestion, I consulted some data about GLFW, it may be a new start for me. By the way, how about cocos2d-x? It seems that cocos2d-x is very popular in mobile game development.

 

How about sound? I know OpenAL is for sound, however I'm not familiar with OpenAL, but are there any opensource libraries about OpenAL? I think the sound effect is also very important in a game.


In Topic: c++ A problem when create a thread in a class

17 September 2013 - 03:33 AM

 


When I use a static method, the Singleton is meaningless

You should avoid singletons, but not for this reason. The static thread method is just used to dispatch the call to the instance-specific handler. The "real" handler is not static.

 

Really thankful to you, I think I know what to do so. Thanks very very much.


In Topic: c++ A problem when create a thread in a class

17 September 2013 - 02:14 AM

 

Could you recommand some articles or books about c++ lower mechanisms and theory of c++ class. I always feel confused about some concepts in c++ class.

http://www.parashift.com/c++-faq/
 
http://www.parashift.com/c++-faq/memfnptr-vs-fnptr.html

 

Thanks, bro~

 

 

How to convert the function pointer in a class to the normal function pointer in C?

You cannot directly specify an instance method as method / callback parameter in Windows API in general, and not in CreateThread in particular. This is because internally instance methods have an additional parameter pointing to the class instance, so the method signature does not match the signature required by CreateThread.
The usual workaround is to have a static method, pass a pointer to the instance as lpParameter, and dispatch the call in the static method to an instance method, using that parameter.

class MsgListener
{
private:
    HANDLE _threadHandle;
    DWORD _threadId;
    static MsgListener *_instance;
    MsgListener();
    DWORD Listen();
    static DWORD WINAPI StaticListen(LPVOID param);
public:
    static MsgListener *GetInstance();
    void StartListen();
    void StopListen();
};

MsgListener *MsgListener::_instance = new MsgListener();
MsgListener::MsgListener() 
{ 
    _threadHandle = 0;
    _threadId = 0;
}
DWORD WINAPI MsgListener::StaticListen(LPVOID param) 
{
	MsgListener* listener = reinterpret_cast<MsgListener*>(param);
	return listener->Listen();
}
DWORD MsgListener::Listen() 
{ 
    // The method to run in a new thread....
	return 0;
}
MsgListener *MsgListener::GetInstance()
{
    if (!_instance)
        _instance = new MsgListener();
    return _instance;
}
void MsgListener::StartListen()
{
    this->_threadHandle = CreateThread(NULL, 0, &MsgListener::StaticListen, this, 0, &_threadId);
}
void MsgListener::StopListen()
{
    CloseHandle(_threadHandle);
}

However, I'd use the threading support in C++11 instead. It is so much easier to specify an arbitrary worker method, even an instance method, using the std::thread ctor:

http://en.cppreference.com/w/cpp/thread/thread/thread

 

Yeah, you are right. When I use a static method, the Singleton is meaningless, so I think I ought to change a design way to watch the device state. Thanks very much, bro.


In Topic: c++ A problem when create a thread in a class

17 September 2013 - 02:11 AM

 

Thanks very much. Could you recommand some articles or books about c++ lower mechanisms and theory of c++ class. I always feel confused about some concepts in c++ class.

Accelerated C++ by Koenig and Moo, and C++ Primer by Lippmann, LaJoie and Moo, are both frequently recommended for beginners in C++.

Even so, what problem are you trying to solve? People can probably point you to excellent resources for whatever specific problem you are looking to solve that are less complex than the path you were traveling.

 

Thanks, I want to create a new thread to watch the keyboard state and mouse state in DirectInput, I want to use a infinite loop to watch the message by using the GetDevice function in DirectInput. So I want to define a class which is to manage the listen thread.


PARTNERS