Can't get images to dispay in OpenGL

Started by
8 comments, last by hamishmcgee 14 years, 11 months ago
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>

cBitmapImage *imageLoader;
int background;

void init()
{
	imageLoader = new cBitmapImage;
	background = imageLoader->loadImageTrans("bg.bmp");
}

void display()
{
	imageLoader->drawImageQuad(background, 0, 0, 512, 512);
	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.
Advertisement
Is this when you run the program from within the IDE? Check the project's debugging properties, in particular the working directory.
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?
Sorry to double post but, any help for this?
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.
It seems where ever I put those files, the path always starts with the same '\\'.

Any idea how I could fix that?
glEnable(GL_TEXTURE_2D);

Does that happen in cBitmapImage.h? If not make sure you put that in the init.
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.
Quote:Original post by Gorax
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.

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.
[Window Detective] - Windows UI spy utility for programmers
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?

This topic is closed to new replies.

Advertisement