Public Group

# Can't get images to dispay in OpenGL

This topic is 3481 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hey, I am just going through my first year of a Computer Games technology course at my university, where I've started to learn to program in C++. For this semester we are learning 2D graphics, which involves OpenGL. In class we use Microsoft Visual Studio, however I have a mac at home. So for this purpose I installed Parallels and one way or another I now have Windows XP on my machine, so I can now do a lot of work at home. I installed Visual Studio, and tried a few test example programs, and they worked fine. I then installed openGL and tried a few simple shape examples and they all worked fine. However, for a project of mine I have to create a very basic cannon game, that involves using bitmaps, but when I tried a very simple example of a program that utilizes bitmaps, I get an error. Although the weird thing (for me, at least) is that the error comes after the program compiles. Error Message It seems quite a simple error, but I have no idea why it does it. I have my .bmp file in with the .cpp file, so it should be alright. Plus it's an example I downloaded from the university, so all the files should definitely be in the right place. Here's my code (it's very simple just for the purpose of trying to get this to work):
#include"cBitmapImage.h"
#include<gl/glut.h>

int background;

void init()
{
}

void display()
{
glutPostRedisplay();
}

void main()
{
glutInitDisplayMode(GLUT_RGBA | GLUT_SINGLE);
glutInitWindowSize(512, 512);
glutInitWindowPosition(100, 100);
glutCreateWindow("Cannon Game");
gluOrtho2D(0, 512, 0, 512);
init();
glutDisplayFunc(display);
glutMainLoop();
}


As you can see I use more files (supplied by the university, used for opening and reading bitmaps), but I'm hoping the problem is an easy one to fix, and that I don't have to show you those files. But if necessary, please just say and I'll post those files. EDIT - I should note that in the error message, the first part of it I know about, and doesn't necessarily affect the OpenGL graphics display. I don't know how to get rid of it, but it doesn't matter so much at the moment because it won't be there when I compile it in the university.

##### Share on other sites
Is this when you run the program from within the IDE? Check the project's debugging properties, in particular the working directory.

##### Share on other sites
Sorry, I forgot to mention that I'm a complete newbie at this stuff, and so have no idea what you're talking about. I run it using Microsoft Visual Studio 2008 Express Edition. Don't know if that helps, could you maybe explain it in a bit more detail please?

##### Share on other sites
Sorry to double post but, any help for this?

##### Share on other sites
It would appear that you're trying to run the program from a DOS prompt, which is all good and fun except Windows doesn't like you accessing networks like that (anything that starts with '\\' in the path is effectively a part of a network, even if it's on your own computer). I learnt that the hard way.

The only thing I can suggest is copying all of the files to a folder on the desktop and running it from there.

##### Share on other sites
It seems where ever I put those files, the path always starts with the same '\\'.

Any idea how I could fix that?

##### Share on other sites
glEnable(GL_TEXTURE_2D);

Does that happen in cBitmapImage.h? If not make sure you put that in the init.

##### Share on other sites
If your using visual c++ and your a nooby, one mistake i made when i was trying to learn how to compile Visual c++ is i hit the build command and then compile, That is not how you see the results. You have to Build the project and then "Start without debugging" to see the openGL shapes and stuff that you made.

##### Share on other sites
Quote:
 Original post by GoraxWindows doesn't like you accessing networks like that (anything that starts with '\\' in the path is effectively a part of a network, even if it's on your own computer). I learnt that the hard way.

What, when Command Prompt told you:
"CMD does not support UNC paths as current directories." [smile].

@hamishmcgee: You can just specify the drive name like: "C:\blah..." or if you are working on a network drive you will have to map it to a drive letter to be able to access it via the command prompt.

##### Share on other sites
As much as I wish otherwise, everything that everyone has suggested to me has not worked. I tried putting in the files full address, but I just get the same "Error loading bitmap file C:\Programming\cannon\cannon\bg.bmp

This is so annoying! I have absolutely no idea what to do.

EDIT - I managed to finish my uni project using the computers in the university, so that's ok, but I'd still like to get it working on my mac. It can't be anything wrong with the code, as it all works fine on the university computers, so it must be just because I'm running it off of XP on mac via Parallels.

Do you think I should maybe ask this question over at the Parallels forum?

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 9
• 9
• 9
• 14
• 12
• ### Forum Statistics

• Total Topics
633290
• Total Posts
3011232
• ### Who's Online (See full list)

There are no registered users currently online

×