Forum Discussion
BlueLeopard543
9 years agoHonored Guest
Apply a texture from a HBITMAP to a wall in the sample DirectX11 room
Hi,
is it possible using the code from the sample OculusTinyRoom(DX11) to apply a texture to a solid from a HBITMAP?
The sample code is
TriangleSet walls;
walls.AddSolidColorBox(-10.1f, 0.0f, -20.0f, -10.0f, 4.0f, 20.0f, 0xff808080); // Left Wall
Add(new Model(&walls, Vector3f(0, 0, 0), new Material(new Texture(false, Sizei(256, 256), Texture::AUTO_WALL))));
Let's say that I want apply a HBITMAP texture on this wall, how can I do it in a simple way?
Thanks
is it possible using the code from the sample OculusTinyRoom(DX11) to apply a texture to a solid from a HBITMAP?
The sample code is
TriangleSet walls;
walls.AddSolidColorBox(-10.1f, 0.0f, -20.0f, -10.0f, 4.0f, 20.0f, 0xff808080); // Left Wall
Add(new Model(&walls, Vector3f(0, 0, 0), new Material(new Texture(false, Sizei(256, 256), Texture::AUTO_WALL))));
Let's say that I want apply a HBITMAP texture on this wall, how can I do it in a simple way?
Thanks
6 Replies
- thewhiteambitAdventurerThere is no such thing as a HBITMAP texture, why not simply make a texture out of it?
- BlueLeopard543Honored GuestWhat? I want to know how to make a texture using a HBITMAP but mostly I want to know how to integrate it with the already existing code of the sample. can you help me?
- thewhiteambitAdventurerI found a sample for OpenGL
http://stackoverflow.com/questions/23301171/loading-and-converting-a-hbitmap-to-an-opengl-texture
but i guess you can also use the buffer for something like thisID3D11Texture2D *tex;D3D11_TEXTURE2D_DESC tdesc;D3D11_SUBRESOURCE_DATA tbsd;tbsd.pSysMem = (void *)bits;tbsd.SysMemPitch = w * 4;tbsd.SysMemSlicePitch = w*h * 4; // Not needed since this is a 2d texturetdesc.Width = w;tdesc.Height = h;tdesc.MipLevels = 1;tdesc.ArraySize = 1;tdesc.SampleDesc.Count = 1;tdesc.SampleDesc.Quality = 0;tdesc.Usage = D3D11_USAGE_DEFAULT;tdesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;tdesc.BindFlags = D3D11_BIND_SHADER_RESOURCE;tdesc.CPUAccessFlags = 0;tdesc.MiscFlags = 0;if (FAILED(myDevice->CreateTexture2D(&tdesc, &tbsd, &tex))) {delete[] buf;return(0);} - thewhiteambitAdventurerBut I see no DX11 in your sample, seems to be wrapped in classes somehow
- BlueLeopard543Honored GuestHi,
Sorry but I don't see any HBITMAP in your code in the DirectX part, this just looks like the sample code from Oculus Tiny Room Directx11. How do I create a texture from a HBITMAP? - stevewHonored Guestyou need to access the bits of the bitmap and squirt them into a directx texture as thewhiteambit explained above.
Getting the bits from an HBITMAP is a pain as it's a legacy GDI function. You'd be better off avoiding all that stuff.
If you really must do it that way, this explains how to access the bitmap data from the handle.
https://msdn.microsoft.com/en-us/library/windows/desktop/dd183402%28v=vs.85%29.aspx
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 2 months ago
- 10 months ago
- 10 months ago
- 5 months ago
- 10 months ago