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;
wcl.hIcon = static_cast<HICON>(LoadImage(hInstance,
MAKEINTRESOURCE (IDI_ICON1),
IMAGE_ICON,
48, 48, // or whatever size icon you want to load
LR_DEFAULTCOLOR));
wcl.hCursor = LoadCursor(0, IDC_ARROW);
wcl.hbrBackground = 0;
wcl.lpszMenuName = MAKEINTRESOURCE(MENU_FIXED_FUNC);
wcl.lpszClassName = "GLWindowClass";
wcl.hIconSm = 0;
if (!RegisterClassEx(&wcl))
return 0;
g_hWnd = CreateAppWindow(wcl, APP_TITLE);
// load our texture
FIBITMAP *dib1 = loadImage("angel.jpg");
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);
}
EDIT: Now i load the picture, but the object doesn'n load.
VOID DrawFrame(GLuint texture,HDC hDC)
{
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
// setup texture mapping
glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, texture );
glPushMatrix();
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();
glClear(GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glPopMatrix(); // Pops our orthographic projection matrix
glMatrixMode(GL_MODELVIEW);
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);
}