Win 7 + opengl
Hey,
I'm new to this forum, but have been visiting the site quite long ago, learnt most of my opengl knowledge here.
I have replaced my winXP with WIN 7 RC 1 (build 7100) some months ago, and I was unable to run most of my opengl programs. (made in DEV C++) They worked perfectly while I was using XP.
I figured out that if I turn off the textures in my program (the texture loading script is the very same that is implemented here, on NeHe, except that I also added possibility to load multiple textures) then my programs run just fine. (except that there are no textures of course)
This is a unique problem here, maybe only concerning the RC1 version, or you know about it and also the solution? I tried running the .exe-s in administrator mode, winXP compatibility mode, not working.
Any idea?
Thanks in advance.
(PS. Okay, sorry I wrote here, just realized this wasn't the right section, but somehow I was redirected here automatically, and haven't realized.)
Move or copy your post to the right section right now, or almost nobody will read yours.
good luck.
good luck.
I've seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion. I watched C-beams glitter in the dark near the Tannhauser gate. All those moments will be lost in time, like tears in rain. Time to die.
Have you tried to use your debugger to step thru the code to see what happens when you try to load the textures? There may be some assumptions about file handling that, while worked in XP, break in 7. In particular, I would check for hard-coded paths.
OpenGL itself (at least as implemented by AMD and NVidia) works just fine on 7. I use Blender weekly on 7 and it displays textures just like in XP and Vista.
OpenGL itself (at least as implemented by AMD and NVidia) works just fine on 7. I use Blender weekly on 7 and it displays textures just like in XP and Vista.
Niko Suni
Tried to debug, got an error.
"An acces violation (segmentation fault) raised in your program."
No idea what that means.
"An acces violation (segmentation fault) raised in your program."
No idea what that means.
I've had a similar problem with OpenGL applications not starting in windows 7. It turned out I needed new drivers. I have a rather old ATI graphics card and I had to look for older versions of the driver (9.3).
Quote: Original post by terraform
Tried to debug, got an error.
"An acces violation (segmentation fault) raised in your program."
No idea what that means.
On what line of code does this error happens? Please post relevant source code for this line (variable declarations/usage/passing to functions).
Quote: Original post by terraform
Tried to debug, got an error.
"An acces violation (segmentation fault) raised in your program."
No idea what that means.
It probably means that your program tried to access an invalid pointer. One that might have been pointing at memory that your program didn't own and so wasn't allowed to access, hence the "Access violation" part.
Have you done much debugging before? because if you were running that through a decent debugger you'd have got a callstack, address and probably variable state that you could have looked at.
Actually I just re-read and see that you're using Dev-C++... seriously you're running Windows7 but still using a compiler/IDE that hasn't been updated in 6 years? Download MSVisualC++ Express Edition. It's a good compiler and a great debugger. You'll be able to install it, setup a project using your code, get it compiling AND find the problem faster than you would with Dev-C++.
Andy
"Ars longa, vita brevis, occasio praeceps, experimentum periculosum, iudicium difficile"
"Life is short, [the] craft long, opportunity fleeting, experiment treacherous, judgement difficult."
For the previous comment: I have Radeon HD4850 and the latest Catalyst driver, so that shouldn't be a problem.
Okay, so I haven't really done debugging before, I didn't really need it I just corrected any error that have came up while programming. I have learnt C++ programming in university last year, and debugging never came up as a topic. My prof insisted on using DEV C++. Although, I already installed MS visual C++ some time ago and tried to compile my programs there, but if I remember correctly there was some problems with linking, I'll check out again.
I'll post the header file which handles textures.
Btw, downloaded dev C++ and visual C++ codes for lesson 06 (textures implementation), and while DEV failed to run it, MS visual succeeded, so I guess the problem is in dev. I'll try to "update" myself to MS visual, thanks for your replies.
// textures.h
Okay, so I haven't really done debugging before, I didn't really need it I just corrected any error that have came up while programming. I have learnt C++ programming in university last year, and debugging never came up as a topic. My prof insisted on using DEV C++. Although, I already installed MS visual C++ some time ago and tried to compile my programs there, but if I remember correctly there was some problems with linking, I'll check out again.
I'll post the header file which handles textures.
Btw, downloaded dev C++ and visual C++ codes for lesson 06 (textures implementation), and while DEV failed to run it, MS visual succeeded, so I guess the problem is in dev. I'll try to "update" myself to MS visual, thanks for your replies.
// textures.h
#define GLUT_DISABLE_ATEXIT_HACK#ifndef texture#define texture#include <GL/glaux.h>#include <stdio.h>#include <stdlib.h>const int GL_textures_nr = 18;int GL_used_texture;char *texture_name[GL_textures_nr];GLuint GL_texture[GL_textures_nr];AUX_RGBImageRec *LoadBMP(char *Filename) { FILE *File=NULL; if (!Filename) { return NULL; } File=fopen(Filename,"r"); if (File) { fclose(File); return auxDIBImageLoad(Filename); } return NULL; }int LoadGLTextures(char *texture_name, int texture_nr) { int Status=FALSE; AUX_RGBImageRec *TextureImage[texture_nr+1]; memset(TextureImage,0,sizeof(void *)*1); if (TextureImage[texture_nr]=LoadBMP(texture_name)) { Status=TRUE; glGenTextures(1, &GL_texture[texture_nr]); glBindTexture (GL_TEXTURE_2D, GL_texture[texture_nr]); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TextureImage[texture_nr]->sizeX, TextureImage[texture_nr]->sizeY, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[texture_nr]->data); } if (TextureImage[texture_nr]) { if (TextureImage[texture_nr]->data) { free(TextureImage[texture_nr]->data); } free(TextureImage[texture_nr]); } return Status; }#endif
Oh also glaux is deprecated. So for loading bmp's etc you're probably better off using a replacement library like glbmp:
http://freshmeat.net/projects/glbmp/
or lc_overlord posted his own replacement in this thread:
http://www.gamedev.net/community/forums/topic.asp?topic_id=275238
Now onto the code.
The first thing is that you don't need an array because you're only loading a single bmp. The second thing is that the way you declared your array was invalid for C++ and it threw a compiler error in VS2008.
The second is your memset wouldn't have set everything to zero. Only the first entry.
Third, you're using "free" without a corresponding "malloc", and even then you're only using it for a single element rather than the array that you'd expect.
Regardless of that you should probably be using "new" and "delete". They're the C++ memory operators except for where the glaux function has allocated memory using "free" internally. That won't be a problem if you replace the glaux bmp loader with one of those I've suggested at the top.
Below is your modified code for "texture.h". I've added comments (prefixed with "NYC :") but I'll leave you to fix up any issues with the calls to "free" at the end ;)
I've never understood why some professor/lecturers still insist on using Dev-C++, it's completely dead and it had lots of issues even when it wasn't. Ah well. Make the switch, you won't regret it.
Debugging is an ESSENTIAL ability, spend some serious time getting to do it, stepping in and out of functions, using breakpoints, understanding and walking the callstack... all of it, they're a life saver and you'd have found this issue very quickly if you'd known.
Good luck.
Andy
http://freshmeat.net/projects/glbmp/
or lc_overlord posted his own replacement in this thread:
http://www.gamedev.net/community/forums/topic.asp?topic_id=275238
Now onto the code.
The first thing is that you don't need an array because you're only loading a single bmp. The second thing is that the way you declared your array was invalid for C++ and it threw a compiler error in VS2008.
The second is your memset wouldn't have set everything to zero. Only the first entry.
Third, you're using "free" without a corresponding "malloc", and even then you're only using it for a single element rather than the array that you'd expect.
Regardless of that you should probably be using "new" and "delete". They're the C++ memory operators except for where the glaux function has allocated memory using "free" internally. That won't be a problem if you replace the glaux bmp loader with one of those I've suggested at the top.
Below is your modified code for "texture.h". I've added comments (prefixed with "NYC :") but I'll leave you to fix up any issues with the calls to "free" at the end ;)
// textures.h#define GLUT_DISABLE_ATEXIT_HACK#ifndef texture#define texture#include <GL/glaux.h>#include <stdio.h>#include <stdlib.h>const int GL_textures_nr = 18;int GL_used_texture;char *texture_name[GL_textures_nr];GLuint GL_texture[GL_textures_nr];AUX_RGBImageRec *LoadBMP(char *Filename) { FILE *File=NULL; if (!Filename) { return NULL; } File=fopen(Filename,"r"); if (File) { fclose(File); return auxDIBImageLoad(Filename); } return NULL; }int LoadGLTextures(char *texture_name, int texture_nr) { int Status=FALSE; // NYC : this isn't a valid C/C++ way to declare an array //AUX_RGBImageRec *pTextureImage[texture_nr+1]; // NYC : for reference this is the correct C++ way //AUX_RGBImageRec *pTextureImage = new AUX_RGBImageRec[texture_nr+1]; // NYC : or in C //AUX_RGBImageRec *pTextureImage = (AUX_RGBImageRec*)malloc( sizeof(AUX_RGBImageRec*)*texture_nr+1 ); // NYC : however you actually only need this since you're ONLY LOADING ONE TEXTURE! :) AUX_RGBImageRec *pTextureImage = NULL; // and this won't clear all of it's entries - but you don't need it anyway //memset(pTextureImage,0,sizeof(void *)*1); // valid syntax for clearing an array would be //memset(pTextureImage,0,sizeof(AUX_RGBImageRec *)*texture_nr+1); if (pTextureImage=LoadBMP(texture_name)) { Status=TRUE; glGenTextures(1, &GL_texture[texture_nr]); glBindTexture (GL_TEXTURE_2D, GL_texture[texture_nr]); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); gluBuild2DMipmaps(GL_TEXTURE_2D, 3, pTextureImage->sizeX, pTextureImage->sizeY, GL_RGB, GL_UNSIGNED_BYTE, pTextureImage->data); } if (pTextureImage) { if (pTextureImage->data) { free(pTextureImage->data); } free(pTextureImage); } return Status; }#endif
I've never understood why some professor/lecturers still insist on using Dev-C++, it's completely dead and it had lots of issues even when it wasn't. Ah well. Make the switch, you won't regret it.
Debugging is an ESSENTIAL ability, spend some serious time getting to do it, stepping in and out of functions, using breakpoints, understanding and walking the callstack... all of it, they're a life saver and you'd have found this issue very quickly if you'd known.
Good luck.
Andy
"Ars longa, vita brevis, occasio praeceps, experimentum periculosum, iudicium difficile"
"Life is short, [the] craft long, opportunity fleeting, experiment treacherous, judgement difficult."
Thank you for taking time to explain this and correct my code. I've never really understood the texture loading code, I was just using it, but now that you mention these errors, I can also see. I guess DEV-C++ really is dead. I'm trying to make a switch to VC++, I think that will be better.
Thanks again,
Gabor
Thanks again,
Gabor
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement