Posts RSS Comments RSS Del.icio.us Digg Technorati Blinklist Furl reddit 105 Posts and 7 Comments till now
This wordpress theme is downloaded from wordpress themes website.

Vulkan 1.0 released

I started writing DirectX/OpenGL code when I took multiple college classes in computer graphics and game programming (in 2001 or 2002).  In the years since then, I

HeroQuest – Prior Work and References

HeroQuest (Games Workshop, Milton Bradley) was released in America and Canada in 1990 (Europe and Australasia in 1989). Today there are some great HeroQuest fan websites and online communities. In the 26 years since the American release, there have been software development projects related to HeroQuest including video games and map editors. This post is an overview of prior work and references in the HeroQuest community that relate to my project.

Board Game: The original board game has long been out of print. The American release and the European/Australasian release have minor differences.  The six standard expansions are – Kellar’s Keep, Return of the Witch Lord, Against the Ogre Horde (Europe only), Wizards of Morcar (Europe only), The Dark Company (Europe only), The Mage of the Mirror (America only), The Frozen Horror (America only).  Related games were released by Games Workshop including Advanced HeroQuest and Warhammer Quest. An unofficial 25th anniversary edition was crowdfunded.  Fan websites have variations on everything

HeroQuest map loader

It

Unreal Engine 4 – side project started

Short story – my latest side project as of Jan 2016 is a game using Unreal Engine 4.

Long story

Fix minor camera bug (with GLM camera)

My previous post

Emscripten build target (JavaScript asm.js WebGL)

I

C++ member function pointer, parent class, template, std::function

Today I ran into a C++ scenario where I found std::function to be useful.  I wanted to create a std::queue of member function pointers to functions that are children of the same parent class.  For example:

class Parent
{
public:
    Parent() {};
    virtual ~Parent() {};
};
class ChildA : public Parent
{
public:
    ChildA() : Parent() {};
    ~ChildA() {};
    void Execute01() {printf("A");};
    void Execute02() {printf("B");};
    void Execute03() {printf("C");};
};
class ChildB : public Parent
{
public:
    void Execute01() {printf("D");};
    void Execute02() {printf("E");};
    void Execute03() {printf("F");};
};

To keep it simple, this examples shows two child classes (ChildA, ChildB), but I wanted it to work for lots more child classes.  I wanted to push() member function pointers to ChildA::Execute01() etc into a std::queue…  But I ran into an issue.  The declaration for a member function pointer requires the class to be specified, and the execution requires an instance of the class the be specified.  So the following snippet is valid:

typedef void (ChildA::*funcPtr)(); 
std::queue<funcPtr> theQueue; 
ChildA childA; 
theQueue.push(&ChildA::Execute01); 
funcPtr fn = theQueue.front(); 
(childA.*fn)();

However, I can’t push() a pointer to a ChildB member function into this same std::queue.  If I try referencing the parent class as follows:

typedef void (Parent::*funcPtr)();
std::queue<funcPtr> theQueue;
ChildA childA;
theQueue.push(&ChildA::Execute01);
funcPtr fn = theQueue.front();
(childA.*fn)();

Then Visual Studio 2013 gives me an error:

Error    9    error C2664: ‘void std::queue<funcPtr,std::deque<_Ty,std::allocator<_Ty>>>::push(void (__cdecl Parent::* const &)(void))’ : cannot convert argument 1 from ‘void (__cdecl ChildB::* )(void)’ to ‘void (__cdecl Parent::* &&)(void)’

Ignoring C++14’s variable templates, there are two types of templates – function templates and class templates…  So we can’t just use a template on the function pointer’s typedef.  Instead, my next solution was to make a queue of Delegate’s and use a template to define the delegate class’s children:

class Delegate
{
public:
  Delegate() {};
  virtual ~Delegate() {};
  virtual void ExeFunc() = 0;
};
template<class T>
class DelegateT : public Delegate
{
public:
  DelegateT(T* obj, void (T::*func)()) { m_obj = obj; m_func = func; };
  ~DelegateT() {};
  void ExeFunc() { (m_obj->*m_func)(); }
protected:
  void (T::*m_func)();
  T* m_obj;
};

And here’s an example usage:

std::queue<Delegate *> theQueue;
ChildA childA;
ChildB childB;
theQueue.push(new DelegateT<ChildA>(&childA, &ChildA::Execute01));
theQueue.push(new DelegateT<ChildB>(&childB, &ChildB::Execute01));
while (!theQueue.empty())
{
  Delegate *del = theQueue.front();
  del->ExeFunc();
  theQueue.pop();
  delete del;
}

Finally I ran into a more modern solution (but not that modern seeing as it’s supported by Visual Studio 2010) – use std::function:

ChildA childA;
ChildB childB;
std::queue<std::function<void()>> theQueue;
theQueue.push(std::bind(&ChildA::Execute01, childA));
theQueue.push(std::bind(&ChildB::Execute01, childB));
while (!theQueue.empty())
{
  std::function<void()> func = theQueue.front();
  func();
  theQueue.pop();
}

Tile Map Geometry

Today I implemented tile map geometry.

Basically the way it works is I have a class TileFloorData that stores a 2D array of Tile

C++, SDL2, OpenGL ES 2 (GLES2), CMake, Git

Background, CMake

Two C++ OpenGL side projects I

C++ view assembly (auto-vectorizer) (MSVC) (clang/LLVM)

This link ( http://bit.ly/1yLKB8O ) describes three ways to view assembly code in the Visual Studio debugger

1) While stepping your code in Visual Studio debugger, do (ctrl+alt+d) or right click -> Go To Disassembly
image

2) Right-click project settings -> C/C++ -> Output Files -> ASM List Location. The *.asm or *.cod file will be output to your build output folder such as

« Previous PageNext Page »

Check out best marijuana drug testing website.