Irrlicht-Konfigurationstest.app <Mac OS X Application File>
|
|__+ Contents <Folder>
|
|___ Info.plist <Property List>
|
|__+ MacOS <Folder>
| |
| |__ Irrlicht-Konfigurationstest <Executable>
|
|__PkgInfo <Plain Text>
|
|__+ Resources <Folder>
|
|__ sydney.md2 <MD2 Mesh>
|
|__ sydney.bmp <Windows/OS2 Bitmap>
|
|__ ... (other resources) <some other files>
#include <OpenGL/OpenGL.h>
#include <Carbon/Carbon.h>
#include <CoreFoundation/CFBundle.h>
#include <CoreFoundation/CFString.h>
#include <irrlicht.h>
#include <iostream>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
#pragma comment(lib, "libIrrlicht.a")
// function provides some Mac OS X specific source code to load files from the resources of the application bundle.
char * resPath(char **argv, char* name, char* type )
{
char resource[1024];
CFURLRef cfBundleURL = CFBundleCopyResourceURL( CFBundleGetMainBundle(),
CFStringCreateWithCString(kCFAllocatorDefault,
name,
kCFStringEncodingISOLatin1),
CFStringCreateWithCString(kCFAllocatorDefault,
type,
kCFStringEncodingISOLatin1),
NULL );
CFStringGetCString( CFURLCopyPath(cfBundleURL),
resource,
1023,
kCFStringEncodingISOLatin1);
return resource;
}
int main(int argc, char** argv)
{
IrrlichtDevice *device = createDevice(EDT_OPENGL,
dimension2d<s32>(512, 384),
16,
false,
false,
false,
0);
device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo");
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IAnimatedMesh* mesh = smgr->getMesh( resPath(argv, "sydney", "md2") );
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
if (node)
{
node->setMaterialFlag(EMF_LIGHTING, false);
node->setFrameLoop(0, 310);
// -- PROBLEM -- Irrlicht still displays just a white mesh without texture!
node->setMaterialTexture( 0, driver->getTexture( resPath(argv, "sydney", "bmp") ));
}
smgr->addCameraSceneNode(0,
vector3df(0,30,-40),
vector3df(0,5,0));
while(device->run())
{
driver->beginScene(true,
true,
SColor(255,100,101,140));
smgr->drawAll();
driver->endScene();
}
device->drop();
return 0;
}
g++ -o MyApp.app/Contents/MacOS/MyApp myfile.cpp -fvisibility=hidden -lirrlicht -framework Foundation -framework OpenGL -framework Cocoa -framework Carbon -framework AppKit -framework IOKit
Return to FAQs, Tutorials, Howtos, and external tool lists
Users browsing this forum: No registered users and 1 guest