
As far as I understand this, it will not be possible to implement this Ogre interface in pure C because of the void* handles used for C++ objects, right?
If anyone decides to do this, please, please release the output of the code generation, rather than "just" the method of generating it.JamesKilton wrote:As a half-shameless-plug, instead of doing all this by hand, have you guys looked into GCC-XML for parsing the Ogre code and giving you a list of methods and enumerations to export to C? The tools pygccxml (it's website is down, strange) or rbgccxml (mine, http://rbplusplus.rubyforge.org/rbgccxml.html) make it very easy to query the XML you get back for this information and do with it what you will.
Code: Select all
(require 'ogre)
(defparameter *windowhandle* nil)
(defparameter *camerahandle* nil)
(defparameter *viewporthandle* nil)
(defparameter *windowhwnd* nil)
(defparameter *entityhandle* nil)
(defparameter *nodehandle* nil)
(defparameter *lighthandle* nil)
(defparameter *mouse* nil)
(defparameter *keyboard* nil)
(ogre:create-root "plugins.cfg" "ogre.cfg" "ogre.log")
(ogre:restore-config)
(ogre:setup-resources "resources.cfg")
(setq *windowhandle* (ogre:root-initialise 1 "therenderwindow"))
(ogre:set-default-num-mipmaps 5)
(ogre:initialise-all-resourcegroups)
(ogre:create-scene-manager "OctreeSceneManager" "scenemanager")
(setq *camerahandle* (ogre:create-camera "myCam"))
(ogre:camera-set-position *camerahandle* 0.0 0.0 280.0)
(ogre:camera-lookat *camerahandle* 0.0 0.0 -300.0)
(setq *viewporthandle* (ogre:add-viewport *camerahandle*))
(ogre:viewport-set-background-colour *viewporthandle* 0.0 0.0 0.0)
(ogre:camera-set-aspect-ratio *camerahandle* 800.0 600.0)
(setq *entityhandle* (ogre:create-entity "OgreHead" "ogrehead.mesh"))
(setq *nodehandle* (ogre:create-child-scenenode "headnode"))
(ogre:attach-entity-to-scenenode *entityhandle* *nodehandle*)
(ogre:set-ambient-light-rgb 0.5 0.5 0.5)
(setq *lighthandle* (ogre:create-light "mainLight"))
(ogre:light-set-position *lighthandle* 20.0 80.0 50.0)
(ogre:log-message "Hello World from Lisp")
;;(ogre:render-window-update *windowhandle* 1)
;;(setq *windowhwnd* (ogre:render-window-get-hwnd *windowhandle*))
;;(ogre:create-input-system *windowhwnd*);
;;(setq *keyboard* (ogre:create-keyboard-object 0))
;;(setq *mouse* (ogre:create-mouse-object 0))
;;(ogre:render-one-frame)
;;(ogre:render-loop)
(let ((n 0))
(loop
(when (> n 4000) (return))
(ogre:pump-messages)
(ogre:render-one-frame)
(incf n)))
(ogre:release-engine)
Code: Select all
#+sbcl(sb-ext::set-floating-point-modes :traps nil)
Do you have an example script for Ogre?JamesKilton wrote:As a half-shameless-plug, instead of doing all this by hand, have you guys looked into GCC-XML for parsing the Ogre code and giving you a list of methods and enumerations to export to C? The tools pygccxml (it's website is down, strange) or rbgccxml (mine, http://rbplusplus.rubyforge.org/rbgccxml.html) make it very easy to query the XML you get back for this information and do with it what you will.
Code: Select all
#elif defined( __GNUC__ )
# define OGRE_COMPILER OGRE_COMPILER_GNUC
# define OGRE_COMP_VER (420)
Python-Ogre doesn't patch Ogre's code to get around the gcc-xml tr1 issue. It simply (re-)defines OGRE_COMP_VER 420 after including OgrePlatform.h in one of it's header files:JamesKilton wrote:Ya I had to follow what Python-Ogre does and actually patch Ogre's code a little bit to get around that stuff.
This is for 1.6.2, I haven't tried running against 1.7.x yet: https://github.com/jameskilton/ogrerb/b ... -6-2.patch
then run with -D__OGRERB_BUILD and the rest of the code had no problems.
Code: Select all
#include "OgrePlatform.h"
#if (OGRE_COMPILER == OGRE_COMPILER_GNUC ) && OGRE_THREAD_PROVIDER
#define OGRE_COMP_VER 420
#endif
As a first step you could take a look at the python-ogre code generators. There was some work previously to allow them to generate python Swig interface files though I don't know if that is in trunk at the moment.jacmoe wrote:Thanks!
It worked wonderfully.
Now I need to figure out what to do with the *huge* XML file it made..
I hope that gccxml is upgraded to gcc 4.4 some day..
Would defining GCC version 420 help, I wonder?
Code: Select all
Ogre::MovableObject::Listener
Ogre::MovableObject::operator=(Ogre::MovableObject const&)
Ogre::MovableObject::MovableObject(Ogre::MovableObject const&)
Ogre::MovableObject::MovableObject()
Ogre::MovableObject::MovableObject(std::string const&)
Ogre::MovableObject::~MovableObject()
Ogre::MovableObject::_notifyCreator(Ogre::MovableObjectFactory*)
Ogre::MovableObject::_getCreator() const
Ogre::MovableObject::_notifyManager(Ogre::SceneManager*)
Ogre::MovableObject::_getManager() const
Ogre::MovableObject::getName() const
Ogre::MovableObject::getMovableType() const
Ogre::MovableObject::getParentNode() const
Ogre::MovableObject::getParentSceneNode() const
Ogre::MovableObject::isParentTagPoint() const
Ogre::MovableObject::_notifyAttached(Ogre::Node*, bool)
Ogre::MovableObject::isAttached() const
Ogre::MovableObject::detachFromParent()
Ogre::MovableObject::isInScene() const
Ogre::MovableObject::_notifyMoved()
Ogre::MovableObject::_notifyCurrentCamera(Ogre::Camera*)
Ogre::MovableObject::getBoundingBox() const
Ogre::MovableObject::getBoundingRadius() const
Ogre::MovableObject::getWorldBoundingBox(bool) const
Ogre::MovableObject::getWorldBoundingSphere(bool) const
Ogre::MovableObject::_updateRenderQueue(Ogre::RenderQueue*)
Ogre::MovableObject::setVisible(bool)
Ogre::MovableObject::getVisible() const
Ogre::MovableObject::isVisible() const
Ogre::MovableObject::setRenderingDistance(float)
...
Code: Select all
namespace Ogre { class Ogre ....};
Code: Select all
typedef void Ogre_Root;
Code: Select all
bool Ogre::Root::isInitialised(void) const;
Code: Select all
int Ogre_Root_isInitialised(const Ogre_Root*);
Code: Select all
class Ogre::Vector3 { ... };
Code: Select all
struct Ogre_Vector3 { Real x, y, z; };
Code: Select all
Ogre::Vector3 Ogre::Vector3::operator+(const Ogre::Vector3&) const;
Code: Select all
Ogre_Vector3 Ogre_Vector3_operator_plus(const Ogre_Vector3*, const Ogre_Vector3*);
Code: Select all
class Foo
{
virtual void doFoo() = 0;
};
Code: Select all
class Foo_Wrapper : Foo
{
public:
void doFoo()
{
assert(doFoo_cb);
doFoo_cb();
}
void set_doFoo_cb(void (*cb)())
{
doFoo_cb = cb;
}
private:
void (*doFoo_cb)() = 0;
}
Code: Select all
void Foo_doFoo(Foo* p) { ((Foo_Wrapper*)p)->doFoo(); }
void set_doFoo_cb(Foo* p, void (*cb)()) { ((Foo_Wrapper*)p)->set_doFoo_cb(cb); }
Code: Select all
int foo(int);
int foo(int, int);
int foo(float, int);
Code: Select all
int foo_1i(int); int foo_2i(int, int); int foo_1f1i(float, int);
// or
int foo_int(int); int foo_int_int(int, int); int foo_float_int(float, int);
// or
int foo1(int); int foo2(int, int); int foo3(float, int);
Code: Select all
Ogre_Vector3 Ogre_Vector3_operator_plus(const Ogre_Vector3*, const Ogre_Vector3*);
Code: Select all
void add_v3(Ogre_Vector3* op1, Ogre_Vector3* op2,Ogre_Vector3* result /* may be 0 */);