Related
Trying to complete a basic texture map to surface using OpenGL and SOIL but I am not generating anything.
GLuint textureID[5];
glutInitWindowPosition(0, 50);
windowID[0] = glutCreateWindow("orthogonal projection, cubes");
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-400, 400, -400, 400, -500, 500);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glutKeyboardFunc(Keyboard);
glutDisplayFunc(DrawWindowOne);
textureID[0] = SOIL_load_OGL_texture("assets/faceA.png",
SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_INVERT_Y);
void DrawWindowOne()
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
glViewport(0, 0, 250, 250);
glMatrixMode(GL_MODELVIEW);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
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);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, textureID[0]);
glBegin(GL_QUADS);
glNormal3f(0.0, 0.0, 1.0); // front face
glTexCoord2f(0.0, 0.0); glVertex3f(-a,-a, a);
glTexCoord2f(0.0, 1.0); glVertex3f(-a, a, a);
glTexCoord2f(1.0, 1.0); glVertex3f( a, a, a);
glTexCoord2f(1.0, 0.0); glVertex3f( a,-a, a);
glEnd();
glDisable(GL_TEXTURE_2D);
}
The face draws in blue, however, and I get no texture. I have a second window, where apart from position the only differance is that I am using Frustrum as opposed to Orthogonal
windowID[1] = glutCreateWindow("Perspective projection using glFrustum");
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-60, 60, -60, 60, 60, 200);
gluLookAt(0, 0, 120, 0, 0, 0, 0, 1, 0);
and the texture draws fine.
The problem was that I was loading the textures all at once, where it appears they need to be loaded after each window is initialized to be available for that windows draw code.
#pragma region Initialise Window One
glutInitWindowPosition(0, 50);
windowID[1] = glutCreateWindow("orthogonal projection, cubes");
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-400, 400, -400, 400, -500, 500);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glutKeyboardFunc(Keyboard);
glutDisplayFunc(DrawWindowOne);
LoadTextures();
#pragma endregion
#pragma region Initialise Window Two
glutInitWindowPosition(0, 450);
windowID[1] = glutCreateWindow("Perspective projection using glFrustum, ellipsoids");
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-60, 60, -60, 60, 60, 200);
gluLookAt(0, 0, 120, 0, 0, 0, 0, 1, 0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glutKeyboardFunc(Keyboard);
glutDisplayFunc(DrawWindowTwo);
LoadTextures();
#pragma endregion
I am trying something quite easy, normally: applying a texture on the different surfaces of a cube.
I am able to apply it but it seems as if he just takes an average of the colors of my image.
why please?
my code:
void MyGLWidget::drawCube()
{
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
glLoadIdentity();
// glPushMatrix();
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
glTranslatef( 0.5, 0, 0.0);
glRotatef(getCubeAngle(), 0.0f, 1.0f, 0.0f);
glTranslatef(0, 0, 0);
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
glBindTexture(GL_TEXTURE_2D, texture[0]);
glBegin(GL_QUADS);
//back
glVertex3f(-0.1, 0.1,-0.1 );//upper left corner
glVertex3f(0.1, 0.1,-0.1); //uper right
glVertex3f(0.1,-0.1,-0.1 ); // down left
glVertex3f(-0.1,-0.1,-0.1); // down right
/* other code to create rest of the cube*/
glEnd();
glFlush();
// glPopMatrix();
}
void MyGLWidget::resizeGL(int width, int height)
{
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glScalef(height *1./width, 1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
}
void MyGLWidget::myTextureMapping()
{
QImage t;
QImage b;
if(!b.load("..../myImage.bmp"))
{qDebug("error with image\n");}
t = QGLWidget::convertToGLFormat(b);
glGenTextures( 1, &texture[0] );
glBindTexture( GL_TEXTURE_2D, texture[0] );
glTexImage2D( GL_TEXTURE_2D, 0, 3, t.width(), t.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, t.bits() );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
}
void MyGLWidget::initializeGL()
{
myTextureMapping();
glEnable(GL_TEXTURE_2D);
glShadeModel(GL_SMOOTH);
glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
}
EDIT:
added those tex coordinates:
glTexCoord2f(-0.1, 0.1);
glVertex3f(-0.1, 0.1,0 );//upper left corner
glTexCoord2f(0.1, 0.1);
glVertex3f(0.1, 0.1,0); //uper right
glTexCoord2f(0.1, -0.1);
glVertex3f(0.1,-0.1,0 ); // down left
glTexCoord2f(-0.1, -0.1);
glVertex3f(-0.1,-0.1,0); // down right
But my image is bigger than the face of my cube:
source image : http://imgur.com/h48QARM
result in software: http://imgur.com/rxvK0Ot
You should be providing the texture co-ordinates for each vertex. What you have right now is just a position data for the Quad, texture co-ordinates are missing.
Have a look at this :
OpenGL Textured Cube Not Being Mapped Correctly
Try this :
glTexCoord2f(0, 0);
glVertex3f(-0.1, 0.1,0 );//upper left corner
glTexCoord2f(1, 0);
glVertex3f(0.1, 0.1,0); //uper right
glTexCoord2f(0, 1);
glVertex3f(-0.1,-0.1,0 ); // down left
glTexCoord2f(1, 1);
glVertex3f(0.1,-0.1,0); // down right
Isn't the texture coordinates wrong? To me it seems like you're going -0.1 to 0.1, while texture coordinates normally are defined in the interval [0,1].
How can I Create a 4 views (LEFT/TOP/PERSPECTIVE/FRONT) in Open GL ??
I Have Used this :
int main(int c,char ** argv)
{
glutInit(&c,argv);
glutInitDisplayMode(GLUT_DOUBLE |GLUT_DEPTH |GLUT_RGB );
glutInitWindowSize(w,h);
MainWin =glutCreateWindow("Teapot Window");
glutDisplayFunc(display);
LeftWin = glutCreateSubWindow(MainWin,0,0,s_window_w,s_window_h);
glutDisplayFunc(displayLeft);
glutReshapeFunc(reshapeLeft);
TopWin = glutCreateSubWindow(MainWin,s_window_w+3,0,s_window_w,s_window_h);
glutDisplayFunc(displayTop);
glutReshapeFunc(reshapeTop);
PerspectiveWin = glutCreateSubWindow(MainWin,0,s_window_h+3,s_window_w,s_window_h);
glutDisplayFunc(displayPerspective);
glutReshapeFunc(reshapePerspective);
FrontWin = glutCreateSubWindow(MainWin,s_window_w+3,s_window_h+3,s_window_w,s_window_h);
glutDisplayFunc(displayFront);
glutReshapeFunc(reshapeFront);
glutMainLoop();
return 0;
}
Then I have make the projection for top and left and like this :
glViewport(0,0,w,h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-0.5f,0.5f,-0.35f,0.35f,1,500);
When I use the top lines for the front also , the output is something like this :
Where is my fault ?
thanks in advance
Why the Front view is empty and the perspective and left view are same ??
For perspective projection i had used glFrustum ....
So Am I going wrong ?
Please help on creating multiple views like 3ds max or maya ...
below is the code for display functions:
void displayLeft()
{
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0,0,-1,0,0,0,0,1,0);
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glLightfv(GL_LIGHT0,GL_POSITION,light_pos);
glShadeModel(GL_SMOOTH);
glClearColor(0.2f,0.3f,0.4f,1);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glEnable(GL_COLOR_MATERIAL);
glTranslatef(teapot_x,teapot_y,teapot_z);
glRotatef(teapot_angle,0,1,0);
glColor3f(0,1,0);
glutSolidTeapot(0.2f);
glPopMatrix();
glFlush();
glutSwapBuffers();
}
void displayTop()
{
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0,-1,0,0,0,0,0,0,-1);
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glLightfv(GL_LIGHT0,GL_POSITION,light_pos);
glShadeModel(GL_SMOOTH);
glClearColor(0.2f,0.3f,0.4f,1);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glEnable(GL_COLOR_MATERIAL);
glTranslatef(teapot_x,teapot_y,teapot_z);
glRotatef(teapot_angle,0,1,0);
glColor3f(0,1,0);
glutSolidTeapot(0.2f);
glPopMatrix();
glFlush();
glutSwapBuffers();
}
void displayFront()
{
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0,0,0,0,0,0,1,0,0);
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glLightfv(GL_LIGHT0,GL_POSITION,light_pos);
glShadeModel(GL_SMOOTH);
glClearColor(0.2f,0.3f,0.4f,1);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glEnable(GL_COLOR_MATERIAL);
glTranslatef(teapot_x,teapot_y,teapot_z);
glRotatef(teapot_angle,0,1,0);
glColor3f(0,1,0);
glutSolidTeapot(0.2f);
glPopMatrix();
glFlush();
glutSwapBuffers();
}
void displayPerspective()
{
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0,0,-1,0,0,0,0,1,0);
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glLightfv(GL_LIGHT0,GL_POSITION,light_pos);
glShadeModel(GL_SMOOTH);
glClearColor(0.2f,0.3f,0.4f,1);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glEnable(GL_COLOR_MATERIAL);
glTranslatef(teapot_x,teapot_y,teapot_z);
glRotatef(0,0,1,0);
glColor3f(0,1,0);
glutSolidTeapot(0.2f);
glPopMatrix();
glFlush();
glutSwapBuffers();
}
Use glViewport and glScissor to cut out panes of the window. Then for each pane perform the rendering as usual. Setting the projection matrix is actually a drawing state operation, so it belongs into the display function, not reshape.
Your display function should become something like
void ViewportScissor(int x, int y, int width, int height)
{
glViewport(x, y, width, height);
glScissor(x, y, width, height);
}
void display(void)
{
int const win_width = glutGet(GLUT_WINDOW_WIDTH);
int const win_height = glutGet(GLUT_WINDOW_HEIGHT);
glDisable(GL_SCISSOR);
glClear(…);
glEnable(GL_SCISSOR);
ViewportScissor(0, 0, win_width/2, win_height/2);
glMatrixMode(GL_PROJECTION);
setup_frontview_projection();
glMatrixMode(GL_MODELVIEW);
setup_frontview();
draw_scene();
ViewportScissor(win_width/2, 0, win_width/2, win_height/2);
glMatrixMode(GL_PROJECTION);
setup_rightview_projection();
glMatrixMode(GL_MODELVIEW);
setup_rightview();
draw_scene();
ViewportScissor(0, win_height/2, win_width/2, win_height/2);
glMatrixMode(GL_PROJECTION);
setup_topview_projection();
glMatrixMode(GL_MODELVIEW);
setup_topview();
draw_scene();
ViewportScissor(win_width/2, win_height/2, win_width/2, win_height/2);
glMatrixMode(GL_PROJECTION);
setup_freecamview_projection();
glMatrixMode(GL_MODELVIEW);
setup_freecamview();
draw_scene();
glutSwapBuffers();
}
Adding splitter lines/frames is left as an exercise for the reader.
To make my maze type game faster I decided to put my drawed ball inside a texture, because i have to draw it otherwise once for every room and I'm drawing it like a concave polygon using the stencil buffer, it takes more time than using a texture. The problem is, that I'm getting it inside a texture correctly from the back buffer when I'm rendering the third frame since the start of the game and my question is, why is it like so?
When I'm using a texture from the thirst frame, I'm having texture with solid white color, so it has nothing inside. When I'm using textures from the second frame, then I have only the black background of the desired texture and when I take the texture from the third frame, then I have desired texture. For frame count I use the static variable "done" inside the "drawTexture" function.
Copying from the first frame:
Copying from the second frame:
Copying from the third frame (desired outcome):
void DrawBall::drawTexture(float imageD) {
static int done = 0;
if (done < 3) {
drawToTexture(imageD);
done++;
}
glEnable(GL_TEXTURE_2D);
glBindTexture (GL_TEXTURE_2D, texture);
glColor3f(1, 1, 1);
glBegin (GL_QUADS);
glTexCoord2f (0.0, 0.0); glVertex3f (0.0, 0.0, -imageD);
glTexCoord2f (1.0, 0.0); glVertex3f (5.0, 0.0, -imageD);
glTexCoord2f (1.0, 1.0); glVertex3f (5.0, 5.0, -imageD);
glTexCoord2f (0.0, 1.0); glVertex3f (0.0, 5.0, -imageD);
glEnd ();
glDisable(GL_TEXTURE_2D);
}
void DrawBall::drawToTexture(float imageD) {
int viewport[4];
glGetIntegerv(GL_VIEWPORT, (int*) viewport);
int textureWidth = 64;
int textureHeight = 64;
texture = genEmptyTexture(textureWidth, textureHeight);
glViewport(0, 0, textureWidth, textureHeight);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f, 1, 1, 100);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
/*
This function calculates the vertexes for the ball
inside a vector<vector<float>> variable "test"
*/
_calculateCircleVertexes(0.0f, 0.0f, -2.0f, 0.249f, &test, 20);
_displayBall(&test, 0.0f, 0.0f, 0.5f, -2.0f, &*smallBallColor);
glBindTexture(GL_TEXTURE_2D, texture);
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, textureWidth, textureHeight, 0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
glViewport(viewport[0], viewport[1], viewport[2], viewport[3]);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f, (GLfloat)viewport[2] / (GLfloat)viewport[3], 1.0f, imageD + 10.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
GLuint DrawBall::genEmptyTexture(unsigned int width, unsigned int height) {
GLuint txtIndex;
glGenTextures(1, &txtIndex);
glBindTexture(GL_TEXTURE_2D, txtIndex);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0,
GL_RGB, GL_UNSIGNED_BYTE, NULL);
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_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
return txtIndex;
}
void DrawBall::_displayBall(vector<vector<GLfloat>> *vertexes, GLfloat x, GLfloat y
, GLfloat imageW, GLfloat imageD, color *color) {
glTranslatef(x, y, imageD);
glClearStencil(0);
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_NEVER, 0, 1);
glStencilOp(GL_INVERT, GL_INVERT, GL_INVERT);
glBegin(GL_POLYGON);
vector<vector<GLfloat>>::iterator it = vertexes->begin();
for (; it != vertexes->end(); it++) {
glVertex3f((*it)[0], (*it)[1], 0.0f);
}
glEnd();
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glStencilFunc(GL_EQUAL, 1, 1);
glStencilOp(GL_ZERO, GL_ZERO, GL_ZERO);
glColor3f(color->r, color->g, color->b);
glBegin(GL_QUADS);
glVertex3f(-(imageW / 2.0f), -(imageW / 2.0f), 0.0f);
glVertex3f( (imageW / 2.0f), -(imageW / 2.0f), 0.0f);
glVertex3f( (imageW / 2.0f), (imageW / 2.0f), 0.0f);
glVertex3f(-(imageW / 2.0f), (imageW / 2.0f), 0.0f);
glEnd();
glDisable(GL_STENCIL_TEST);
glTranslatef(x, y, -imageD);
}
You should not use the window framebuffer (which includes both back- and frontbuffer) for render to texture operations. It just breaks to easily (you've experienced it). Instead use a so called Framebuffer Object, with the texture as rendering target.
Well, Datenwolf, thank you for your suggestion, you are probably right but I just want to use the advanced stuff as less as possible and I found my mistakes. I didn't get the desired outcome before the second frame because I didn't have yet enabled stencil test. Before the first frame I didn't get the desired outcome because in the window creation Windows sends WM_SIZE message and I had the draw message inside it but at that time the OpenGL isn't set up properly yet.
here is the output: http://i43.tinypic.com/9a5zyx.png
if things were working the way i wanted, the colors in the left square would match the colors in the right square. thanks for any help regarding the subject
#include <gl/glfw.h>
const char* title="test";
GLuint img;
unsigned int w=64,h=64;
int screenwidth,screenheight;
void enable2d()
{
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glViewport(0,0,screenwidth,screenheight);
glOrtho(0,screenwidth,screenheight,0,-1,1);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glPushAttrib(GL_DEPTH_BUFFER_BIT|GL_LIGHTING_BIT);
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
}
void drawmytex()
{
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,img);
glBegin(GL_QUADS);
glTexCoord2i(0,0);
glVertex2i(0,0);
glTexCoord2i(1,0);
glVertex2i(w,0);
glTexCoord2i(1,1);
glVertex2i(w,h);
glTexCoord2i(0,1);
glVertex2i(0,h);
glEnd();
glDisable(GL_TEXTURE_2D);
}
void drawquad(int x,int y)
{
glBegin(GL_QUADS);
glColor3f(0.0f,1.0f,0.0f);
glVertex2i(x,y);
glColor3f(1.0f,0.0f,1.0f);
glVertex2i(x+w,y);
glColor3f(0.0f,1.0f,1.0f);
glVertex2i(x+w,y+h);
glColor3f(0.0f,0.0f,1.0f);
glVertex2i(x,y+h);
glEnd();
}
void texcopy()
{
if (!glIsTexture(img))
glDeleteTextures(1,&img);
glGenTextures(1,&img);
glBindTexture(GL_TEXTURE_2D,img);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,w,h,0,GL_RGBA,GL_UNSIGNED_BYTE,0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0,w,h,0,-1,1);
glViewport(0,0,w,h);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
drawquad(0,0);
glBindTexture(GL_TEXTURE_2D,img);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
//glCopyTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,0,0,w,h,0);
glCopyTexSubImage2D(GL_TEXTURE_2D,0,0,0,0,0,w,h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0,screenwidth,screenheight,0,-1,1);
glViewport(0,0,screenwidth,screenheight);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
int main()
{
int running;
glfwInit();
running=glfwOpenWindow(640,480,0,0,0,0,0,0,GLFW_WINDOW);
if (!running)
{
glfwTerminate();
return 0;
}
glfwSetWindowTitle(title);
glfwEnable(GLFW_STICKY_KEYS);
glfwGetWindowSize(&screenwidth,&screenheight);
enable2d();
texcopy();
do
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
drawquad(64,0);
drawmytex();
glfwSwapBuffers();
running=!glfwGetKey(GLFW_KEY_ESC)&&glfwGetWindowParam(GLFW_OPENED);
GLenum error=glGetError();
if (error!=GL_NO_ERROR)running=error;
glfwSleep(.017);
}
while (running==1);
glDeleteTextures(1,&img);
glfwTerminate();
return running;
}
Try adding 'glColor3f(1,1,1);' in your 'drawmytex' function. I suspect that your texture is modulated (multiplied) with the current color, if so, the problem is not the texture copy but the way you display it.