I have rendered this scene using the Java 3D API. At the bottom of the image, where the ground is closer to the viewer, there is a blurriness surrounding the black lines on the image. I would like to prevent this blurriness entirely. Here is the image I am using as the texture:
As you can see, it is quite small but making the image larger is not an option. Are there any scaling methods I can change the type of such as a "nearest-neighbour" option for Java 3D texturing?
Thanks!
As Banthar suggested, I used:
texture.setMagFilter(Texture.BASE_LEVEL_POINT);
and it works perfectly with no blurriness.
Related
I want to draw Strings in my Libgdx game but i cant use BitMap Fonts because the scale of my game is to smal to use them.
It sounds like you mean the scale of your viewport is too small to show fonts correctly. There are two solutions. The first is better for legibility while the second is quick and dirty.
One is to use a second viewport for the UI that has an appropriate scale for text. You would first call gameViewport.apply(), draw the game, and end the batch. Then use uiViewport.apply() and then draw the UI. The downside with this method would be if you want to draw text that aligns with moving objects in the game, you would have to use the two viewports to convert coordinates. Otherwise, this is the ideal method to get a crisp looking UI. Ideally you would use a ScreenViewport and select a font size at runtime based on the screen dimensions, either by shipping your game with multiple versions of the font at different scales, or by using FreeTypeFontGenerator.
The second method is to scale down all your text. First call bitmapFont.setUseIntegerPositions(false) do it won't round off positions to integers. Then call bitmapFont.setScale() with however much you want to shrink it to fit in your game viewport.
There is a gdx-freetype project:
https://www.badlogicgames.com/wordpress/?p=2300
and it uses TrueType fonts as source to generate bitmap font on the fly.
Not sure how stable this is - didn't use it.
I generate my BitmapFonts at runtime with GdxFreetype. As the parameter.size is in pixels and I use a camera which scales up the scene, the font becomes blurry (even with texture filters at higher resolutions).
I need a way to create fonts based on the current resolution. How can I achieve that?
Just use two different cameras! One for your game that could have virtual size(say 16x20) and one pixel perfect camera. Draw those bitmap fonts using the second one. And for dynamically setting parameter size while generating them i personally use
ORIGINAL_SCREEN_HEIGHT/SOME_CONSTANT
I am having a problem with manipulating images in java 7. I have researched the problem I am having for three weeks and have failed to find a solution,
I am trying to set an image over an area, basically setting the corner posistions.
I am using a BufferedImage.
This is for a 3D game where I am writing the 3D conversion code. I have managed to create a 3d world, and populate it with cubes, filling in the sides with graphics.fillPolygon():
What I would like to do is draw an image that fills a polygon's shape.
Any help I will be grateful for (even if it is formating this post better).
You can use transformations on your graphics. Here is a little tutorial on it. With that you can transform already drawn stuff. If you want to transform multiple images in different ways, you can draw them on different canvases and transform then separately. Then you can merge the images together...
But I would recommend using a 3D engine (JOGL, jMonkeyEngine, or others) for that (unless you want to learn about the geometric calculations with this task). It is also much faster to use OpenGL than drawing the stuff by yourself and doing the calculations in code (most probably meaning: on the CPU and not the GPU).
Have you tried using the drawImage? instead of .fillPolygon?
I'm looking for some method to draw half transparent figures within the draw2d framework.
Currently I'm using setAlpha() of org.eclipse.draw2d.Graphics. The problem is that it slows down the whole UI, if I draw more than one half transparent figure.
Here was another question regarding the perfomance of it [1]. It targets SWT on Linux, I target both Linux and Windows. The windows (Win7) system has a 3D capable graphic card and a i7 q720. The Linux machine is even better equipped and has also 3D, so I think it's not a performance issue of the platform.
My question is: Is there a performant way to achieve alpha blending in draw2d?
I've tried to use OpenGL respectivly LWJGL. Since draw2d and OpenGL can't be mixed up and I must rely on draw2d, I thought I could do something like this: draw2d -> OpenGL -> draw2d
here where canvas is the Canvas where the OpenGL drawing happens and c1 is the Canvas where I want to get the drawn OpenGL picture. But my attempt to copy the OpenGL drawings doesn't work it gets me just the underlying Canvas (canvas) background. Besides this I'm not sure if this would improve the "perormance" anyway...
Thanks,
atx
This issue is known but unsolved. On the mailing list of draw2d there is a thread regarding this issue: mailing list
TL;DR: A possible solution was dropped because of license issues between LWJGL and Eclipse.
Make sure all your src/dest images are of the same depth (eg. ARGB)
Otherwise, expensive conversions happen during copy (src->dest)
GCs don't allow access to their underlying buffers, afaik.
MemoryImageSource might be a way to go.
You can grab your OpenGL drawing images using something like:
BufferedImage capture = new Robot().createScreenCapture(new Rectangle( canvas.getX(), canvas.getY(), canvas.getWidth(), canvas.getHeight() ) );
Kind of fiddly, but very fast.
I use it to save jpegs of my live animation frames to a folder.
VirtualDub then creates a movie from the frames. Have to play with the frame rate ;)
Great for producing youtube teasers!
You can see one here!
I've googled around everywhere, but cannot find much for rendering strings to textures and then displaying that texture on a quad on the screen. Can someone provide a run-down on the process or provide good resources that describe how? Is rendering strings to textures even the best method for displaying text in an Android OpenGL ES app?
EDIT:
Okay, so LabelMaker interferes with alpha blending, the texture (created from a PNG with a transparent background) now has a solid black background, rather than a transparent background. If I comment out all the LabelMaker-related code, it works fine.
UPDATE:
Nevermind. I took a look at the code to find that LabelMaker was disabling blending after drawing the labels.
I think this is what you are looking for.
If you don't want to use GL extensions you need to create the font as a bitmap and then create a class to convert that string into quads that you can draw.
I use this method with the 2 fonts in my game. I have a class that takes a wide texture with all the letters evenly spaced, and a string that matches the image, then uses lookups on the letters to find out how far in the bitmap it should go.
Your other option is to render your text to a offscreen bitmap using android, and then bind the text as a texture. This will let you use androids built-in font processing and rendering to create texture-based fonts.
The second method I have not used yet, but I have rendered google maps to a offscreen canvas and then bound the bitmap as a GL texture, so doing it for text should be much simpler.
If you are planning to have modifying string data in a gl loop you need to really worry about StringBuilder too, because it causes GC and performance issues. I hardcode all my strings so it doesn't allocate, and all my rapidly numbers are done through a second draw function dedicated to drawing changing numbers without using string-builder.