Sha256: 74c6ec403a9092c3b0868522b80a708469476f5e1753d8d6bf77c51d1f52ad5a

Contents?: true

Size: 1.72 KB

Versions: 3

Compression:

Stored size: 1.72 KB

Contents

%{
  #include "OgreResource.h"
  #include "OgreGpuProgram.h"
  #include "OgreMaterial.h"
  #include "OgreMesh.h"
  #include "OgrePatchMesh.h"
  #include "OgreSkeleton.h"
  #include "OgreSkeletonInstance.h"
  #include "OgreTexture.h"
%}

namespace Ogre {
  %ignore Resource::addListener;
  %ignore Resource::removeListener;

  %template(ResourceSharedPtr) SharedPtr<Resource>;
}

%ignore extractResource;

%inline %{
  
  // Helper function to convert Resources to correct derived type
  // for Ruby
  VALUE extractResource(Ogre::ResourcePtr res)
  {
    swig_type_info* type = NULL;
    
    // cl for windows does not recognize ResourcePtr as a *pointer.
    // In order to create our swig type, we create a reference to
    // the ResourcePtr object, and use Resource * for the dynamic class checking.
    ResourcePtr *newRes = new ResourcePtr(res);
    
    Ogre::Resource * ptr = res.getPointer();
		
     if (dynamic_cast<Ogre::Material *>(ptr)) {
        type = SWIGTYPE_p_Ogre__MaterialPtr;
		 }
     else if (dynamic_cast<Ogre::PatchMesh *>(ptr))
        type = SWIGTYPE_p_Ogre__PatchMeshPtr;

     else if (dynamic_cast<Ogre::Mesh *>(ptr))
        type = SWIGTYPE_p_Ogre__MeshPtr;

     else if (dynamic_cast<Ogre::GpuProgram *>(ptr))
        type = SWIGTYPE_p_Ogre__GpuProgramPtr;

     else if (dynamic_cast<Ogre::Skeleton *>(ptr))
        type = SWIGTYPE_p_Ogre__SkeletonPtr;

     else if (dynamic_cast<Ogre::Texture *>(ptr))
        type = SWIGTYPE_p_Ogre__TexturePtr;

     if (type)
        return SWIG_NewPointerObj( (void*) (newRes), type, SWIG_POINTER_OWN);

     return Qnil;
  }

%}

// All Resources turn into appropriate type on output to Ruby
%typemap(out) Ogre::ResourcePtr
{
    $result = extractResource($1);
}

%include "OgreResource.h"

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
shattered_ogrerb-0.5.0.1 vendor/ogrerb/ogre/OgreResource.i
shattered_ogrerb-0.5.0.2 vendor/ogrerb/ogre/OgreResource.i
shattered_ogrerb-0.5.1 vendor/ogrerb/swig/ogre/OgreResource.i