LibGDX: BufferedImage into Texture - opengl

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.

Related

Unreal: How to access image in MediaTexture with C++?

I'm currently using unreal read from video and cameras. I got a Media Player and Media Texture alongside with it.
I'm aware that It is possible to read pixels from Texture2D. The problem is mediaTexture is derived from Texture. Thus It cannot be casted to Texture2D. And I have no idea how to get pixel data from it.
Thanks for any reply! C++ and blueprint are both welcomed!
At present, it seems like the only way is to render the media texture to a render target, and then read the result with ReadPixels. This is how Epic does it for their OpenCV Calibration

How to send QImage to Qt3D Entity from C++ to QML for using it as texture?

I need to change the texture of a plane in a 3D scene. In the BackEnd class in C++ I make a new QImage for setting it on a texture. I want to send it as a signal to my QML and there assign it to the planes material property.
But it looks like TextureMaterial etc. can only use a URL path to a texture file. I cant't save my Images to my hard drive to use them as a URL path. It will be too long. I need to change my texture 20+ times in a second and there are other things which this program should to do in the same time.
Is there any way to do this?
You can have a look at my implementation of a background image in Qt3D.
The way I achieved what you are looking for is by using the classes QTextureMaterial, QTexture2D and QPaintedTextureImage. I had to flip the image before drawing it that's why I subclassed QPaintedTextureImage but this might also just be what you need. Instead of loading the texture from disk, like I did, you could set the QImage on your subclass as an attribute. You only need to make the C++ class available to QML and set it on your plane (maybe you could even use PaintedTextureImage directly and write the image painting in their JavaScript-style language).
You can add your QPaintedTextureIage to the QTexture2D and then set the result as the texture on the QTextureMaterial. I'm not sure if this yields the best performance, though.
You could also try to follow these steps but they seem to be a bit more involved. This would mean you have to implement your own version of QAbstractTextureImage and return the appropriate QTextureImageDataGeneratorPtr. You can checkout the sources to gain a better understanding.

Write texture mapped obj file to disk with VTK

I am using VTK to read an obj file, texture map the 3D model and transform it to another view (by applying rotateY/X/Z transforms to vtkActors) and writing it to file using vtkwindowtoImageFilter. Due to this pipeline, the rendered image is displayed on the screen before being written to file. Is there a way to do the same pipeline without the image being displayed on screen ?
If you are using VTK 5.10 or earlier, you can reander the geometry off screen.
I am not quite sure if this is what you are looking for. I am new to vtk and I found the above link looking for a way to convert a triangular surface to volume data, ie, to voxelize the surface. All profile I found on the internet is about using vtkwindowtoImageFilter to obtain a 2D section of the screen, have you worked out a way to access 3D data of the rendered window? Please tell me about that.

OpenGL VBO Loading Font data

I need to draw a VBO consisting of font data, mainly numbers. How do I obtain the data and send it to the VBO?
I know that there is a library called freetype which should do this, but that uses bitmap fonts and I do not need bitmaps in my project. I just want polygon data which I can fill with my own color and reposition/scale.
Freetype also does outline fonts, but how do I go about tessellating the outline fonts to create accurate geometry?
Is what I am trying to achieve difficult? Can I find some examples of something similar?
Is what I am trying to achieve difficult?
In the case of rendering crisp fonts at all sizes with proper gamma correction and antialiasing: Yes!
This is actually a subject of active research.
Can I find some examples of something similar?
Just use a ready to use font drawing library for OpenGL, like FTGL.
A solution that could work is to save the font data as XY coordinates with indices from a 3D Modeling program. Than this data is loaded at startup, the result being the desired one.
Of course that this does not work when changing fonts and it takes time, but if the font will not change, it does its job.

Texture Mapping C++ OpenGL

I have read around on this, including Nehe and here for solutions, but I cant find a specific answer.
I am trying to load a a photo, called stars.jpg. I want to make this my background of the scene, by mapping it using uv coordinates, doing it by
glBegin(GL_QUADS);
glTexCoord2f(0,0);
glVertex2f(0,0);
However I am just very confused about how to load the actual textures in, all the calls for
glActiveTexture();
glEnable(GL_TEXTURE_2d);
glBindTexture(GL_TEXTURE);
All they do is confuse me, what do all these mean/do, and in what order am I suppose to put these in, in order to get the stars.jpg to be my background?
Your number-one tool for loading textures in OpenGL is the Simple OpenGL Image Loader (SOIL) library. You just need to pass the filename and some flags and you'll get your texture ID.
Also, you're learning very old and outdated version of OpenGL now - you might want to have a google for newer tutorials or browse the specs whenever you feel ready.
Here's a step by step tutorial on loading textures
http://www.nullterminator.net/gltexture.html
Its important to remember that OpenGL is a state machine, so you have to tell it "I'm going to talk about textures now" that's where the glActiveTexture(); comes in.
Also keep in mind that you will have to load in pixel by pixel the colors from your .jpg (compressed) to your texture array, so either you will need to find a library that will give you bitmap values of your .jpg file or you will need to pre-convert it into a .ppm or a .bmp which will make reading in the values easier.