OpenGl antialiasing in lwjgl (Minecraft) - java

Is it possible to have an antialiasing shader (if so how) , or is it only possible with fbos based on information below.
.
I am trying to add anti aliasing to the gui in Minecraft which runs off lwjgl.
I first came upon this https://www.youtube.com/watch?v=Pdn13TRWEM0
In which he talks about how to make antialiasing in lwjgl, But since minecraft uses another framebuffer,
Display.create((new PixelFormat()).withDepthBits(24).withSamples(8));
GL11.glEnable(GL13.GL_MULTISAMPLE);
Dosen't work
From there in another video he describes doing it with fbos
https://www.youtube.com/watch?v=HCBoIvVmYgk
Would this be the only way for me to implement anti aliasing, or is it possible an easier way.
Optifine allows for antialiasing, but it only happens within minecraft games
With no antialiasing a circle looks like this

Which game version and modding framework are you using? There are a few ways of doing this, I happen to know one for fabricmc on everything up from 1.17.
(disclaimer: this library is made and maintained by me)
https://github.com/0x3C50/Renderer is a rendering library for modern fabric, that includes a MSAAFramebuffer you can use to render things anti aliased. Just wrap your rendering code in
MSAAFramebuffer.use(samples, () -> {
// render
});

Related

How to run libGDX headless, without GPU, but still rendering frames?

I'm looking into running libGDX based app on a Ubuntu Server. The server has no GPU. The purpose is to render animations defined as libGDX "games". The perfect setup would pipe frames out to standard output. I'm OK with some kind of software-simulated GPU.
I'm aware of libGDX headless mode, but as far as I understand it will not render any graphics.
LibGDX on Linux depends upon the LWJGL library for setting up rendering support. So, what you want to find out is if/how LWJGL can run without a GPU. Both LibGDX and LWJGL expose fairly low-level OpenGL commands, so I think what you need is the Mesa library (it exposes OpenGL support, but does everything in software).
From this question:
Does LWJGL (bare) use software or hardware rendering? it looks like you can ask LWJGL to not require hardware support. But, I think you still need some software-support enabled (and I believe that would be Mesa).
If you get this stack working, I think the next step is to have your "game" render to a FrameBuffer and then use Libgdx to render the FrameBuffer to file inside libgdx or OpenGL. (There may be ways to get lower layers of the stack to render to a file, too.)

Rendering 2D Text in OpenGL in the modern pipeline

I've been searching the internet for quite some time and I have not been able to find satisfying content, I am using Java/LWJGL/OpenGL to create a 3D application.
I am running it on 3.3 on the core profile, because I want to have absolutely nothing to do with legacy OpenGL.
However I cannot find any small jar that allows me to render 2D text.
If I need to do it all by myself, then well... Fine. But I was not intending to invest so much time in something so trivial as printing some 2D text on the screen.
What I have come accross so far:
Slick-Util library for Java, relies on the legacy OpenGL.
Some proprietary class called TextRender that has somethign to do with Java2D, seems quite sketchy and almost sounds to me like it will create it's own OpenGL context and I want to manage those things.
What else is there out there to render 2D text? Do I really need to make something myself for something such trivial?
I just wanted to output the frames per second.

JavaFX and antialias

I am in the process of porting some graphics rendering from java/Android to standard java.
The first thing that I am faced with is - which graphics api to use, Graphics2D or JavaFX.
It was proposed by assylias in my previous question "Porting graphics drawing from android to standard java", that I use JavaFX.
I have seen that this has the advantage of taking doubles and floats as parameters for drawing, as with Android.
However, I have not been able to find anything which confirms that the drawing is antialiased, or that antialiasing can be turned on.
My objective is to generate a high quality image which will be directly saved to disk and not displayed in the application. It will be displayed in another context and not printed.
I need to be drawing text, paths, beziers, lines, ellipses and rectangles.
Is it worth my while digging into JavaFX or do I have no choice but to go with Graphics2D ?
Many (if not all) of the objects that are drawn in JavaFX applications already have antialiasing effect. This is visible to the naked eye. Try to write two identical applications, one in JavaFX, and another in Swing (without antialiasing effect of Graphics and RenderingHints object). The difference is clear, especially when drawing geometric shapes and text. Here you can find some comparisons between Swing and JavaFX, and here you can get to know better the JavaFX 2.X (read the subject "Graphics System" and "Media and Images").
Personally, I would prefer to use JavaFX technology. I previously used a lot Swing. Each of my applications had to be made in Swing. However, after seeing the practicality of JavaFX, its maintainability, its elegance and productivity, I did not think twice. Even if you just want to draw simple things, JavaFX seems to have a much better performance. If I'm not mistaken, JavaFX was developed taking into account the use of video hardware on your platform, and was also inspired by the famous game engines available for Java users, which are made to work with high processing visual effect, screen updates, and among many other things.
For you marvel a bit with the technology and effort that was put, I beg you, visit this address. Look for the download of a JavaFX program named Ensemble. You will find where is written "JDK 7 and JavaFX Demos and Samples". click download and use the demo program Ensemble.
For information on drawing text, geometric shapes and stuff, see the following links:
http://java.dzone.com/articles/javafx-21-beta-improved-font
http://fxexperience.com/2012/01/lcd-text-support-in-javafx-2-1-developer-preview/ (An alternative from the previous link)
http://docs.oracle.com/javafx/2/text/jfxpub-text.htm (Look for "Setting LCD Text Support" and also, with the feature of applying effects to text and various things of JavaFX, you can still improve the visualization of what is shown to the user.)
http://docs.oracle.com/javafx/2/api/javafx/scene/shape/Shape.html#smoothProperty (The "shapes part")
Would you like an opinion of a colleague? Adopt JavaFX in its version 2.X or higher (do not use the JavaFX 1.X). Over time this type of technology will mature. Much still come ahead. The next update of JavaFX, we will have many nice features. And notice that JavaFX is still in its version 2.X. Probably in the near future Swing library will be left out, as happened with the AWT. You better start now studying JavaFX, rather than only in the future you go familiarizing yourself. The market is there.
If you still have some questions, please come back and ask. We'll be here. :)
Good luck.

