from .dll to .bundle

Moderator
Posts: 373
Joined: 2006.08
Post: #1
First off: I know that I posted related to this earlier about how to do this, but now that I'm actually doing it, I need a bit more help.
I'm transferring my .dll files to .bundle files on the Mac; I'm not really using .dll files for their true purpose, instead I'm just basically using them to export the classes that they contain; while some may say that this is pointless, it has simplified the development of my game quite a bit, which is what I was aiming for.
Here is the header file of the .dll on windows:

Code:
#ifndef OBJECTMANAGER_HPP
#define OBJECTMANAGER_HPP

#include "object.hpp"

class __declspec(dllexport) objectManager
{
      public:

      object* objects;
      object boundingCube;
      int numberOfObjects;
      double offsetX;
      double offsetY;
      double offsetZ;
            
      objectManager();
      void copyConstructor(objectManager* copiedObjectManager);
      ~objectManager();
      
      void loadObjects(const char* theManagerName);
      void moveX(double addX);
      void moveY(double addY);
      void moveZ(double addZ);
      void draw();
      void drawBounding();
      
};

#endif

and the .cpp file:
Code:
#include "objectManager.hpp"

using namespace std;

objectManager::objectManager()
{
numberOfObjects = 0;
offsetX = 0.0;
offsetY = 0.0;
offsetZ = 0.0;

boundingCube.shapes = new shape[6];
for(int i=0; i<=5; i++)
{
boundingCube.shapes[i].constructor(3);
}
}

void objectManager::copyConstructor(objectManager* copiedObjectManager)
{
offsetX = copiedObjectManager->offsetX;
offsetY = copiedObjectManager->offsetY;
offsetZ = copiedObjectManager->offsetZ;
numberOfObjects = copiedObjectManager->numberOfObjects;
objects = new object[numberOfObjects+1];

for(int i=0; i<=numberOfObjects; i++)
{
objects[i].copyConstructor(&copiedObjectManager->objects[i]);
}
    
    for(int i=0; i<=5; i++)
    {
    for(int x=0; x<=3; x++)
    {
    boundingCube.shapes[i].setCurrentXYZ(copiedObjectManager->boundingCube.shapes[i].vertices[x].getX(), copiedObjectManager->boundingCube.shapes[i].vertices[x].getY(), copiedObjectManager->boundingCube.shapes[i].vertices[x].getZ());
    }
    }    
}

objectManager::~objectManager()
{
delete [] objects;
}

void objectManager::loadObjects(const char* theManagerName)
{

#if defined(__APPLE_CC__)
CFBundleRef mainBundle = CFBundleGetMainBundle();
    CFURLRef resourcesURL = CFBundleCopyBundleURL(mainBundle);
    char path[PATH_MAX];
    if (!CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX))
    {
        fprintf(stderr, "Can't change to Resources direcory; something's seriously wrong\n");
        exit(EXIT_FAILURE);
    }
    CFRelease(resourcesURL);
    
    int dotOperatorPos = 0;
    
    while(path[dotOperatorPos] != '.')
    {
    
    dotOperatorPos = dotOperatorPos + 1;
    
    }
    
    path[(dotOperatorPos + 3)] = '\0';
    path[(dotOperatorPos + 2)] = '\0';
    path[(dotOperatorPos + 1)] = '\0';
    path[dotOperatorPos] = '\0';
    
    for(int i=dotOperatorPos;path[i] != '/';i--)
    {
    
    path[i] = '\0';
    
    }
    
    
    chdir(path);
#endif

    FILE * readFile;
    
    std::string temporaryFileName = std::string("Objects/") + theManagerName + std::string("/meshList.txt");
    char parameterFile[temporaryFileName.length()];
    for(int x=0;x<=temporaryFileName.length();x++)
    {
    parameterFile[x] = temporaryFileName[x];
    }
    
    
    readFile = fopen(parameterFile,"r+t");
    if(readFile)
    {
    fscanf(readFile, "%d", &numberOfObjects);
    
    objects = new object[numberOfObjects+1];
    char tempObjectName[20];
    
    for(int i=0; i<=numberOfObjects; i++)
    {
    fscanf(readFile, "%s", &tempObjectName);
    objects[i].loadShapes(theManagerName, tempObjectName);
    }

    fclose(readFile);
    }
    
    double tempX = 0.0;
    double tempY = 0.0;
    double tempZ = 0.0;
    
    for(int i=0; i<=numberOfObjects; i++)
    {
    if(objects[i].boundingX > tempX)
    {
    tempX = objects[i].boundingX;
    }
    if(objects[i].boundingY > tempY)
    {
    tempY = objects[i].boundingY;
    }
    if(objects[i].boundingZ > tempZ)
    {
    tempZ = objects[i].boundingZ;
    }
    }
    
    boundingCube.shapes[0].setCurrentXYZ((tempX * -1), (tempY * -1), (tempZ * -1));
    boundingCube.shapes[0].setCurrentXYZ(tempX, (tempY * -1), (tempZ * -1));
    boundingCube.shapes[0].setCurrentXYZ(tempX, tempY, (tempZ * -1));
    boundingCube.shapes[0].setCurrentXYZ((tempX * -1), tempY, (tempZ * -1));
    
    boundingCube.shapes[1].setCurrentXYZ((tempX * -1), (tempY * -1), (tempZ * -1));
    boundingCube.shapes[1].setCurrentXYZ((tempX * -1), (tempY * -1), tempZ);
    boundingCube.shapes[1].setCurrentXYZ((tempX * -1), tempY, tempZ);
    boundingCube.shapes[1].setCurrentXYZ((tempX * -1), tempY, (tempZ * -1));
    
    boundingCube.shapes[2].setCurrentXYZ((tempX * -1), (tempY * -1), tempZ);
    boundingCube.shapes[2].setCurrentXYZ(tempX, (tempY * -1), tempZ);
    boundingCube.shapes[2].setCurrentXYZ(tempX, tempY, tempZ);
    boundingCube.shapes[2].setCurrentXYZ((tempX * -1), tempY, tempZ);
    
    boundingCube.shapes[3].setCurrentXYZ(tempX, (tempY * -1), (tempZ * -1));
    boundingCube.shapes[3].setCurrentXYZ(tempX, (tempY * -1), tempZ);
    boundingCube.shapes[3].setCurrentXYZ(tempX, tempY, tempZ);
    boundingCube.shapes[3].setCurrentXYZ(tempX, tempY, (tempZ * -1));
    
    boundingCube.shapes[4].setCurrentXYZ((tempX * -1), tempY, (tempZ * -1));
    boundingCube.shapes[4].setCurrentXYZ((tempX * -1), tempY, tempZ);
    boundingCube.shapes[4].setCurrentXYZ(tempX, tempY, tempZ);
    boundingCube.shapes[4].setCurrentXYZ(tempX, tempY, (tempZ * -1));
    
    boundingCube.shapes[5].setCurrentXYZ((tempX * -1), (tempY * -1), (tempZ * -1));
    boundingCube.shapes[5].setCurrentXYZ((tempX * -1), (tempY * -1), tempZ);
    boundingCube.shapes[5].setCurrentXYZ(tempX, (tempY * -1), tempZ);
    boundingCube.shapes[5].setCurrentXYZ(tempX, (tempY * -1), (tempZ * -1));
    
}

