C interface as core feature

What it says on the tin: a place to discuss proposed new features.
Post Reply
garvek
Gnoblar
Posts: 8
Joined: Sat Nov 29, 2008 11:50 am

Re: C interface as core feature

Post by garvek » Mon Mar 21, 2011 4:13 pm

Out of curiosity I've tried my own approach this Week End, and was able to run the 1st Ogre advanced tutorial (the one where you implement from scratch the app) ... in plain C and Pascal (with PP binding).

My approach is by hand (except the PP header which was partially generated with h2p). I have flatten class names and namespaces; however I've focused on ease of wrapping, therefore I did'nt implement operators neither tried to have all methods, only the ones I needed for the demo. I have also made some functions which are not mapped 1:1 but rather focus on the actual usage of the function (i.e. it is no use to have some methods exported if they are allways used in a given context, rather implement the block of code and put a wrapper on the top of it).

I have something like this:

Code: Select all

int main()
{
Pointer root = ogre_root_new1("plugins.cfg");

...

Pointer sceneMgr = ogre_root_create_scene_manager(root, "Default", "Default");

...

Pointer node = ogre_scene_manager_get_parent_node(sceneMgr);

...

ogre_scene_node_attach_entity(node, entity);

...

ogre_root_free(root);
}

(I will put the full code later if someone is interrested, of course the actual declaration are on top of the function, you can't instanciate in the middle with pure C)


The jacmoe's state of work is probably beyond mine, therefore I'm not sure it is usefull to continue my wrapper. Anyway I'd be glad to share some stuff if it can help moving forward, and having several approaches to do the same stuff means also several flavors, which is not allways a bad thing.
0 x

User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
Contact:

Re: C interface as core feature

Post by jacmoe » Mon Mar 21, 2011 4:24 pm

Please do!
I am open for any approach really. :)
0 x
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.

tboucher
Gnoblar
Posts: 3
Joined: Wed Oct 21, 2009 5:03 am

Re: C interface as core feature

Post by tboucher » Tue Mar 22, 2011 6:11 am

so0os wrote:

Code: Select all

Ogre_Vector3 Ogre_Vector3_operator_plus(const Ogre_Vector3*, const Ogre_Vector3*);
Can you really look at this snippet and tell this is a good idea? :P Or better than this:

Code: Select all

void add_v3(Ogre_Vector3* op1, Ogre_Vector3* op2,Ogre_Vector3* result /* may be 0 */);
Also, yours is not a valid C and no tweaks are going to make it so. C and C++ are totally different languages in terms of underlying standards, that makes it harder than that.
Ok,

Code: Select all

void Ogre_Vector3_add(const Ogre_Vector3* rhs, const Ogre_Vector3* lhs, Ogre_Vector3* res);
The main point is creating consistent rules for mapping between C++ methods and C functions.
0 x

garvek
Gnoblar
Posts: 8
Joined: Sat Nov 29, 2008 11:50 am

Re: C interface as core feature

Post by garvek » Tue Mar 22, 2011 11:58 am

I'm not sure that "const" is part of C language. Moreover, some other languages are case insensitive, therefore I would recommend putting all in lower case to avoid possible linking issues.
0 x

tboucher
Gnoblar
Posts: 3
Joined: Wed Oct 21, 2009 5:03 am

Re: C interface as core feature

Post by tboucher » Tue Mar 22, 2011 2:39 pm

garvek wrote:I'm not sure that "const" is part of C language. Moreover, some other languages are case insensitive, therefore I would recommend putting all in lower case to avoid possible linking issues.
const and volatile are part of the C language. A const method in C++ is essentially passing 'const this' to the function.

Returning aggregate types (structs) I am not sure about however.

I'm fine with all lower case as well (its fairly common anyway in C to use lower_case_underscore for symbol names).
0 x

User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
Contact:

Re: C interface as core feature

Post by jacmoe » Tue Mar 22, 2011 2:52 pm

This is how things look like now - a small excerpt from ogre_interface.h:

Code: Select all

// Scene nodes
DLL SceneNodeHandle create_child_scenenode(const char* node_name);

DLL void attach_entity_to_scenenode(EntityHandle entity_handle, SceneNodeHandle scenenode_handle);

DLL void scenenode_update(SceneNodeHandle scenenode_handle, int update_children, int parent_has_changed);