Is it possible to make a JFrame always on top of apps. running OpenGL and DirectX?

I am currently working on a notification app, using Java.
I need for the window to be shortly (about 10 sec.) on top of any apps. including the ones running OpenGL and DirectX (e.g. computer games). I know that the JFrame.setAlwaysOnTop(true); only works in window based environments, which OpenGL and DirectX is not.
Thought about the OpenGL bindings, but can't seem to find anything about DirectX?
Maybe it is possible using JNI?
Any ideas are welcome :-)
Edit: Thanks for the answers guys, but I actually gave up on it and decided to force the game, of which I am making the overlay for, in windowed fullscreen mode. I´ll just have to wait and see what the beta-testers have to say about the reduced fps :-) thanks again
Don't bother with directx and java. That has an impedance mismatch. Java is cross platform, OpenGL is cross platform. If you insist on using directx you can try SWT since it uses native operating system resources you might have a chance.
For opengl what you are looking for is canvas integration with panel/jframe, you can use JOGL for that. I think lwjgl has a implementation too, but the jogl one is better. Then you can set the alwaysOnTop on that jframe.
kenai.com/projects/jogl
Your problem is not related to your code but the graphic device instead.
The device can have only one accelerated surface in full screen mode. This is Why you cannot launch two DirectX games in fullscreen if you have a dueal head GPU.
Your best bet is to try to find the DX/OpenGL surface pointer and attach to it using the required APIs. I don't know if this can be done in Java however the approach woul be:
get a pointer to the accelerated surface of the game or app that is running
create an accelerated graphic device
create a non-mimpap texture(screenshot) from your UI
get a pointer to the texture surface
use the stretch rectangle from this surface to the one you got in step 1
present
This may introduce flickering if not using Vsync and refresh rate synched repetition for each frame. This may introduce a substantial framerate drop too.
One example of this is FRAPS, that draws the current framerate on the accelerated app.

Suggested framework for generic 3D demo software

My company has decided that we need a "generic" demo infrastructure for our technology demos, given that I can write this using JOGL or OpenGL and create my own framework, I'd hate to reinvent the wheel. But there are so many 3D gfx engines out there and so many OpenGL wrappers!
Basically, we want to use 3D graphics to render some terrain and put simple models on it.
Their requirements are for it to look great and be cross-platform.
Basically, I am free to decide the scope and paradigm this would follow but I was thinking:
- Be able to load 3D models and render them in full-screen or windowed mode.
- Be able to control the camera(s) to "fly" through the resulting scene.
- Be able to show/hide billboard messages on top of everything, i.e. 2D text and images that are fixed on the screen and always face the camera.
- Be able to change simple things about parts of the scene, such as making object appear/disappear, change highlight color (like paint in red), and such.
- I am optionally looking to write or use an existing scripting language to inject event handling and pre-programmed animations.
Sample use case:
- Someone at our company prepares a 3D model of terrain with some buildings, essentially generating an XML-like file describing the scene and its objects.
- He then proceeds to use my program to fly through the terrain and record a few camera positions "of interest".
- Then, he binds some of those positions to keyboard keys and/or existing GUI buttons.
- He adds some pieces of floating text.
- He presents a demo using my program, loads his 3D model file and script file and can start "flying" with the audience from one of his selected camera poses to the next, the floating text fades in and out as he arrives and leaves the camera positions... some buildings on the terrain highlight in red when he clicks a button... etc.
I have some OpenGL and JOGL, as well as XNA Game Studio experience.
I'd rather use Java so it can be as platform-independent as possible.
What should I do?
I'd recommend you take a look at OpenSceneGraph or Ogre. Both are cross platform (C++), feature rich graphics engines. Furthermore, they are commercially friendly licenses and are very mature and actively maintained engines.
I know that out of the box, OpenSceneGraph supports the loading of several model formats with one or two lines of code and there are several OSG libraries that already do a great job at managing and rendering terrain.
Otherwise, you'll be spending 95% of your time writing a niche engine rather than developing your visualization capability.
It's not Java, but otherwise what you describe sounds extremely close to the Open Source Virtual Terrain Project. You may well be better using that add contributing additional facilities you develop than starting from a more basic scenegraph level.
I advise you to use Ardor3D or JMonkeyEngine 3. Ardor3D has an excellent support of JOGL, it supports the Collada format, terrains, heightmaps, it is used by the NASA and in GIS applications, it is not a niche engine. Ardor3D even works on Android, it is one of the most cross-platform 3D engine.
I advise you to look at this demo showing a procedural terrain in Ardor3D:
http://www.youtube.com/watch?v=bkXFkxrYtLY

Categories