void objectManager::moveX(double addX)
{
offsetX = offsetX + addX;
for(int i=0; i<=5; i++)
{
boundingCube.shapes[i].moveX(addX);
}
for(int i=0; i<=numberOfObjects; i++)
{
objects[i].boundingSquare.moveX(addX);
}
}

void objectManager::moveY(double addY)
{
offsetY = offsetY + addY;
for(int i=0; i<=5; i++)
{
boundingCube.shapes[i].moveY(addY);
}
for(int i=0; i<=numberOfObjects; i++)
{
objects[i].boundingSquare.moveY(addY);
}
}

void objectManager::moveZ(double addZ)
{
offsetZ = offsetZ + addZ;
for(int i=0; i<=5; i++)
{
boundingCube.shapes[i].moveZ(addZ);
}
for(int i=0; i<=numberOfObjects; i++)
{
objects[i].boundingSquare.moveZ(addZ);
}
}

void objectManager::draw()
{
     glTranslatef(offsetX, offsetY, offsetZ);
     for(int i=0;i<=numberOfObjects;i++)
     {
     objects[i].draw();
     }
     glTranslatef((-1*offsetX),(-1*offsetY),(-1*offsetZ));
}

void objectManager::drawBounding()
{
for(int i=0; i<=5; i++)
{
boundingCube.shapes[i].drawNoTexture();
}
}

I've successfully compiled my program both on Mac and on Windows (on Windows as a .dll file and on Mac as a .app), all I need to do now is to add in the code to make it a .bundle file; unfortunately, I have no idea how to do this. Half an hour of googling such terms as 'bundle programming','mac bundles', etc. have been rather fruitless, as has the Mac Developer's articles on bundles.
Thanks Smile
-wyrmmage

Worlds at War (Current Project) - http://www.awkward-games.com/forum/
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #2
The Mac equivalent of a dll would be a .dylib, or the wrappered version .framework. To make that, you're going to have to make a new target of the type you want, assuming you are using XCode. If not, you're going to have to pass -dynamiclib into gcc. If you want a framework, you'll have to create the directory and symbolic link structure yourself.
Quote this message in a reply
Moderator
Posts: 373
Joined: 2006.08
Post: #3
perfect Smile With not too much pain I was able to compile it as a Cocoa framework ^_^
When I ship my game, will I need to include this graphics framework, or will merely linking against it be enough?
Thanks again Smile
-wyrmmage

Worlds at War (Current Project) - http://www.awkward-games.com/forum/
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #4
.dylib and .frameworks are for linking to; .bundles are for loading dynamically at run-time.
Quote this message in a reply
Moderator
Posts: 373
Joined: 2006.08
Post: #5
ok. I guess .framework's were what I wanted then Smile

Worlds at War (Current Project) - http://www.awkward-games.com/forum/
Quote this message in a reply
Member
Posts: 567
Joined: 2004.07
Post: #6
yes, you'll need to include them in App.app/Contents/Frameworks, so install is Drag-and-drop.

It's not magic, it's Ruby.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Automatic creation of app bundle in dmg installer peterp 7 5,197 Feb 24, 2010 01:22 PM
Last Post: cmiller
  Tutorial: Make an Mac OSX App Bundle for your Java Application AndyKorth 0 3,613 Dec 21, 2008 09:30 PM
Last Post: AndyKorth
  Framework and bundle problem pointer 2 2,736 Dec 8, 2006 04:29 AM
Last Post: MacFiend
  Application Bundle Identifiers for Browsers dancedrummer 2 3,817 Jul 22, 2005 02:08 PM
Last Post: dancedrummer
  CPlusTest Problem With Framework in App Bundle kingofsquirrels 2 3,510 Jul 19, 2005 03:55 AM
Last Post: kingofsquirrels