# Background behind 3D model

I have object loader, which i want to have background. I tried to put jpg image like texture to my application. I tried to make that with FreeImage library, but the image didn't show. Also i tried with Gdiplus, i opened the image but when i opened and the object the background disappeared. I send link with the code (with FreeImage library), If someone have any ideas i will be so happy, because I haven't yet.

https://github.com/Nushiii/viewer/blob/master/ViewerPicture%20FreeImege/ViewerPicture/main.cpp

EDIT:

       int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{

MSG msg = {0};
WNDCLASSEX wcl = {0};

GLuint texture;
float theta = 0.0f;

wcl.cbSize = sizeof(wcl);
wcl.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
wcl.lpfnWndProc = WindowProc;
wcl.cbClsExtra = 0;
wcl.cbWndExtra = 0;
wcl.hInstance = g_hInstance = hInstance;
MAKEINTRESOURCE (IDI_ICON1),
IMAGE_ICON,
48, 48,    // or whatever size icon you want to load
LR_DEFAULTCOLOR));
wcl.hbrBackground = 0;
wcl.lpszClassName = "GLWindowClass";
wcl.hIconSm = 0;

if (!RegisterClassEx(&wcl))
return 0;

g_hWnd = CreateAppWindow(wcl, APP_TITLE);

texture = LoadTexturee( dib1, TRUE );

if (g_hWnd)
{
SetProcessorAffinity();

if (Init())
{
ShowWindow(g_hWnd, nShowCmd);
UpdateWindow(g_hWnd);

while (true)
{
if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT)
break;

TranslateMessage(&msg);
DispatchMessage(&msg);
} else {


EDIT

                  UpdateFrame(GetElapsedTimeInSeconds());
DrawFrame(texture, g_hDC);
SwapBuffers(g_hDC);

}

if (msg.message == WM_QUIT)
break;

}
}

Cleanup();
UnregisterClass(wcl.lpszClassName, hInstance);
}
FreeTexture( texture );
return static_cast<int>(msg.wParam);
}


VOID DrawFrame(GLuint texture,HDC hDC)
{

glMatrixMode(GL_PROJECTION);
glPushMatrix();

glMatrixMode(GL_MODELVIEW);
glPushMatrix();

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

glPushMatrix();
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();

glClear(GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glPopMatrix(); // Pops our orthographic projection matrix
glMatrixMode(GL_MODELVIEW);
glMatrixMode(GL_PROJECTION);
gluPerspective(CAMERA_FOVY,
static_cast<float>(g_windowWidth) / static_cast<float> (g_windowHeight),
CAMERA_ZNEAR, CAMERA_ZFAR);
glMatrixMode(GL_MODELVIEW);
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);


}

• The normal way to draw a static background if to draw a static textured full-screen quad. – ratchet freak Sep 13 '16 at 13:25
• @ratchetfreak please make that comment an answer, so we can vote it up :) – Paul-Jan Sep 14 '16 at 6:08
• Without access to the code, it is difficult to guess what might have gone wrong. The link does not work for me (perhaps it requires you to be logged into your storage account). Would you be happy to paste the code here? If so you can edit and the question can be reopened. Until then I'm putting the question on hold so that there will be no further answers until it is clarified, to avoid further confusion. – trichoplax Sep 15 '16 at 8:58
• @trichoplax what do you think about github or mail, becouse the code is long and i think that if you look the all code will be easier what i wrong. Thank you so much! – I.To Sep 15 '16 at 13:31
• I recommend separating out just the part of the code that places the background, and seeing if it works on its own. If it doesn't, you can post just that part knowing that it contains a problem. If it does work, add in the simplest extra code that causes the problem, then post that slightly longer code knowing that it contains a problem. – trichoplax Sep 15 '16 at 18:13

In the code you posted you draw the quad but then clear the screen again. Don't do that. Move the drawing of the quad from main to right after the glClear call.