DLL void scenenode_update_bounds(SceneNodeHandle scenenode_handle);

DLL EntityHandle scenenode_get_attached_entity_int(SceneNodeHandle scenenode_handle, int entity_index);

DLL EntityHandle scenenode_get_attached_entity(SceneNodeHandle scenenode_handle, const char* entity_name);

DLL int scenenode_num_attached_objects(SceneNodeHandle scenenode_handle);

DLL void scenenode_detach_entity_int(SceneNodeHandle scenenode_handle, int entity_index);

DLL void scenenode_detach_entity(SceneNodeHandle scenenode_handle, EntityHandle entity_handle);

DLL void scenenode_detach_entity_string(SceneNodeHandle scenenode_handle, const char* entity_name);

DLL void scenenode_detach_all_objects(SceneNodeHandle scenenode_handle);

DLL int scenenode_is_in_scenegraph(SceneNodeHandle scenenode_handle);

DLL void scenenode_notify_rootnode(SceneNodeHandle scenenode_handle);

DLL void scenenode_show_boundingbox(SceneNodeHandle scenenode_handle, int show_boundingbox);

DLL void scenenode_hide_boundingbox(SceneNodeHandle scenenode_handle, int hide_boundingbox);

DLL int scenenode_get_show_boundingbox(SceneNodeHandle scenenode_handle);

DLL SceneNodeHandle scenenode_get_parent_scenenode(SceneNodeHandle scenenode_handle);

DLL void scenenode_set_visible(SceneNodeHandle scenenode_handle, int visible);

DLL void scenenode_set_visible_ex(SceneNodeHandle scenenode_handle, int visible, int cascade);

DLL void scenenode_flip_visibility(SceneNodeHandle scenenode_handle);

DLL void scenenode_flip_visibility_ex(SceneNodeHandle scenenode_handle, int cascade);

DLL void scenenode_set_debug_display_enabled(SceneNodeHandle scenenode_handle, int enabled);

DLL void scenenode_set_debug_display_enabled_ex(SceneNodeHandle scenenode_handle, int enabled, int cascade);

DLL SceneManagerHandle scenenode_get_creator(SceneNodeHandle scenenode_handle);

DLL void scenenode_set_direction(SceneNodeHandle scenenode_handle, float x, float y, float z);

DLL void scenenode_set_orientation(SceneNodeHandle scenenode_handle, float w, float x, float y, float z);

DLL void scenenode_set_position(SceneNodeHandle scenenode_handle, float x, float y, float z);

DLL void scenenode_yaw(SceneNodeHandle scenenode_handle, coiReal radians);

DLL void scenenode_set_scale(SceneNodeHandle scenenode_handle, float x, float y, float z);

DLL void scenenode_scale(SceneNodeHandle scenenode_handle, float x, float y, float z);

DLL void scenenode_translate(SceneNodeHandle scenenode_handle, float x, float y, float z);

DLL void scenenode_roll(SceneNodeHandle scenenode_handle, coiReal radians);

DLL void scenenode_pitch(SceneNodeHandle scenenode_handle, coiReal radians);
The goal - as mentioned previously - is not to create a one-to-one mapping between the C++ interface and the C interface, but to create a wholesome and consistent C interface.

About passing structs: I'd prefer to just pass arrays of floats, as it's much cheaper. And better supported (read: SWIG and FFI's). :wink:
0 x
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.

User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
Contact:

Re: C interface as core feature

Post by jacmoe » Tue Mar 22, 2011 2:55 pm

And since most languages - Ruby, Lisp, Python, whatever - uses packages/modules, it is not necessary to prepend everything with 'ogre'.
In Lisp it becomes:

Code: Select all

(ogre:create-root "plugins.cfg" "ogre.cfg" "ogre.log")
(ogre:restore-config)
(ogre:setup-resources "resources.cfg")
0 x
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.

User avatar
so0os
Bugbear
Posts: 833
Joined: Thu Apr 15, 2010 7:42 am
Location: Poznan, Poland

Re: C interface as core feature

Post by so0os » Tue Mar 22, 2011 3:23 pm

i'd get rid of scenenode_ in most cases, since e.g. scenenode_set_position would execute correctly for Node, SceneNode and Bone, so there's really no point in wrapping the three around separatedly without using defines, thus i propose:

Code: Select all


#define scenenode_set_position set_position
#define node_set_position set_position
#define bone_set_position set_position

DLL void set_position(SceneNodeHandle scenenode_handle, float x, float y, float z);
0 x
Sos Sosowski :)
http://www.sos.gd

