Skip to main content
GameDev.net gamedev.net
🔒 Locked

Surfaces and Textures

Started by Metus Sep 10, 2000 at 5:08 PM 0 replies 200+ views
Original Post
Metus
Metus
Ok...It''s late here in Sweden and I''m tired...and MAD AS HELL because my LoadTexture Function won''t work..or at least...as it should... here''s the main code: void Engine::LoadTexture(LPDIRECTDRAWSURFACE7 *Surface, char *Filename) { DDSURFACEDESC2 TextureDesc; HBITMAP hBitmap; BITMAP Bitmap; HDC DeviceContext; HDC BitmapContext; //Load the Bitmap into Memory hBitmap = (HBITMAP)LoadImage(hInstance, Filename, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE); GetObject(hBitmap, sizeof(BITMAP), &Bitmap); //Create the Surface ZeroMemory(&TextureDesc, sizeof(DDSURFACEDESC2)); TextureDesc.dwSize = sizeof(DDSURFACEDESC2); TextureDesc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; TextureDesc.ddsCaps.dwCaps = DDSCAPS_TEXTURE; TextureDesc.ddsCaps.dwCaps2 = DDSCAPS2_TEXTUREMANAGE; TextureDesc.dwWidth = Bitmap.bmWidth; TextureDesc.dwHeight = Bitmap.bmHeight; DirectDraw->CreateSurface(&TextureDesc, &(*Surface), NULL); //Blit the Bitmap into Surface (*Surface)->GetDC(&DeviceContext); BitmapContext = CreateCompatibleDC(DeviceContext); SelectObject(BitmapContext, hBitmap); BitBlt(DeviceContext, 0, 0, Bitmap.bmWidth, Bitmap.bmHeight, BitmapContext, 0, 0, SRCCOPY); (*Surface)->ReleaseDC(DeviceContext); DeleteDC(DeviceContext); DeleteObject(hBitmap); } (Not the nicest code eh ?) Soo..perhaps this code seems to work...and yes it does..ONCE! After the first compile, everything works, the texture even appears on my TLVERTEX... When i RECOMPILE the code, the texture won''t appear...could you please help me, or prevent me from destroying the damn computer? Patrik
Ethereal
Sentinel
Sentinel
Try this:

//Blit the Bitmap into Surface
(*Surface)->GetDC(&DeviceContext);
BitmapContext = CreateCompatibleDC(NULL);
SelectObject(BitmapContext, hBitmap);
BitBlt(DeviceContext, 0, 0, Bitmap.bmWidth, Bitmap.bmHeight, BitmapContext, 0, 0, SRCCOPY);
(*Surface)->ReleaseDC(DeviceContext);
DeleteObject(hBitmap);
DeleteDC(BitmapContext);
}

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.