bonjour
est-ce qu'il est possible de charger un bitmap dans un screensaver autrement que de le mettre dans le fichier ressources
j'ai essayé ca ,mais ca ne charge pas
#include <windows.h>
#include <stdio.h>
#include "classTextureBmp.h"
TextureBitmap::TextureBitmap()
{
}
TextureBitmap::~TextureBitmap()
{
}
void TextureBitmap::Init(HINSTANCE hInst)
{
glEnable(GL_TEXTURE_2D);
LoadTexture("PHOTOS//photo1.bmp",hInst,1);
LoadTexture("PHOTOS//photo2.bmp",hInst,2);
LoadTexture("PHOTOS//photo3.bmp",hInst,3);
LoadTexture("PHOTOS//photo4.bmp",hInst,4);
LoadTexture("PHOTOS//photo5.bmp",hInst,5);
LoadTexture("PHOTOS//photo6.bmp",hInst,6);
}
unsigned char* TextureBitmap::inverseRGB(unsigned char* data, long nbre, int type)
{
long i=0;
int index;
unsigned char temp;
while (i<nbre-1)
{
index=i*(type/8);
temp=data[index];
data[index]=data[index+2];
data[index+2]=temp;
i++;
}
data[nbre]=0;
return data;
}
bool TextureBitmap::LoadTexture(LPTSTR szFileName, HINSTANCE hInst,GLuint texture )
{
HBITMAP hBMP;
BITMAP BMP;
unsigned char* pData;
long nData;
glGenTextures(1, &texture_name);
hBMP=(HBITMAP)LoadImage(hInst, szFileName, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION );
if (!hBMP)
return FALSE;
GetObject(hBMP, sizeof(BMP), &BMP);
pData=(unsigned char*)BMP.bmBits;
nData=BMP.bmWidth*BMP.bmHeight;
pData[nData]=0;
pData=inverseRGB(pData,nData,BMP.bmBitsPixel);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glBindTexture(GL_TEXTURE_2D,texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3,BMP.bmWidth,BMP.bmHeight,
GL_RGB, GL_UNSIGNED_BYTE,pData);
DeleteObject(hBMP);
return TRUE;
}
dans main.cpp:
LRESULT MsgCreate(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
....................code opengl ect....
Images.Init(hInst);
}
merci d'avance