garvek
Gnoblar
Posts: 8
Joined: Sat Nov 29, 2008 11:50 am

Re: C interface as core feature

Post by garvek » Wed Mar 23, 2011 12:59 am

On my side, I have something like this:

Code: Select all

#ifndef _FLAT_OGRE_ROOT__
#define _FLAT_OGRE_ROOT__

#include "cpp_types.h"

#ifdef __cplusplus
extern "C"
{
#endif

	/*
		Ogre Root constructors, in different flavors
	*/
	DLLEXPORT Pointer ogre_root_new(void);
	DLLEXPORT Pointer ogre_root_new1(PChar pluginFile);
	DLLEXPORT Pointer ogre_root_new2(PChar pluginFile, PChar configFile);
	DLLEXPORT Pointer ogre_root_new3(PChar pluginFile, PChar configFile, PChar logFile);

	/**
		Ogre Root destructor callback

		@param Pointer anonymized pointer to the Ogre::Root element
	*/
	DLLEXPORT void ogre_root_free(Pointer);

	/**
		Tries to load and parse config file

		@param Pointer object
		@return int 0 if failed
	*/
	DLLEXPORT int ogre_root_restore_config(Pointer);

	/**
		Launch Ogre setup and edit / create config file

		@param Pointer object
		@return int 0 if failed
	*/
	DLLEXPORT int ogre_root_show_config(Pointer);

	/**
		Initialize Ogre and automatically create render window

		@param Pointer object
		@param PChar window title
		@return Pointer
	*/
	DLLEXPORT Pointer ogre_root_initialise_create(Pointer, PChar);

	/**
		Initialize Ogre but don't create a render window

		@param Pointer object
		@return int
	*/
	DLLEXPORT int ogre_root_initialise(Pointer);

	/**
		Manually create a render window

		@param Pointer object
		@param PChar window title
		@param int width
		@param int height
		@param int fullscreen
		@param int window context handle
		@return Pointer
	*/
	DLLEXPORT Pointer ogre_root_create_render_window(Pointer, PChar, int, int, int, int);

	/**
		Create a scene manager

		@param Pointer object
		@param PChar type
		@return Pointer
	*/
	DLLEXPORT Pointer ogre_root_create_scene_manager(Pointer, PChar);

	/**
		Render one frame

		@param Pointer object
		@return int
	*/
	DLLEXPORT int ogre_root_render_one_frame(Pointer);

#ifdef __cplusplus
}
#endif

#endif
which gives in my (insane ?) Pascal try:

Code: Select all

program project1;

{$mode objfpc}
{$H+}

uses
  Classes, object_storage, ogre_camera, ogre_config, ogre_entity, ogre_light, ogre_log_manager, ogre_render_window, ogre_resource_group, ogre_root, ogre_scene_manager, ogre_scene_node, ogre_texture_manager, ogre_vector3, ogre_viewport, ogre_window_event_utilities, ois_manager;

var
   ogreRoot, ogreRenderWindow, ogreSceneMgr, ogreCamera, ogreViewport : Pointer;
   oisManager : Pointer;
   stop : Boolean;

const
   PLUGIN_FILE : PChar = 'plugins.cfg';
   RESOURCE_FILE : PChar = 'resources.cfg';

procedure my_event_listener(p: Pointer); cdecl;
begin
if (ois_manager_keyboard_is_pressed(p, 1) = 1)  { KC_ESCAPE }
then
   stop := true;
end;

