Page 5 of 6

Posted: Mon Apr 20, 2009 1:44 pm
by hybrid
Try to start it from the command line, and check what the console prints. I guess the paths are wrong.

Posted: Mon Apr 20, 2009 3:21 pm
by Fareusel
Well, it's getting quite more confusing:


It really seems to be a problem of finding the resource-files.
I tested three ways of starting the program:

--------------------------------------------------------------------------------------------
1st way: Terminal
The terminal says, that it cannot load the mesh (../Resources/sydney.md2) because the file could not be opend and leave me with a blank window.
--------------------------------------------------------------------------------------------
2nd way: Xcode
Starting the program with "Build&Run" out of Xcode, there is no terminal window (printf's are simply ignored?), the mesh loads up and is displayed but without any texture (white).
--------------------------------------------------------------------------------------------
3rd way: Double-click on the app in the Finder
Like the terminal method it gives a blank Irrlicht-window to me, but without the error messages in the terminal window.
--------------------------------------------------------------------------------------------

The most confusing fact at this problem is following:
As my app-file is a normal OS X Application, it is a package. If I open this package in the finder, I get the following file structur:

Code: Select all

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>
So "Irrlicht-Konfigurationstest.app" is my OS X appication, and therein "Irrlicht-Konfigurationstest" (in the MacOS folder) is the actual runable programfile. That's also the one I have to run in the terminal.

As you can see, the path "../Resources/sydney.md2" should be quite correct, reffering to my executable file in "MacOS".

I really don't understand what is wrong with it? Can anyone tell me what I am doing wrong? And why are there two ways of behaviour? If i start the program by clicking the build&run button in Xcode, the mesh is loaded correctly but without texture. If I start the program in the terminal or finder, nothing is loaded at all!?

:/ quite confusing!

Posted: Mon Apr 20, 2009 6:30 pm
by Fareusel
Hi,

ok, well, I've got a solution for loading files out of the application bundle, but the mesh is still white!

I took some Mac OS X-specific code (CFBundle) and loaded my resources from the bundle. My Sourcecode is now the following:

Code: Select all

#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;
}
The Terminal says "Mesh loaded" and "Texture Loaded". The only problem is, that there is not texture loaded! -.-

still a white mesh.

what should I do?

Posted: Mon Apr 20, 2009 8:20 pm
by hybrid
If the console tells you the texture was loaded it's ok. Maybe it's a problem with the OpenGL driver, problematic/broken support of NPOT?

Posted: Mon Apr 20, 2009 8:57 pm
by Fareusel
Cool, that was the point: My ATI Radeon X1600 doesn't support NPOT =)
thank you very much, resizing the texture file works! yeah!

Posted: Wed Apr 29, 2009 5:12 am
by afecelis
Fareusel, do you have a copy of Zathras' tutorial? The link posted here:
http://www.ruthless.zathras.de/facts/ap ... on-mac.php
seems to be dead. I'm really interested in checking how he setup things to compile a new project.

I've also added everything as described here but without any success, so any extra info will come in handy ;)

regards,
Alvaro

ps. If anyone else has got a copy of this tutorial, please post it here :D

Posted: Thu Dec 31, 2009 12:19 pm
by Ven
at first sorry for bumping this old topic.
i followed the tutorial, with some necessary changes and my project is compiling, giving me a static grey screen and freezing my mouse cursor till i fquit the app., instead of displaying the obj. i was expecting.
anyone experience the same problem - has a possible solution?
forgot to add, i am running xcode 3.2.1 on snow leopard.
thanks a lot

Posted: Mon Jan 04, 2010 5:29 pm
by ecsos
If you just drag jpeg into your project, it ends up in the Resources folder once you build and run. Hence why the Resources folder should be included in the default folder archives. Bitplane was supposed to have added this already. You shouldn't need a special function resPath or have to specify a path to the resources folder.

I cannot run the examples on OSX

Posted: Thu Jul 22, 2010 5:16 pm
by zevarito
Hi,

I am trying to get the examples work without success, I can compile the lib and the examples but when try to run it nothing happen, the shell don't log nothing so I have not idea of what is happening, I am new on Xcode so may be I am missing something, any help?

OSX 10.6.4 Xcode 3.2.2

thanks!

Posted: Thu Jul 22, 2010 5:26 pm
by hybrid
The problem is usually that the console does not start for the examples when run from within XCode. You need to start the apps fromt he console manually, or change the driver choice to return OpenGL without interaction.

Posted: Sun Sep 26, 2010 11:28 pm
by jokoon
I'm really begging for someone to redo this short howto, Xcode has changed a lot of its interface, and irrlicht has changed also...

Posted: Fri Mar 04, 2011 10:31 pm
by jpenguin
I'm still trying to get it to work, bu I found one-

http://karlkirch.com/blog/2010/03/10/irrlicht-xcode/

Re: [Tutorial] Getting started on Mac OS X

Posted: Fri Aug 26, 2011 8:11 am
by JamesMoon
Hello.. osxus3r

Are you still in this forum?..

It's been several years since you have posted this thread.

I hope you to write again for iPad app in Xcode 4 or Xcode 3.2.6 ..

There are quite much needs for simple and fast 3d engine in iOS programming.

Regards

Re: [Tutorial] Getting started on Mac OS X

Posted: Tue Nov 22, 2011 11:28 am
by Carnafex
Heya everyone,

Thought I would just post the steps I used to get a new project up in XCode 4.1, seeing how its substantially different from the older version!
Note that I had to compile irrlicht myself to get the static library first before I could do this. (I managed to compile it from 1.7.2 base, check out http://irrlicht.sourceforge.net/forum/v ... =1&t=44736

Anyway to start:
  1. Create a new empty project.
  2. Add a target. (You can do this by left clicking the project file in the tree menu on the left, then look for a circle with a plus at the bottom of the window)
    • Select Max OS X > Application > Cocoa Application
  3. Now delete the *AppDelegate.m, *AppDelegate.h and *.xib file, you wont need these.
  4. Now create a new file
    • I usually select Mac OS X > C and C++ > C++ File. I also usually fill it with the Example 1 tutorial to get the app compiling with some output to start.
  5. Now click on the project in the left tree menu again
  6. In the central part of the screen, click "Build Settings", and change the following settings:
    1. Base SDK: Standard (32/64 bit intel)
    2. Base SDK: Latest Mac OS X
    3. Compiler for C/C++/Objective-C: LLVM GCC 4.2
    4. Header Search Paths: /Path/To/Your/Irrlicht/Folder/include
  7. Now select "Build Phases"
    1. Under "Link Binary With Libraries, click the plus and add Cocoa, Carbon, IOKit, OpenGL, and the libIrrlicht.a file.
    2. under "Compile Sources", select the 'main.m' and then delete the main.m file
  8. Compile!
Hopefully this will help some people get started!

Re: [Tutorial] Getting started on Mac OS X

Posted: Mon Feb 11, 2013 11:12 am
by champialex
Hi, I have been struggling for a a little while to find out the right command to compile an irrlicht file from command line once installed using the tutorial [1]. So I figured I would share it :

Code: Select all

 
g++ -o MyApp.app/Contents/MacOS/MyApp myfile.cpp -fvisibility=hidden -lirrlicht -framework Foundation -framework OpenGL -framework Cocoa -framework Carbon -framework AppKit -framework IOKit
 
Packaging it as a MacOS app avoid trouble with catching keyboard input.
You must of course have created the folder MyApp.app/Contents/MacOS beforehand

Hope it helps some people.
I think I would be nice to have this on the front page.


[1] http://irrlicht3d.org/wiki/index.php?n= ... uildMacOSX