Hello,
I am getting strange results when I get quad texture on screen, if I use code
below
void GL_Init(){
glClearColor(0.0,0.0,0.0,1.0);
glViewport(0,0,1200,550);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
//glOrtho(0, 1200, 550, 0.0f, 1.0f, 1.0f);
//glOrtho(0.0f, 1200.0f, 0.0f, 550.0f, 0.1f, 100.0f);
//glOrtho(1200, 550, 0, 1.0f, 1.0f, 0.0f);
//glOrtho(0,1200,550,0,-1.0f,0);
//gluOrtho2D(0,1200,0,550);
//gluPerspective(90,500.0/250.0,1.0,-50.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//glFrontFace(GL_CW);
}
void texture(){
if(glfwInit()==false){ printf("GLFW could not be inialized.");}//Initializing Open GL FW
window = glfwCreateWindow(1200,550,"GL_Scope",NULL,NULL);
glfwSetWindowPos(window,50,100);
if(!window){printf("GLFW could not create window.");}
glfwMakeContextCurrent(window);
glewInit();
GL_Init();
coordinate_system=SOIL_load_image("Coordinate.bmp",&width,&height,0,SOIL_LOAD_RGBA);
glGenTextures(1, &tex_coordinate_system); // allocating a texture name
glBindTexture(GL_TEXTURE_2D, tex_coordinate_system); // selecting current texture
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); // selecting modulate to mix texture with color for shading
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_DECAL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_DECAL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); // when texture area is small, bilinear filter the closest mipmap
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // when texture area is large, bilinear filter the first mipmap
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); // tiling texture
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
glGenerateMipmap(GL_TEXTURE_2D);
gluBuild2DMipmaps(GL_TEXTURE_2D, 4, width, height, GL_RGBA, GL_UNSIGNED_BYTE,coordinate_system ); // building texture mipmaps
while(1){
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBegin(GL_QUADS);
glVertex2f(-1.00000f, -1.00000f);
glTexCoord2f(1.0f, 0.0f);
glVertex2f( 0.66666f, -1.00000f);
glTexCoord2f(1.0f, 1.0f);
glVertex2f( 0.66666f, 0.81818f);
glTexCoord2f(0.0f, 1.0f);
glVertex2f(-1.00000f, 0.81818f);
glTexCoord2f(0.0f, 0.0f);
glEnd();
}
}
I am getting an image(1000/500) that almost covers all the field on the window(1200/550) and it starts bottom left and goes all the way positive x,y axis towards right and top. But when I change my vertex and coordinates to below
glTexCoord2i(0, 550);
//glColor3f(1.0,1.0,1.0);
glVertex2i(0,500); // Top Left Vertex
glTexCoord2i(1200, 550);
//glColor3f(1.0,1.0,1.0);
glVertex2i(1000,500); // Top Right Vertex
glTexCoord2i(1200, 0);
//glColor3f(1.0,1.0,1.0);
glVertex2i(1000,0); // Bottom Right Vertex
glTexCoord2i(0, 0);
//glColor3f(1.0,1.0,1.0); glVertex2i(0,0); // Bottom Left Vertex
I am getting an image starting from (0,0) (exact middle of screen) and goes along the positive x axis and positive y axis and stops on where y is 500 and x is 1000 but size gets 1/4 of screen height and width. I mean image gets smaller but is able to fit in positive x,y axis of screen, does not exceed screen borders even gets short.
when I am using second code, I expect to see that my image will start exactly bottom left and go all the way top right and top and will not change its size.
why when I use x and y coordinate which matches to screen height and width, my image gets smaller and changes its starting point on screen.
what am I doing wrong?
thank you
regards