begin
	writeln('Alloc Ogre Root');
        ogreRoot := ogre_root_new1(PLUGIN_FILE);
	object_store('Root', ogreRoot, @ogre_root_free);

	ogre_config_parse_resources(RESOURCE_FILE);

	if (((ogre_root_restore_config(ogreRoot) <> 1) and (ogre_root_show_config(ogreRoot) <> 1)))
	then begin
		writeln('Configuration failed !');
                object_remove('Root');
		exit;
	end;

        ogreRenderWindow := ogre_root_initialise_create(ogreRoot, 'Ogre Test Window');
	object_store('Window', ogreRenderWindow, nil);

	ogre_texture_manager_set_default_num_mipmaps(5);
	ogre_resource_group_initialise();

        ogreSceneMgr := ogre_root_create_scene_manager(ogreRoot, 'DefaultSceneManager');
	object_store('SceneMgr', ogreSceneMgr, nil);
        ogreCamera := ogre_scene_manager_create_camera(ogreSceneMgr, 'DefaultCamera');
	object_store('Camera', ogreCamera, nil);

	ogre_camera_set_clip_distances(ogreCamera, 5.0, 1000.0);
	ogre_camera_set_position(ogreCamera, 0, 0, 80.0);
	ogre_camera_look_at(ogreCamera, 0, 0, -300.0);

        ogreViewport := ogre_render_window_add_viewport(ogreRenderWindow, ogreCamera);
	object_store('Viewport', ogreViewport, nil);
	ogre_viewport_set_background_color(ogreViewport, 0, 0, 0);
	ogre_camera_set_aspect_ratio(ogreCamera,
		single(ogre_viewport_get_actual_width(ogreViewport)) /
		single(ogre_viewport_get_actual_height(ogreViewport)) );

	object_store('Entity_Head', ogre_scene_manager_create_entity(ogreSceneMgr, 'Head', 'ogrehead.mesh'), nil);
	ogre_scene_node_attach_object(
		ogre_scene_manager_get_root_scene_node(ogreSceneMgr),
		object_retrieve('Entity_Head')
	);

	ogre_scene_manager_set_ambient_light(ogreSceneMgr, 0.5, 0.5, 0.5);

	object_store('Entity_Light', ogre_scene_manager_create_light(ogreSceneMgr, 'Light'), nil);
	ogre_scene_node_attach_object(
		ogre_scene_manager_get_root_scene_node(ogreSceneMgr),
		object_retrieve('Entity_Light')
	);
	ogre_light_set_position(
		object_retrieve('Entity_Light'),
		20.0, 80.0, 50.0
	);

        oisManager := ois_manager_create(ogreRoot, ogreRenderWindow, 0);
	object_store('Input_Manager', oisManager, @ois_manager_destroy);
	ois_manager_register(oisManager, @my_event_listener);

	while (not stop)
	do begin
		ogre_window_event_utilities_message_pump();

		if (ogre_render_window_is_closed(ogreRenderWindow) = 1)
		then
			break;

		if (ogre_root_render_one_frame(ogreRoot) <> 1)
                then
			break;
	end;

	writeln('--- Press a key to continue ---');
	readln;

	writeln('Delete OIS manager');
	object_remove('Input_Manager');

	writeln('Delete Ogre Root');
	object_remove('Root');
end.
This works but with some limitations:
- I miss some exceptions, I'm currently working on intercepting them (if appropriate)
- I used CMake to have VC & MingW environments, however the MingW behavior is different (alloc error on some shaders compilations)
- DLL linkage is a mess; if you build on MSVC you have to use the Ogre DLL along, when you build on MinG you have to use the Ogre *plus* MingW runtimes *plus* boost dlls.
0 x

User avatar
aerique
Halfling
Posts: 59
Joined: Thu Oct 18, 2007 2:37 pm
Location: The Netherlands
Contact:

Re: C interface as core feature

Post by aerique » Thu Mar 24, 2011 11:33 pm

jacmoe wrote:If you want a flat interface in C++, then take a look at libOkra at Github:
https://github.com/aerique/okra/tree/master/libokra/src
Ah, you found Okra. Great :-)

I have (and still am) too busy with other projects to help with the C API for Ogre, but I am glad it is being worked on seriously. A C++ library without a C API is really awful to write bindings for.

Some notes on my adventures in writing Ogre bindings for Common Lisp. I tried a couple of approaches: hand-written bindings, Swig, gcc-xml and I finally settled on using Doxygen's XML output since that was the easiest to work with for me at the time. Back then I was in an "auto-generated bindings are better and more 'proper'" mindset but nowadays I just use handwritten bindings and make then up as I need them (since everyone probably uses at most 10% of Ogre in a single project (but it's a different 10% every time)).

Handwritten bindings take more time if you want to cover the whole API but actually less if you just write what you need (and keep them around). For covering the whole API a project like this is wonderful. Also, Ogre seems to have a pretty stable API.

Anyway, good luck!
0 x
Okra: Common Lisp bindings for Ogre

