?
Solved

OpenGL & Bitblt

Posted on 2004-04-06
4
Medium Priority
?
1,544 Views
Last Modified: 2007-12-19
Question: is it possible to toss OpenGL a pointer to some data from a BitBlt operation, in hopes that it can make a texture out of it?


Here the current code (C#, don't ask):

this._hdcSrc = User32.GetWindowDC(HWnd.ToInt32());
this._hdcDest = GDI32.CreateCompatibleDC(HdcSrc);
this._hBitmap = GDI32.CreateCompatibleBitmap(HdcSrc,
GDI32.GetDeviceCaps(HdcSrc,8),GDI32.GetDeviceCaps(HdcSrc,10));       
GDI32.SelectObject(HdcDest,HBitmap);
GDI32.BitBlt(HdcDest,0,0,GDI32.GetDeviceCaps(HdcSrc,8), GDI32.GetDeviceCaps(HdcSrc,10),      HdcSrc,0,0,0x00CC0020);

Can I toss HdcDest or HBitmap to an OpenGL function for textures? Creating a Bitmap from the HBitmap pointer, creating a mimap from that Bitmap, loading, unloading, etc. is very slow.

I'm half tempted to say I'd like to stream video from a pointer to a window (hWnd), but that might be going a bit far.
0
Comment
Question by:rossryan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 6

Expert Comment

by:joghurt
ID: 10764042
Why don't you use GetDIBits instead of copying the bitmap or creating a new bitmap? I don't know which gl function do you prefer for creating a texture, but you may also be able to use this._hBitmap directly.
0
 

Author Comment

by:rossryan
ID: 10764136
bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY);
                        
                        Rectangle rectangle = new Rectangle(0, 0, bitmap.Width,
                              bitmap.Height);
                        BitmapData bitmapData = bitmap.LockBits(rectangle,
                              ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
                              
                        Gl.glGenTextures(1, out this._texture);
                        Gl.glBindTexture(Gl.GL_TEXTURE_2D, this._texture);
                        Gl.glTexParameteri(Gl.GL_TEXTURE_2D,
                              Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_LINEAR);
                        Gl.glTexParameteri(Gl.GL_TEXTURE_2D,
                              Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_LINEAR);
                        Glu.gluBuild2DMipmaps(Gl.GL_TEXTURE_2D, 3,
                              bitmapData.Width, bitmapData.Height,
                              Gl.GL_BGR_EXT, Gl.GL_UNSIGNED_BYTE,
                              bitmapData.Scan0);
                        bitmap.UnlockBits(bitmapData);
0
 

Author Comment

by:rossryan
ID: 10764151
Perhaps replacing bitmapData.Scan0 with hBitmap?
0
 
LVL 6

Accepted Solution

by:
joghurt earned 2000 total points
ID: 10764193
No, your code seems to be OK. Scan0 is the address of the first scan line. bitmap.LockBits behaves like GetDIBits.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question