sjhalayka

OpenGL ES Using Xcode results in file not found error

Recommended Posts

I'm using Xcode on Mac OS X, and I've added a file called 'peacock.tga' into my project. I can't seem to open that file (using fopen) however. Is there anything special that I need to do in order for the file to be readable?

Edited by sjhalayka

Share this post


Link to post
Share on other sites

You need to make sure you use the correct path to the file. If you're just creating a regular, console-type application, the .tga is probably not being copied to the output directory of the executable. If you're creating an OS X bundle, you probably want to ensure the .tga is packaged into the bundle and that you use a path to where the file ends up in the Resources subdirectory of the bundle.

Share this post


Link to post
Share on other sites

If you're porting and building a Mac OSX bundle app, you've have some file handling rework ahead of you. First, I recommend that you add your assets as references rather than directly in the project. This is because XCode will preserve folder structure for referenced folders, while flattening file hierarchies that are directly included in the project. Second, you will need to follow these instructions to get a real file path:

https://stackoverflow.com/questions/8768217/how-can-i-find-the-path-to-a-file-in-an-application-bundle-nsbundle-using-c

You'll be able to use fopen as normal after that. While we're on the topic, I'll point out that this approach will not work on Android, where you have to go through explicit platform-specific IO APIs to load content embedded in your app.

Share this post


Link to post
Share on other sites

Thank you for the replies.

I managed to get it working using this code:

	    
    NSString *fileRoot = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"peacock.tga"];
	    tga_32bit_image peacock_img;
    peacock_img.load([fileRoot UTF8String]);
	

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Forum Statistics

    • Total Topics
      627735
    • Total Posts
      2978854
  • Similar Content

    • By cebugdev
      hi all,

      i am trying to build an OpenGL 2D GUI system, (yeah yeah, i know i should not be re inventing the wheel, but this is for educational and some other purpose only),
      i have built GUI system before using 2D systems such as that of HTML/JS canvas, but in 2D system, i can directly match a mouse coordinates to the actual graphic coordinates with additional computation for screen size/ratio/scale ofcourse.
      now i want to port it to OpenGL, i know that to render a 2D object in OpenGL we specify coordiantes in Clip space or use the orthographic projection, now heres what i need help about.
      1. what is the right way of rendering the GUI? is it thru drawing in clip space or switching to ortho projection?
      2. from screen coordinates (top left is 0,0 nd bottom right is width height), how can i map the mouse coordinates to OpenGL 2D so that mouse events such as button click works? In consideration ofcourse to the current screen/size dimension.
      3. when let say if the screen size/dimension is different, how to handle this? in my previous javascript 2D engine using canvas, i just have my working coordinates and then just perform the bitblk or copying my working canvas to screen canvas and scale the mouse coordinates from there, in OpenGL how to work on a multiple screen sizes (more like an OpenGL ES question).
      lastly, if you guys know any books, resources, links or tutorials that handle or discuss this, i found one with marekknows opengl game engine website but its not free,
      Just let me know. Did not have any luck finding resource in google for writing our own OpenGL GUI framework.
      IF there are no any available online, just let me know, what things do i need to look into for OpenGL and i will study them one by one to make it work.
      thank you, and looking forward to positive replies.
    • By lawnjelly
      I've been making pretty good use of texture atlases in my current game, but as I find myself forced to use another texture (to enable generating tex coords for point sprites), I'm wondering if there may be a better way than currently batching by texture, and calling glBind before each batch.
      Instead is it more efficient to pre-bind a whole set of textures to all the available active texture slots, then simply only read from the ones I'm interested in in the fragment shaders (or call glUniform to change the active texture used by the frag shader). Is there any performance penalty to have a load of textures bound, but not being used?
      Is this a practical way to work on GLES 2.0, and are there any typical figures for how many active texture slots should be available on mobiles? I'm getting the impression the minimum is 8.
      This may make a difference as I'm having to do several render passes on some frames.
    • By DevBlazer
      Hi all, I am busy working on a small project where by I wont to use a webcam to track a users 'eye position' (vector from persons eye position relative to the center of the screen) and use this 'camera angle' to manipulate a threeJS scene (or maybe just straight webGL) such that it looks like the screen itself is a 'window' into a 3d environment.  Too accomplish this I believe all that is required (assuming you already have the 'eye camera angle') is to manipulate the view matrix.  For instance the image on the left would be a typical view frustum for a standard view matrix given a straight camera angle.  The image on the right would be the ideal matrix and resulting view frustum if the 'eye camera position' were moved upwards.

      Is this as simple as swapping out the standard view matrix used?
      What would said matrix look like.

      Please bare in mind when answering, that I know as much about linear algebra as a first grader.
      Also for further details, this project will be browser based using webGl and javascript.
    • By SneakyCrago
      Hello everyone!

      This is my first project for android.
      I was very interested of making games, and find LibGDX framework, and there I started. After 6-7 month I finished first mode for my game.

      So here we go ^^
       
      Undercore - hardcore runner for android.
      You have to use skills like jump and stay on line. And you goal is to make a highscore dodging obstacles.
      ○ Improve your skills - the way will be rough, will you become a master?
      ○ Contest - your friend hit 40 points? Double score and make him jealous!
      ○ Collect - buy new color themes that would make the gameplay brighter!
      ○ Achieve - beat records, die, earn. Collect achivements. No pain no gain.

      PlayMarket: https://play.google.com/store/apps/details?id=com.sneakycrago.undercore&hl=en
      Youtube - Gameplay



       
      I hope you enjoy it and also wait for feedback 

      I can't make clickable button.Sorry, just link: https://goo.gl/dG1dLj
    • By khawk
       
      This video gives an overview of differing features an OpenGL ES developer would encounter when starting to develop with the Vulkan API.
  • Popular Now