User avatar
danfma
Gnoblar
Posts: 2
Joined: Thu Apr 08, 2010 10:45 pm
Location: Goiania - GO / Brazil
Contact:

Re: C interface as core feature

Post by danfma » Thu Mar 31, 2011 7:34 pm

I just realize this topic today, so maybe I am really late, but here we go:

I am writing, by hand, C functions to wrap ogre funcionality. The Project is on https://github.com/danfma/InVision

My target is to create a C layer so it could be used on any Ogre + Mono platform, so .NET plataform is what I am aiming for.
The code needs to be cleanup (in some ways) because I am just experimenting things.

By now, I can initialize the ogre root and some other services.

The project is working in some way, and is part of my master degree project, but if there is someone interested or that want to join forces, I would appreciate.

The code is aiming .NET and the API doesn't have the OGRE name, but if the community is interested, I could change the library name to something like cOGRE or whatever, and put someone to help...
0 x
---
Daniel Ferreira Monteiro Alves
danfma@gmail.com

User avatar
lonewolff
Ogre Magi
Posts: 1191
Joined: Wed Dec 28, 2005 12:58 am
x 1

Re: C interface as core feature

Post by lonewolff » Fri Apr 01, 2011 12:08 pm

Man, this would be awesome.

If we could get Ogre running without classes we might be able to create an Ogre assembly app with MASM32.

Now that would be cool! 8)
0 x

User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
Contact:

Re: C interface as core feature

Post by jacmoe » Fri Apr 01, 2011 1:45 pm

Er, guys:
We already have a project:
http://code.google.com/p/llcoi/ :)
0 x
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.

garvek
Gnoblar
Posts: 8
Joined: Sat Nov 29, 2008 11:50 am

Re: C interface as core feature

Post by garvek » Fri Apr 01, 2011 3:45 pm

Glad to see you setup something "official" :)
0 x

User avatar
lonewolff
Ogre Magi
Posts: 1191
Joined: Wed Dec 28, 2005 12:58 am
x 1

Re: C interface as core feature

Post by lonewolff » Sat Apr 02, 2011 4:57 am

Er, guys:
There is nothing there...
0 x

User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
Contact:

Re: C interface as core feature

Post by jacmoe » Sat Apr 02, 2011 3:17 pm

lonewolff wrote:Er, guys:
There is nothing there...
You search like a cow.. :wink:
0 x
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.

User avatar
lonewolff
Ogre Magi
Posts: 1191
Joined: Wed Dec 28, 2005 12:58 am
x 1

Re: C interface as core feature

Post by lonewolff » Sun Apr 03, 2011 12:08 pm

I must admit, I was looking in the downloads section :wink:
0 x

User avatar
B_Lizzard
Kobold
Posts: 28
Joined: Thu Apr 28, 2005 7:58 pm
Location: Greece

Re: C interface as core feature

Post by B_Lizzard » Sun Apr 03, 2011 10:05 pm

Great work, this is perfect for us C-mongers. There aren't many good 3D engines programmable in C out there.

Will this find its way in vanilla OGRE one day?

EDIT: Correct me if I'm wrong, but since this is a 1-for-1 wrapper, it should be possible to use Ogre with SDL as per this (the OpenGL stuff, mainly), am I right?

Also, do you plan on using c_naming_conventions for type names too?
0 x

pratty70
Gnome
Posts: 341
Joined: Thu May 13, 2004 4:52 pm
Location: Wales - UK

Re: C interface as core feature

Post by pratty70 » Sat Apr 09, 2011 8:15 am

I've just stumbled on this. Doing a system at the moment for a client where the other guys in the project are largely c programmers and I'm hiding all the ogre stuff to make it simpler for them to take over this would be perfect.
If I had any time I'd get involved and help - but I'm working far too many hours as it stands.
Pulled down the repository, I'll take a look at the contents today see if I can use it in it's current guise.
Keep up the good work and if I can help, I will!
0 x

User avatar
Denis_
Halfling
Posts: 43
Joined: Thu Jan 04, 2007 1:43 pm
Location: Belarus
Contact:

Re: C interface as core feature

Post by Denis_ » Wed May 18, 2011 10:35 am

I like that idea, so I can help you.
Let me know if you need a hand.
0 x
Image

User avatar
Chris Jones
Lich
Posts: 1742
Joined: Tue Apr 05, 2005 1:11 pm
Location: Gosport, South England

Re: C interface as core feature

