Jump to content

[..] GDI+ Image -> OpenGL Texture


Recommended Posts

These days, i'm playing around OpenGL, thankfully to a thread on this forum, I found an UDF containing nearly all the standard OpenGL functions!

My problem now is how to display an image???

The best would be to convert an GDI+ image/bitmap to ang openGL usable texture.

Any example would be much apreciated!

Thanks in advance!

Link to comment
Share on other sites

In this archive is the method I try to use

Can someone check it for mistakes???

Thanks!

NB: I'm working on a 2D Display engin in AutoIt, I done a prototype with GDI+ but it's too slow for huge games (but perfect for small ones!), and now i want to do it with OpenGL

OpenGL.zip

Link to comment
Share on other sites

Did you try to play around with to see if it suit your needs and is it faster than GDI+?

In it you can combine pictures-textures to some lvl, you can draw them to in-engine gui, or directly on engine screen.

For OpenGL Udf, i did not play around with it so i realy dont know, maby its best to post problem in the thread of the one who created that Udf if he dont see your post heare.

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

Thanks for the reply

I know IrrLicht, and I tested it, it's as fast as openGL, but there are 2 problems:

- I don't want to create dependencies for my GEngin

- I didn't find out how to rotate an 2d image with it!

The best in my opignon would to create a completly portable 2d display engin for and with AutoIt!

Link to comment
Share on other sites

  • 8 months later...

Found This in msdn

void loadImage(wchar_t* file, GLuint tex)
{
    ULONG_PTR token;
    Gdiplus::GdiplusStartupInput input;
    Gdiplus::GdiplusStartup(&token, &input, NULL);
    {
        Gdiplus::Bitmap bmp(file);
        Gdiplus::Rect rect(0,0,bmp.GetWidth(), bmp.GetHeight());
        Gdiplus::BitmapData data;
        bmp.LockBits(&rect, Gdiplus::ImageLockModeRead, PixelFormat32bppARGB, &data);
        glPixelStorei(GL_UNPACK_ROW_LENGTH, data.Width);
        glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
        glBindTexture(GL_TEXTURE_2D, tex);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, data.Width, data.Height, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, data.Scan0);
        bmp.UnlockBits(&data);
    }
    Gdiplus::GdiplusShutdown(token);
}

I tried to convert it to AutoIt without succes.

Any help??? Thanks

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...