Load a BMP in opengl visual cpp - c++

I need to apply a texture in a polygon. So I searched and I found many sources but i'm most of them I had problems in include and loading BMP picture. (developing in visual cpp 10). So can anyone tell-me the easy way to load a BMP file and how to apply the texture?

An easy way is to use GDI+ class Bitmap:
http://msdn.microsoft.com/en-us/library/ms534420%28v=vs.85%29.aspx
You create an object with a constructor which takes a filename and then get a pointer to the buffer which contains the pixels using LockBits() method. That method gives you a pointer to a buffer which you can send to OpenGL texture functions.

Related

FreeType Text Rendering under DirectX 11

At the moment i just want to render a single char with FreeType and DirectX 11.
But how can i create a "ID3D11ShaderResourceView" from FT_Bitmap?
I already tried "D3DX11CreateShaderResourceViewFromFile" and "D3DX11CreateTextureFromFile" but both doesn't work.
Has someone a good tutorial or a code snippet for me?
Since FT_Bitmap is a bitmap already loaded into memory, you can't use the functions that create a texture from a file. Instead, you'll want to use a function to create a texture from memory.
You could use D3DXCreateShaderResourceViewFromMemory, however the D3DX library is deprecated. As mentioned on that page, you might want to instead use the DirectXTK or DirectXTex library to create a texture from memory.
Alternatively, you can create a D3D texture and shader resource view manually using ID3D11Device::CreateTexture2D and ID3D11Device::CreateShaderResourceView.
The only tricky part will be to determine which DXGI_FORMAT to use. You will need to match it with the FT_Pixel_mode of the bitmap.

LibGDX: BufferedImage into Texture

I'm trying to play videos within a LibGDX application. I've managed to load the individual video frames sequentially into a java.awt.BufferedImage using Xuggler.
Now I'm stuck trying to get that into a LibGDX Texture. Anyone know a way to do this?
I managed to find these two LibGDX files that happen to use BufferedImage's, however can't see how to use this to get my data into a Texture :(
LibGDX JoglPixmap.java
LibGDX JoglTexture.java
as soon as you transformed your bufferedImage to a pixmap just use the Texture constructor passing in a pixmap:
Texture newTexture = new Texture(myPixmap);
There are methods to construct an empty Pixmap and draw onto it. Use this pixmap then as described above
If you are using LibGDX, I have to say that I don't recommend also using BufferedImages (from Java2D), instead you could use a Pixmap, or if you really do need BufferedImages, then I guess you could use ImageIO to save the image to a file, bring the file back in as a texture, then delete the file, but that seems quite hacky and inefficient.

How can i save png images in sdl?

ok so i want to save images in sdl.
i only know how to save stuff in .txt files.
theoreticlly i could take all the bits of the surface and save them in the .txt file and later load all those bits into a surface manually.
but i don't want to do that because a surface in sdl has to go threw some certain processes witch i don't really know what they do.
like every surface has to go through the SDL_DisplayFormat(SDL_Surface *) function.
and if i load functions threw .txt i won't be able to do that.
and there is probablly a simple function to do this so i want to take the easy way.
so where can i get a function that saves a surface to a png file(preferred SDL function)
Use that one to save the Screen as Bitmap.
SDL_SaveBMP(main_global_stuff.sdl.surface, screenshot_filename);
I just looked quickly; with SDL_Image you're able to load png-files. Take a look here for more solutions and librarys.
SDL_Image

How can I draw a png ontop of another png?

How can I "draw"\"merge" a png top of another png (background) using libpng, while keeping the alpha section of the png being drawn on top of the backhround png. There does not seem to be any tutorials or anything mentioned in the documentation about it.
libpng is a library for loading images stored in the PNG file format. It is not a library for blitting images, compositing images, or anything of that nature. libpng's basic job is to take a file or memory image and turn it into an array of color values. What you're talking about is very much out of scope for libpng.
If you want to do this, you will have to do the image composition yourself manually. Or use a library that can do image composition (cairo, etc).

Qt and OpenGL how to render a PVR

I'm having a few issues regarding how to render a PVR.
I'm confused about how to get the data from the PVR to screen. I have a window that is ready to draw a picture and I'm a bit stuck. What do I need to get from the PVR as parameters to then be able to draw a texture? With jpeg and pngs locally you can just load the image from a directory but how would the same occur for a PVR?
Depends what format the data inside the PVR is in. If it's a supported standard then just copy it to a texture with glTexSubImage2D(), otherwise you will need to decompress it into something OpenGL understands - like RGB or RGBA.
edit - OpenGL is a display library (well much much more than that), it doesn't read images, decode movies or do sound.
TGA files are generally very simple uncompressed RGB or RGBA image data, it should be trivial to decode the file, extract the image data and copy it directly to an opengl texture.
since you tagged the question Qt you can use QImage to load the tga and Using QImage with OpenGL