I have a piece of code but when i run it i get the error
1>Compiling...
1>background.cpp
1>texture.cpp
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdlib(26) : error C2039: 'exit' : is not a member of '`global namespace''
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdlib(26) : error C2873: 'exit' : symbol cannot be used in a using-declaration
1>Generating Code...
1>Build log was saved at "file://c:\Users\Nick\Desktop\University\Graphics, C++\background\background\Debug\BuildLog.htm"
1>background - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I am not sure why i am getting this but any help in sorting it out would be great. My code is
#include "stdafx.h"
#include <math.h>
#include "glut.h"
#include "texture.h"
#include <iostream>
#include <stdlib.h>
#define PI 3.1415926535
#define SIDES_NUM 100
using namespace std;
GLuint loadTexture(Image* image) {
GLuint textureId;
glGenTextures(1, &textureId); //Make room for our texture
glBindTexture(GL_TEXTURE_2D, textureId); //Tell OpenGL which texture to edit
//Map the image to the texture
glTexImage2D(GL_TEXTURE_2D, //Always GL_TEXTURE_2D
0, //0 for now
GL_RGB, //Format OpenGL uses for image
image->width, image->height, //Width and height
0, //The border of the image
GL_RGB, //GL_RGB, because pixels are stored in RGB format
GL_UNSIGNED_BYTE, //GL_UNSIGNED_BYTE, because pixels are stored
//as unsigned numbers
image->pixels); //The actual pixel data
return textureId; //Returns the id of the texture
}
GLuint _textureId;
void Initialize()
{
glEnable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f, 1.0f, 0.1f, 1000.0f);
glMatrixMode(GL_MODELVIEW);
glEnable(GL_CULL_FACE);
glEnable(GL_TEXTURE_2D);
Image* image = loadBMP("vtr.bmp");
_textureId = loadTexture(image);
delete image;
}
void Render()
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
gluLookAt(0, 0, 2, 0, 0, 0, 0, 1, 0);
glBindTexture(GL_TEXTURE_2D, _textureId);
glBegin(GL_QUADS);
glTexCoord2f(0,0); glVertex3f(-2,-2,-2);
glTexCoord2f(1,0); glVertex3f( 2,-2,-2);
glTexCoord2f(1,1); glVertex3f( 2, 2,-2);
glTexCoord2f(0,1); glVertex3f(-2, 2,-2);
glEnd();
glBindTexture(GL_TEXTURE_2D, _textureId);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glBegin(GL_TRIANGLE_STRIP);
for(int i=0;i<SIDES_NUM+1;i++){
float x = 0.5f*sinf(i*2*PI/SIDES_NUM);
float y = 0.5f*cosf(i*2*PI/SIDES_NUM);
float d = sqrtf(x*x+y*y);
glNormal3f(x/d,y/d,0);
glVertex3f(x,y,-0.5f);
glNormal3f(x/d,y/d,0);
glVertex3f(x,y, 0.5f);
}
glEnd();
glBegin(GL_TRIANGLE_FAN);
glNormal3f(0.0f,0.0f,-1.0f);
glTexCoord2f(0.5f, 0.5f);
glVertex3f(0.0f,0.0f,-0.5f);
for(int i=0;i<SIDES_NUM+1;i++){
float x = 0.5f*sinf(i*2*PI/SIDES_NUM);
float y = 0.5f*cosf(i*2*PI/SIDES_NUM);
float d = sqrtf(x*x+y*y);
glVertex3f(x,y,-0.5f);
}
glEnd();
glBegin(GL_TRIANGLE_FAN);
glNormal3f(0.0f,0.0f, 1.0f);
glTexCoord2f(0.5f, 0.5f);
glVertex3f(0.0f,0.0f, 0.5f);
for(int i=0;i<SIDES_NUM+1;i++){
float x = 0.5f*sinf(-i*2*PI/SIDES_NUM);
float y = 0.5f*cosf(-i*2*PI/SIDES_NUM);
float d = sqrtf(x*x+y*y);
glVertex3f(x,y, 0.5f);
}
glEnd();
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
}
int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(800,600);
glutInitWindowPosition(0,0);
glutCreateWindow("Coursework 2");
Render();
glutMainLoop();
return(0);
}
thanks for any help