I'm working on building a basketball game in openGL, however i'm taking baby steps and dividing my work into sections. I'm currently focusing on texturing, attempting to build a house using the SOIL library.
I'm extremely new to all of this so i've probably set things up wrong but my main problem is that textures are acting as if they are clamped to edge from what i can see.
Currently the project is a singular wall meant to be textured by bricks, here's an image of the output i'm getting:
Texture Fail
Here is the source code:
#include <stdlib.h>
#include <GL/glut.h>
#include <SOIL.h>
#include <stdio.h>
float _angle = 0.0;
GLuint _textureBrick;
static void resize(int width, int height)
{
const float ar = (float) width / (float) height;
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-ar, ar, -1.0, 1.0, 1.0, 100.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void renderScene(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_TEXTURE_2D);
// Front side brick wall
glPushMatrix();
glBindTexture(GL_TEXTURE_2D, _textureBrick);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTranslatef(0,0,-6);
glRotatef(_angle, 0.0, 1.0, 0.0);
glBegin(GL_QUADS); // Wall
glTexCoord3f(-50.0,2.0,0.1); glVertex3f(-50,0,1);
glTexCoord3f(50.0,2.0,0.1); glVertex3f(50,0,1);
glTexCoord3f(50.0,0.0,0.1); glVertex3f(50,-1.5,1);
glTexCoord3f(-50.0,0.0,0.1); glVertex3f(-50,-1.5,1);
glEnd();
glPopMatrix();
glutSwapBuffers();
}
void mySpecialFunc(int key, int x, int y){
switch (key) {
case GLUT_KEY_RIGHT:
_angle += 1;
if (_angle > 360) _angle = 0.0;
break;
case GLUT_KEY_LEFT:
_angle -= 1;
if (_angle > 360) _angle = 0.0;
break;
}
glutPostRedisplay();
}
GLuint loadTex(const char* texname)
{
GLuint texture = SOIL_load_OGL_texture
(
texname,
SOIL_LOAD_AUTO,
SOIL_CREATE_NEW_ID,
SOIL_FLAG_INVERT_Y
);
if( 0 == texture )
{
printf( "SOIL loading error: '%s'\n", SOIL_last_result() );
}
//glBindTexture(GL_TEXTURE_2D, texture);
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
return texture;
}
void Initialize() {
glClearColor(0.0, 0.0, 0.0, 1.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-100.0, 100.0, -100.0, 100.0, -100.0, 100.0);
//_textureFloor = loadTex("C:\\Users\\Mikle\\OneDrive\\Uni work\\Second Year\\Projects\\3D-House-using-OpenGL-and-C--master\\court.png");
_textureBrick = loadTex("C:\\Users\\Mikle\\OneDrive\\Uni work\\Second Year\\Projects\\3D-House-using-OpenGL-and-C--master\\bricks.bmp");
}
int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
glutInitWindowPosition(0,0);
glutInitWindowSize(600,600);
glutCreateWindow("Textured House");
glEnable(GL_DEPTH_TEST);
glutReshapeFunc(resize);
glutSpecialFunc(mySpecialFunc);
glutDisplayFunc(renderScene);
Initialize();
glutMainLoop();
return 0;
}
Any help would be appreciated, thankyou!
Michael. In order to generate mipmaps and possibly fix the texture, you should change the parameters of the soil loading function to
GLuint texture = SOIL_load_OGL_texture
(
texname,
SOIL_LOAD_AUTO,
SOIL_CREATE_NEW_ID,
SOIL_FLAG_MIPMAPS | SOIL_FLAG_INVERT_Y | SOIL_FLAG_NTSC_SAFE_RGB | SOIL_FLAG_COMPRESS_TO_DXT
);
This will automatically generate mipmaps from the OpenGL library, as you did not call afterwards to glGenerateMipmaps(). It also saves on the memory needed to store the textures. Another suggestion for the texture clamping and wrapping is to use
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
after you use the load function. Good luck with your OpenGL learning experience. I hope this helped you in some way.
EDIT:
You also shouldn't repeat the glTexParameteri every single frame. This puts excess and unnecessary strain on your (or the user's) CPU.
Related
Hey guys I'm new in OpenGL, and I have an issue while I try to display a texture.Every texture I try to display in .png format it just gives it's color, for example if I try to display a red brick it just appears the red, only the color. The code I use is below.Where should I bind the texture or what's wrong with code? I can't aunderstand.
GLuint LoadTexture(const char * filename, int width, int height){
GLuint texture_id;
unsigned char *data;
texture_id = SOIL_load_OGL_texture(filename,
4, 0, SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_INVERT_Y);
if (texture_id == 0)
{
printf( "SOIL loading error: '%s'\n", SOIL_last_result() );
}
glBindTexture(GL_TEXTURE_2D, texture_id);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_DECAL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_DECAL);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
}
void display()
{
glClearColor(0, 0, 0, 1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_TEXTURE_2D);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
int w = glutGet(GLUT_WINDOW_WIDTH);
int h = glutGet(GLUT_WINDOW_HEIGHT);
gluPerspective(60, w / h, 0.1, 100);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(3, 3, 3,
0, 0, 0,
0, 0, 1);
glRotatef(rotate_x, 1.0, 0.0, 0.0);
glRotatef(rotate_y, 0.0, 1.0, 0.0);
glBindTexture(GL_TEXTURE_2D, texture);
glEnable(GL_TEXTURE_2D);
mycube();
glutSwapBuffers();
}
int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE);
glutInitWindowSize(640, 480);
glutCreateWindow("CUBE");
texture = LoadTexture("texture.png", 256, 256);
glutDisplayFunc(display);
glutSpecialFunc(specialKeys);
glEnable(GLUT_DEPTH);
glutMainLoop();
FreeTexture(texture);
return 0;
}
I do not see the source of your LoadTexture() function. One thing that can be done is to create a structure that holds the id value that OpenGL sets to a texture when it is bound to a renderable object, its width & height in pixels, color bit depth information, and the color data, if it contains transparencies, should be wrapped or repeated, and the mipmap quality being used. I do not know what you are using to open, read and parse a png file, but within my own projects I happen to use libpng.
#include <Windows.h>
#include "glut.h"
#include "GLAUX.H"
#include <stdio.h>
GLuint texID;
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(0,0,0,0);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
gluLookAt(10,10,10,0,0,0,0,0,1);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,texID);
glColor3f(0.9f,0.9f,0.9f);
glBegin(GL_QUADS);
glTexCoord2f(0.f,0.f);
glVertex3f(-100.0f, 0.0f, -100.0f);
glTexCoord2f(0.f,1.f);
glVertex3f(-100.0f,0.0f,100.0f);
glTexCoord2f(1.f,1.f);
glVertex3f(100.0f,0.0f,100.0f);
glTexCoord2f(1.f,0.f);
glVertex3f(100.0f, 0.0f, -100.0f);
glEnd();
glutSwapBuffers();
}
void InitTexture()
{
glGenTextures(1,&texID);
AUX_RGBImageRec * image = auxDIBImageLoad("earth.bmp");
if(!image)
puts("image open err\n");
glBindTexture(GL_TEXTURE_2D, texID);
// glTexImage2D(GL_TEXTURE_2D, 0, 3, image->sizeX,image->sizeY,0,GL_RGB,GL_UNSIGNED_BYTE,
// image->data);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, image->sizeX, image->sizeY, GL_RGB, GL_UNSIGNED_BYTE,image->data);
delete image->data;
delete image;
image = NULL;
}
void reshape (int w, int h) {
float ratio = w/(float)h;
glViewport(0,0,w,h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45,ratio,10,1000);
}
int main(int argc, char** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA|GLUT_DEPTH);
glutInitWindowSize(500,500);
glutCreateWindow("3D FORTRESS");
InitTexture();
glClear(GL_COLOR_BUFFER_BIT);
glutDisplayFunc(display);
glutIdleFunc (display);
glutReshapeFunc (reshape);
glutMainLoop();
return 0;
}
i'm trying to make a simple texture mapping..
but it doesn't work at all. it just displays black screen. though It reads bmp files well...
Several things wrong with this code:
glClearColor after glClear does not have any effect (until the next time through the display function).
You are switching to the texture matrix with glMatrixMode(GL_TEXTURE); but then load a view matrix into it. If you're just getting started with OpenGL, the texture matrix is not something you should be using; this should probably be GL_MODELVIEW.
The first argument to gluBuild2DMipmaps must be GLU_TEXTURE_2D.
You're not checking the return value of gluBuild2DMipmaps.
You're not checking for any OpenGL errors. Use glGetError() to pinpoint the source of any problems.
In general, with problems like this, narrow it down by commenting out features first. Here, I'd start with drawing a coloured quad without any texture, then add the texture to it.
I cant seem to load an image and use it as a texture to my program: the image is 512*512 in size and i dont know what im doing wrong, can someone help me?
Main function:
int main(int argc, char** argv)
{
glutInit (&argc, argv);
glutInitWindowSize (800,600);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutCreateWindow ("CS248 GLUT example");
glutDisplayFunc (display);
glutReshapeFunc (reshape);
glutMainLoop ();
return 0;
}
The display function:
void display() {
glClear(GL_COLOR_BUFFER_BIT);
glEnable(GL_TEXTURE_2D);
glColor3f(1.0f,1.0f,1.0f);
texture = LoadTexture("space.bmp");
glBindTexture(GL_TEXTURE_2D, texture);
glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0); glVertex3f(-20.0,-20.0,0);
glTexCoord2f(0.0, 1.0); glVertex3f(-20.0, 20.0, 0.0);
glTexCoord2f(1.0, 1.0); glVertex3f(20.0, 20.0, 0.0);
glTexCoord2f(1.0, 0.0); glVertex3f(20.0, -20.0, 0.0);
glEnd();
glFlush();
}
So, i call here the loadtexture function to an GLuint texture, this way:
GLuint LoadTexture( const char* texture )
{
GLuint textureID = SOIL_load_OGL_texture( texture, SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_MIPMAPS );
glGenTextures(1,&textureID);
glBindTexture( GL_TEXTURE_2D, textureID );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
return textureID;
}
Reshape function:
void reshape(GLsizei w, GLsizei h) {
glViewport(0, 0, 800, 600);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-20.0f, 20.0f, -20.0f, 20.0f, -20.0f, 20.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
Includes,etc:
#include <glut.h>
#include <SOIL.h>
GLuint texture;
GLuint textureID = SOIL_load_OGL_texture( texture, SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_MIPMAPS );
glGenTextures(1,&textureID);
SOIL_load_OGL_texture creates an OpenGL texture object. Generating a new one (which is what glGenTextures does) after already creating one is counter-productive.
Ditch that line, and you'll probably be OK.
However, you should not be reloading the texture on every display. You should be creating that texture once, during initialization, then just using the texture with a glBindTexture call.
Here is my problem;
Image a box, or a cube, all sides right.
If we were to put the box on a flat surface, the face touching the bottom, would be the floor or base. if the base had an inside, which most boxes do, from the outside you would not be able to see it right.
Unfortunately, in my code you can. instead of a box, you have a room, in which i go outside the room and see the floor, but i should not.
ill post an image of the problem and a video, as well as some code and any code that you might ask for.
http://www.youtube.com/watch?v=ml3-OBGNXXA&feature=youtu.be
http://www.flickr.com/photos/pkerkm/8607171993/
http://www.flickr.com/photos/pkerkm/8608276014/
//here is how i manage the textures
void /*GraphicsEngine::*/drawWall(double a[3],double b[3], double c[3], double d[3], bool floor){
if(floor){
glBindTexture(GL_TEXTURE_2D, texture[1]);
}else{
glBindTexture(GL_TEXTURE_2D, texture[0]);
}
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
//gluBuild2DMipmaps(GL_TEXTURE_2D, 4, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data); // build our texture mipmaps
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_DECAL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_DECAL);
//glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glEnable(GL_TEXTURE_2D);
glBegin(GL_QUADS);
glTexCoord2d(0.0,0.0);
glVertex3dv(a);
glTexCoord2d(-1.0,0.0);
glVertex3dv(d);
glTexCoord2d(-1.0,-1.0);
glVertex3dv(c);
glTexCoord2d(0.0,-1.0);
glVertex3dv(b);
glEnd();
}
//here is the reshape function
void reshape(int w, int h){
//glViewport(0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode(GL_PROJECTION);
//glLoadIdentity();
gluPerspective(60.0, (GLfloat) w/(GLfloat) h, 1.0, 200.0);
glMatrixMode(GL_MODELVIEW);
//glTranslatef(0.0, 0.0, -3.6);
//glLoadIdentity();
}
//here is the display function
void /*GraphicsEngine::*/display(){
//glClearColor (0.0, 0.0, 0.0, 1.0);
//glLoadIdentity ();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//glShadeModel(GL_FLAT);
//glClearDepth(1.0);
//glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
setPos();
gluLookAt(currentXPos,currentYPos,currentZPos,currentXFace,currentYFace,currentZFace,0,1,0);
generateMap();
graphicsFloor();
int i = 0;
if(projectiles.size()>0){
for(i= 0; i< projectiles.size(); i++){
arrow(projectiles.operator[](i).getXPos(),projectiles.operator[](i).getYPos(),projectiles.operator[](i).getZPos(),0.5,BLOCKWIDTH);
}
projectileMotion();
player.advance();
//glutPostRedisplay();
/*}else if(player.advance()){
glutPostRedisplay();
}*/
}
//glFlush();
glutSwapBuffers();
}
//here is what tells where to draw the floor and the walls
void graphicsFloor(){
int x,z;
//up
for(x=0;x<7;x+=7){
for(z=0;z<105;z+=7){
double a[3] = {x,0,z};
double b[3] = {x+7,0,z};
double c[3] = {x+7,0,z+7};
double d[3] = {x,0,z+7};
drawWall(d,a,b,c,true);
}
}
}
// the walls
void generateMap(){
int z;
int x;
for(z =0;z<105;z+=7){
double a[3] = {0,0,z};
double b[3] = {0,0,z+7};
double c[3] = {0,MAPHEIGHT,z+7};
double d[3] = {0,MAPHEIGHT,z};
drawWall(d,a,b,c,false);
}
for(z =0;z<42;z+=7){
double a[3] = {7,0,z};
double b[3] = {7,0,z+7};
double c[3] = {7,MAPHEIGHT,z+7};
double d[3] = {7,MAPHEIGHT,z};
drawWall(d,a,b,c,false);
}
}
//and here is how i load up the textures
void genTex(){
texture[0]=SOIL_load_OGL_texture // load an image file directly as a new OpenGL texture
(
//"C:\\Users\\Eddy\\Desktop\\Senior Project\\Senior Project\\bloodwall2.png",
"C:\\Users\\Pkerkm\\Documents\\Visual Studio 2010\\Projects\\files\\gameprojecgraphics\\bloodwall2.png",
SOIL_LOAD_AUTO,
SOIL_CREATE_NEW_ID,
SOIL_FLAG_MIPMAPS | SOIL_FLAG_INVERT_Y | SOIL_FLAG_NTSC_SAFE_RGB | SOIL_FLAG_COMPRESS_TO_DXT
//SOIL_FLAG_POWER_OF_TWO| SOIL_FLAG_MIPMAPS| SOIL_FLAG_MULTIPLY_ALPHA| SOIL_FLAG_COMPRESS_TO_DXT| SOIL_FLAG_DDS_LOAD_DIRECT| SOIL_FLAG_INVERT_Y
);
glBindTexture(GL_TEXTURE_2D, texture[0]);
}
It looks like depth testing is disabled. Enable it:
glEnable(GL_DEPTH_TEST);
If that doesn't work, make sure you have a depth buffer and try again.
This problem baffles me. I am testing some Haskell bindings to OpenGL, I create a vertex shader, a fragment shader, compile the program, and draw a textured rectangle to the screen after transforming the vertices... except the screen is blank.
When I render the rectangle flat white instead of using a sampler in the fragment shader, it works fine. When I go into gdebugger and use the option to replace all textures with a stub texture, it also works fine.
When I look at the allocated textures in gdebugger, there are no texture objects, only the default 2d texture. When I set a breakpoint on glTexImage2d, I see that it is being called, but no texture object appears in memory when I peek at it with gdebugger.
What's going on? Am I forgetting to set some environment variables? I'm quite frustrated. The kicker is that I had this problem before, and I managed to fix it then, but I forgot what the problem was. I hate myself >_>
I ported a tutorial on OpenGL to Haskell some time ago. It includes a link to a very tiny library that, among other things, helps with loading textures.
Perhaps you could compare that code with what you have to spot the differences.
I'm not a Haskell guy by any means, but try doing the simplest thing that could possibly work and check to see where you deviate from it:
#include <GL/glut.h>
double aspect_ratio = 0;
GLuint texID = 0;
unsigned int texBuf[] = {
0x00FFFFFF,
0x00FF0000,
0x0000FF00,
0x000000FF,
};
void display(void)
{
glEnable(GL_DEPTH_TEST);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-10*aspect_ratio, 10*aspect_ratio, -10, 10, -10, 10);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glColor3ub(255,255,255);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texID);
glScalef(8,8,8);
glTranslatef(-0.5f, -0.5f, 0.0f);
glBegin(GL_QUADS);
glTexCoord2f(0,0);
glVertex2f(0,0);
glTexCoord2f(1,0);
glVertex2f(1,0);
glTexCoord2f(1,1);
glVertex2f(1,1);
glTexCoord2f(0,1);
glVertex2f(0,1);
glEnd();
glFlush();
glFinish();
glutSwapBuffers();
}
void reshape(int w, int h)
{
aspect_ratio = (double)w / (double)h;
glViewport(0, 0, w, h);
}
void idle()
{
glutPostRedisplay();
}
int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE);
glutInitWindowSize(200,200);
glutCreateWindow("Aspect Ratio");
glGenTextures(1, &texID);
glBindTexture(GL_TEXTURE_2D, texID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, 4, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, (char*)texBuf);
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutIdleFunc(idle);
glutMainLoop();
return 0;
}