Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 25 Apr 2012
Offline Last Active May 21 2012 07:42 AM

Topics I've Started

Visual Studio C++ Release Build Issue

06 May 2012 - 04:26 PM

I'm working on an OpenGL game, but I'm guessing this is mostly a C++ issue. It loads in models in a class from files, storing the values of both the model and the corresponding material for each object in vectors and arrays. When I run the debug version, it runs and displays what I expect to display if I write the code correctly, however when I build a release version, the values of some of the material files get read funny because it displays the wrong colours and shading values.

This is the issue below:

Posted Image

I'm running the professional/ultimate/paid-for version of Visual Studio 2010, I've repeatedly cleaned the solution, project and the release builds, I've also modified the files where the issue is notable and it has no effect.

Why does this happen and what can I do to fix it?

GLUT to freeglut

04 May 2012 - 06:26 AM

So I'm currently working on a project in GLUT using Visual Studio 2010 C++. I want to make it run on freeglut because
1. From what I've read it's similar to GLUT
2. It's better because it's more updated to include features such as control of the main loop and closing windows.

So I download the package from TransmissionZero and add the correct header and dll files and changed my class definitions to include freeglut.h, assuming that freeglut will still process glut functions and variables.

Obviously I was assuming wrong because as soon as I made the switch, I get 500+ warnings and 10+ errors on my program when I try to build it. Every warning refers to a macro redefinition of GLUT specific variables (most of which aren't used in my program) and each error consist of
"'<glut function name>_ATEXIT_HACK' : redefinition, different linkage".

Switching the freeglut.h include back to glut.h loses all the errors and the program works normally.

So I'm aware that transferring from GLUT to freeglut isn't easy, but I can't find many tutorials specifically for freeglut and those I do find are similar to standard GLUT.

Is there anything I should check or do? I've tried both methods of including freeglut (both adding the file locations as additional include and link directories and by adding the files in the project's folder) and I get the same result.

OpenGL GLUT, C++ with classes and Textures that don't appear

25 April 2012 - 05:20 AM

For anyone who knows how to use C++, OpenGL and GLUT if possible.

I'm having problems trying to load textures in an OpenGL GLUT project using classes. Here's some code that includes the texturing stuff:
Declaring a Textured Model from a subclass of a model class.

TextureModel * title = new TextureModel("Box.obj", "title.raw");

Constructor method of TextureModel subclass:

TextureModel(string fName, string tName) : Model(fName), textureFile(tName)
material newMat = {{0.63,0.52,0.1,1.0},{0.63,0.52,0.1,1.0},{0.2,0.2,0.05,0.5},10};
Material = newMat;
// enable texturing

glGenTextures(1, &textureRef);
// specify the filtering method
// associate the image read in to the texture to be applied
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, 256, 256, GL_RGB, GL_UNSIGNED_BYTE, image_array);

Texture loading function to read in data in RAW file:
int loadcolTexture(const string fileName) {
ifstream inFile;
inFile.open(fileName.c_str(), ios::binary );

if (!inFile.good())
cerr << "Can't open texture file " << fileName << endl;
return 1;
inFile.seekg (0, ios::end);
int size = inFile.tellg();
image_array = new char [size];
inFile.seekg (0, ios::beg);
inFile.read (image_array, size);
return 0;}

Method to draw the triangles:

virtual void drawTriangle(int f1, int f2, int f3, int t1, int t2, int t3, int n1, int n2, int n3)
glBindTexture(GL_TEXTURE_2D, textureRef);
glTexCoord2f(textures[t1].u, textures[t1].v);

glTexCoord2f(textures[t2].u, textures[t2].v);

glTexCoord2f(textures[t3].u, textures[t3].v);

I also have Lighting, Depth Testing and Double Buffering enabled.
Models and Lighting work fine, but the textures don't appear. Any reasons why it won't work will be great.