PDA

View Full Version : Texture behind 3d model



valkaaa
09-17-2016, 04:50 AM
I have object loader, which i want to have background, i tried to put jpg image like texture yo my application. Itried to make that with FreeImage library, but the image didn't show, when the gluPerspective and gluLookAt are not comment. If someone have any ideas i will be so hapyy, becouse i haven't yet. Thank you.


VOID DrawFrameFree(GLuint texture,HDC hDC)
{

glClearColor( 0.0f, 0.4f, 0.0f, 0.0f );
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
// gluPerspective(CAMERA_FOVY,
// static_cast<float>(g_windowWidth) / static_cast<float>(g_windowHeight),
// CAMERA_ZNEAR, CAMERA_ZFAR);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
// gluLookAt(g_cameraPos[0], g_cameraPos[1], g_cameraPos[2],
// g_targetPos[0], g_targetPos[1], g_targetPos[2],
//0.0f, 1.0f, 0.0f);

glRotatef(g_pitch, 1.0f, 0.0f, 0.0f);
glRotatef(g_heading, 0.0f, 1.0f, 0.0f);

//if (g_supportsProgrammablePipeline)
// DrawModelUsingProgrammablePipeline();
// else
// DrawModelUsingFixedFuncPipeline();

// setup texture mapping
glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, texture );

glPushMatrix();
//glRotatef( theta, 0.0f, 0.0f, 1.0f );
glBegin( GL_QUADS );
glTexCoord2d(0.0,0.0); glVertex2d(-1.0,-1.0);
glTexCoord2d(1.0,0.0); glVertex2d(+1.0,-1.0);
glTexCoord2d(1.0,1.0); glVertex2d(+1.0,+1.0);
glTexCoord2d(0.0,1.0); glVertex2d(-1.0,+1.0);
glEnd();
glPopMatrix();

//SwapBuffers( hDC );

// theta += 1.0f;
}