Getting a vtkTexture object from a HBITMAP handle

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Getting a vtkTexture object from a HBITMAP handle

Philippe Bruyant
Dear VTK Users,
I am using VTK 5.0, Visual C++ 6.0, Vista.
I would like to use a bitmap resource located in my .exe file (it's NOT a bitmap file) as a texture for a cube.
My question is:
How can I make a vtkTexture object from an HBITMAP handle to my resource?
I can load the resource, save it to disk, then load the bitmap file and create the vtkTexture object
    MyTexture->SetInputConnection(BMPReader->GetOutputPort());
but it's quite awkward, isn't it?
TXS
Phil

between 0000-00-00 and 9999-99-99  
_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Getting a vtkTexture object from a HBITMAP handle

jupiterben
This post has NOT been accepted by the mailing list yet.
Here is piece of code you can use:

BITMAP lBmpData;
GetObject(mBgTexBitmap, sizeof(lBmpData), &lBmpData);

vtkSmartPointer<vtkOpenGLTexture> texture;

vtkSmartPointer<vtkTextureObject> texObj = vtkSmartPointer<vtkTextureObject>::New();
texObj->SetContext(vtkOpenGLRenderWindow::SafeDownCast(GetRenderWindow()));
if (texObj->Create2DFromRaw(lBmpData.bmWidth, lBmpData.bmHeight, 3, VTK_UNSIGNED_CHAR, lBmpData.bmBits))
{
        texture = vtkSmartPointer<vtkOpenGLTexture>::New();
        texture->SetTextureObject(texObj);
}
Loading...