• Content count

  • Joined

  • Last visited

Community Reputation

229 Neutral

About wanmaple

  • Rank
  1. How to learn Urho3D

    Hi, I am a newbie on 3D game engine.   I found an open-source game engine called Urho3D several weeks ago.   I know about some knowledges about OpenGL, and have enough experience on 2D games. I have researched a lot through the samples provided by Urho3D, but still can't go across it.   Are there any great Urho3D tutorials or 3D game basis which is suitable for beginners like me.   I need your help! Thanks a lot.
  2. Which game engine should I choose?

      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.
  3. Which game engine should I choose?

    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.
  4. Hi: I'm going to learn game programming. I have the basis of c/c++/c#. I'd like to develop 2D games first and research 3D games later, so which game engine should I choose? There are many many different opensource game engines, so I don't know which is suitable for a beginner. I have learnt some about DirectX, which is not cross-platform, so I may spend more time on OpenGL study. I prefer an opensource game engine whose graphic is based on OpenGL. Give me some suggestions, please. Thanks.
  5. c++ A problem when create a thread in a class

    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.
  6. c++ A problem when create a thread in a class

    http://www.parashift.com/c++-faq/   http://www.parashift.com/c++-faq/memfnptr-vs-fnptr.html   Thanks, bro~   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.
  7. c++ A problem when create a thread in a 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.
  8. c++ A problem when create a thread in a class

    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.
  9. Dear everyone, I am writing a singleton class to manage a thread, here's the code: #include <windows.h> typedef class MsgListener { private: HANDLE _threadHandle; DWORD _threadId; static MsgListener *_instance; MsgListener(); DWORD WINAPI Listen(LPVOID param); public: static MsgListener *GetInstance(); void StartListen(); void StopListen(); } MSGLISTENER, *LPMSGLISTENER; MsgListener *MsgListener::_instance = new MsgListener(); MsgListener::MsgListener() { _threadHandle = 0; _threadId = 0; } DWORD WINAPI MsgListener::Listen(LPVOID param) { // The method to run in a new thread.... } MsgListener *MsgListener::GetInstance() { if (!_instance) _instance = new MsgListener(); return _instance; } void MsgListener::StartListen() { // Here, the compiler give the error: // cannot convert 'MsgListener::Listen' from type 'DWORD (MsgListener::)(LPVOID) { aka long unsigned int (MsgListener::)(void*) }' to type 'LPTHREAD_START_ROUTINE { aka long unsigned int (__attribute__((__stdcall__)) *)(void*) }' this->_threadHandle = CreateThread(NULL, 0, Listen, 0, &_threadId); } void MsgListener::StopListen() { CloseHandle(_threadHandle); } The ide I use is Code::Blocks and the compiler is GNU GCC COMPILER. How to convert the function pointer in a class to the normal function pointer in C? And I really don't know the difference between these two kind of function pointers. Where does each kind of function pointer save in the memory?
  10. Strategy pattern.... am I on the right track?

    Where is your override keyword? To realize Polymorphism, you have to implement 3 conditions: 1. Contains inheritance.(Interface or base class) 2. Contains override(use abstract/override or virtual/override or realize the interface method) 3. Mutiple base class objects which point to a derived class reference.   You should use override keyword in your derived class to replace the behavior of base class. Otherwise you should use new keyword to prevent derived class to replace the method of base class.
  11. rotating objects in a double orbit

    Well, you should know the concepts of relative coordinate system and world coordinate system. Your triangles should save your relative point list and the center point. Then update the relative point list when rotate for some radius and redraw it. Give some simple code: #define PI 3.1415926535 typedef struct { double x, y; } POINT, *LPPOINT; typedef class Triangle { private: POINT pointList[3]; POINT centerPoint; public: Triangle() { }; // Constructor ~Triangle() { }; // Destructor BOOL Draw(); // Realize your Draw method BOOL Rotate(double theta); // Rotate method } TRIANGLE, *LPTRIANGLE; BOOL TRIANGLE::Rotate(double theta) { double cosVal, sinVal; for (int i = 0; i < 3; i++) { cosVal = cos(theta * PI / 180); sinVal = sin(theta * PI / 180); // Compute the relative coordinate after rotate this->pointList[i].x = this->pointList[i].x * cosVal - this->pointList[i].y * sinVal; this->pointList[i].y = this->pointList[i].x * sinVal + this->pointList[i].y * cosVal; } return this->Draw(); BOOL TRIANGLE::Draw() { // In your draw method, you should change your relative coordinate to world coordinate. }
  12. DirectX7 SetPalette always failed

      Word of advice, if you'd like some more, screw that book, most of the techniques are probably horribly outdated anyway. Some of the books from about 6 years ago with DirectX9 tended to teach practices not nearly practically usable, so I quess with your book, you'll spend more time learning things that are eigther:   - outdated, and not needed anymore (like the palette thing) or - outdated, and overly complicated or "bad" (like twenty-depth inheritance chains for game objects, yieks!)   If I where you, I'd get a decent DirectX10, or at least DirectX9 book. Also, learning DirectX10, there are better alternatives, DirectX11 is almost the same as its predecessor, just with a few more features. Unless you are stuck with Vista, why not start right there? That way you'll be most up to date ;)   Thanks for your suggestion, I'll try it~ 
  13. DirectX7 SetPalette always failed

    Yes, as Nik02 said. Palettes exist only for 8-bit and lower bitty surfaces. Anything higher than that uses direct color values.   Thanks very much~~
  14. DirectX7 SetPalette always failed

    Thanks very much. So I can't set palette in 32-bit surfaces? There is no palette concept in 32-bit mode, can I comprehend it in this way?