Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6779079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:20:31+00:00 2026-05-26T16:20:31+00:00

I am trying to load a file with a cocoa app but the app

  • 0

I am trying to load a file with a cocoa app but the app cant find the file

I use SDL_image, the code is:

SDL_Surface* surface = IMG_Load(file);

the file is: “/Resources/cursor.png”

I have tried using some lines in Objective-C but the app won’t run since it’s written in c++

Thanks,
Daniel

Update:

Texture loading code:

GLuint CGLTexture::load_texture(const char* file, bool wrap)
{
SDL_Surface* surface = IMG_Load(file);

if (!surface) {
    printf("Error, probably the file isn't there :S");
    return 0;
}

GLuint texture;
glPixelStorei(GL_UNPACK_ALIGNMENT,4);
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
SDL_PixelFormat *format = surface->format;

// select modulate to mix texture with color for shading
glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );

// when texture area is small, bilinear filter the closest mipmap
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
                GL_LINEAR_MIPMAP_NEAREST );
// when texture area is large, bilinear filter the first mipmap
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );

// if wrap is true, the texture wraps over at the edges (repeat)
//       ... false, the texture ends at the edges (clamp)
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
                wrap ? GL_REPEAT : GL_CLAMP );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
                wrap ? GL_REPEAT : GL_CLAMP );

if (format->Amask)
{
    gluBuild2DMipmaps(GL_TEXTURE_2D, 4,
                      surface->w, surface->h, GL_RGBA,GL_UNSIGNED_BYTE, surface->pixels);
}
else
{
    gluBuild2DMipmaps(GL_TEXTURE_2D, 3,
                      surface->w, surface->h, GL_RGB, GL_UNSIGNED_BYTE, surface->pixels);
}
SDL_FreeSurface(surface);
return texture;
}

I call this function like this:

cursorTexture = CGLTexture::load_texture("/Resources/cursor.png",false);

The file is never found, I think this is somewhere in the app’s bundle, but, how can i access it with c++?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:20:32+00:00Added an answer on May 26, 2026 at 4:20 pm

    You can use objective-c++, then you have c++ and objective-c features.
    To use objetive c in a portable environment use this:

    header file:
    
    std::string GetTextureFilename(const char *Name);
    
    implementation file that ends with .mm and included only in mac:
    
    std::string GetTextureFilename(const char *Name)
    {
        return [[[NSBundle mainBundle]
                      pathForResource:
                          [NSString stringWithUTF8String: Name
                                                  ofType: nil] toUTF8String];
    }
    
    source file that ends with .cpp and included only on other platforms:
    
    std::string GetTextureFilename(const char *Name)
    {
        return Name;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to load a JS file using yepnope using the below code:
i am trying load file after it created from /stext command line but its
I'm trying to load File.ServerRelativeUrl when loading items from list, but no luck. Trying
I'm trying to load a file into a string. Here is the code I'm
Trying to load a file into python. It's a very big file (1.5Gb), but
I am trying to load .mm file on my main.m iPhone project but i'v
I'm trying to load a gzipped XML file using simplexml_load_file() PHP function, but I
I have imported a file x.ani into Resource file Resources.resx. Now trying to load
Okay, I'm trying to load a file in Java using this code: String file
I'm trying to use jQuery .load to load separate file with Google Chart into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.