Post by Chris Jones » Thu Jun 09, 2011 7:57 am

What's the status of the C interface? Is it still being worked on?
0 x

User avatar
spacegaier
OGRE Team Member
OGRE Team Member
Posts: 4291
Joined: Mon Feb 04, 2008 2:02 pm
Location: Germany
x 2
Contact:

Re: C interface as core feature

Post by spacegaier » Thu Jun 09, 2011 8:16 am

Last commit is from 13 March: http://code.google.com/p/llcoi/updates/list

But let's wait for jacmoe to comment.
0 x
Ogre Admin [Admin, Dev, PR, Finance, Wiki, etc.] | BasicOgreFramework | AdvancedOgreFramework
Don't know what to do in your spare time? Help the Ogre wiki grow! Or squash a bug...

hartsantler
Greenskin
Posts: 107
Joined: Tue Nov 16, 2010 7:33 am

Re: C interface as core feature

Post by hartsantler » Fri Jul 22, 2011 6:08 am

I am working on a C interface, and Python-ctypes wrapper for Ogre.
So far the code generator covers most of Ogre classes and nested classes, but this is still a work in progress, and many things are not working. The generated C API is pretty huge, over 87K lines of code.

http://rpythonic.googlecode.com/files/p ... 29.tar.bz2


So far i only have a blank window popping up.

Code: Select all

import os,sys, time, ctypes
import Ogre as ogre
root = ogre.Root('data/plugins.cfg', 'data/ogre.cfg', 'data/ogre.log')
root.showConfigDialog()
win = root.initialise( True, 'mywindow', '' )
print( win )
for i in range(200):
	time.sleep(0.01)
	root.renderOneFrame()
print('ogre test done')
more updates soon,
-hart
0 x

hartsantler
Greenskin
Posts: 107
Joined: Tue Nov 16, 2010 7:33 am

Re: C interface as core feature

Post by hartsantler » Sun Jul 24, 2011 4:25 pm

I have added support for objects to be returned from methods, and static methods (getSingleton). Much more of the API can be used now.

http://rpythonic.googlecode.com/files/p ... it.tar.bz2

Here's a quick look at the C wrapper:

Code: Select all

void*  Ogre_Root_initialise( void* object, bool  arg0, const char * arg1, const char * arg2 )  {
	return ( void*)( ((Ogre::Root*)object)->initialise(
		arg0,
		arg1,
		arg2 ) );
}
New Python-ctypes Example:

Code: Select all

import os,sys, time, ctypes
import Ogre as ogre

# defaults: pluginFileName = "plugins.cfg" , configFileName = "ogre.cfg" , logFileName = "Ogre.log"
root = ogre.Root('data/plugins.cfg', 'data/ogre.cfg', 'data/ogre.log')
root.showConfigDialog()
win = root.initialise( True, 'mywindow' )
win.setActive(True)
man = root.createSceneManager('OctreeSceneManager', 'mymanager')
cam = man.createCamera( 'mycamera' )
cam.setPosition( 0, 0, 100 )
cam.lookAt( 0, 0, 0 )
view = win.addViewport( cam )
bg = view.getBackgroundColour()
bg.setHSB( 0.5, 0.5, 0.9 )	#Set a colour value from Hue, Saturation and Brightness.
view.setBackgroundColour( bg )

rgman = ogre.ResourceGroupManager.getSingleton()
rgman.addResourceLocation( './data', 'FileSystem', 'General' )	# can be FileSystem or Zip
rgman.initialiseAllResourceGroups()

rootnode = man.getRootSceneNode()
e = man.createEntity( 'mycube', 'Cube.mesh', groupName='General' )
node = rootnode.createChildSceneNode( ogre.Vector3(), ogre.Quaternion() )
node.attachObject( e )

for i in range(200):
	time.sleep(0.01)
	root.renderOneFrame()
	win.swapBuffers()
0 x

User avatar
Nauk
Gnoll
Posts: 647
Joined: Thu May 11, 2006 9:12 pm
Location: Bavaria
Contact:

Re: C interface as core feature

Post by Nauk » Sun Sep 25, 2011 11:18 pm

jacmoe wrote:
lonewolff wrote:Er, guys:
There is nothing there...
You search like a cow.. :wink:
haha :D

awesome feature and very usefull, time to start looking at D again then! :)
0 x

Post Reply