I want to enable OpenGL pipeline for Java program I'm working on (command line
-Dsun.java2d.opengl=True). I will have quite a lot calls to 2d drawing APIs in it so it seems sensible.
However, even when Java reports "OpenGL pipeline enabled for default config on screen 0" I can't see enything on screen. What I mean is that the program starts, I see the Java comment on OpenGL but the window is empty.
When I start the same program without any command line -D additions, everything is as expected, all the content gets rendered properly.
Where should I look for solution?
I suggest using an API made specifically to enable OpenGL integration with Java.
Not only it will get rid of most (case not "all") difficulty of integration, it will likely make the implementation much easier as well.
I am working with the LWJGL (Light Weight Java Game Library) for a game project. Tough it is made for game-development, it's focus is mainly enabling OpenGL, and actual game-frameworking is done with other, inheriting APIs, like Slick2D.
I am liking it very much and it made my OpenGL development a LOT easier. You can try it. Otherwise, there are some other OpenGL-focused APIs out there that contain yet even less non-OpenGL code.
Related
Im looking for a way of displaying a 3D Rectangle, which could be moved by the values a gyrosensor delivers from my arduino.
I just don't know where to start with the Implementation of the 3D Space, the communication works fine.
I did not find any useful information online, however, I just need a Window (Don't know, is JFrame enough for this) with a model that I can set x/y/z and yaw/pitch/roll etc.
Are there libraries or code-examples?
I did see one integration with JavaFX which I have never used yet, or the implementations were in other languages.
Unity worked out for this, even though i was getting buggy behaviour.
Therefore i tried out Processing, which turned out to work fine. There are some snippets online where you can pass in the values of your arduino and it just works out.
I cannot provide more details since the project was abandoned.
Previously in my game engine written in java, I have used lwjgl 2.9.3. I ran into an issue. I wanted lwjgl to run on another graphics card. So I researched and soon figured out, that it would be impossible using lwjgl 2.9.3. So I read about seeing if lwjgl's developers were going to add the option of choosing which graphics card you get to run on. I figured out that lwjgl 3 did have support for this. So I switched over to lwjgl 3. I got everything working and started to work on why I switched. I soon figured out that there is no documentation for changing which graphics card you use. So after hours of testing I figured out that you need to create a WGLARB context. I know you can just use the method: wglCreateContextAttribsARB(long hdc, long sharedContext, Byte/IntBuffer attribList). But it is unclear how to use this method. I am not sure if you use the windows DC Pointer or something else. I know you do not have to put anything in for the 'long sharedContext' so I put 'MemoruUtil.NULL'. So here are my questions:
How do you create a WGLARB context, or more specificly what do you specifically pass in, like do you put in an empty Int/Byte Buffer or do you put data into the buffer before you pass it in as a parameter. I do not know.
From there how do you use: WGLNVGPUAffinity.getInstance().wglCreateAffinityDCNV(gpuList); GPU list is either a PointBuffer or ByteBuffer how do I get this data to pass in in the first place?
Sorry about the long post, but I am very frustrated about the lack of documentation, Thank you in advance!
LWJGL 3 (through GLFW) handles OpenGL context creation. Which means you don't get to handle it. GLFW will create the context, though it does give you some options as to exactly how. But GLFW is cross-platform, so it doesn't give you Windows & NVIDIA-specific options.
However, that doesn't mean you don't get some control. LWJGL 3 also gives you access to the platform-specific APIs (GLX, WGL, etc), as well as extensions to them. So you can use WGL.wglGetCurrentContext to get the context, then use the WGLNVGPUAffinity functions to create affinity contexts. That extension provides all of the various tools for enumerating GPUs and creating new OpenGL contexts that target a specific GPU.
The extension specification is even nice enough to provide sample code for enumerating GPUs. Of course, it's NVIDIA only, but that clearly isn't a problem for you.
How can I make it so Eclipse automatically updates my code in a window as I edit it? I've seen the feature before in youtube videos but I cannot find it. For example : I change a JApplet rectangle width from 20 to 10, I want to see it update immediately.
I've seen Notch do this on development videos (Minecraft), it is awesome but I don't know exactly how he does it.
-- EDIT --
This has been bugging me so I went and googled "how does notch code" and found this on a blog page https://gun.io/blog/what-i-learned-from-watching-notch-code/. It doesn't say exactly how it was done but gives a good hint (HotSwap) and makes it seem like he set it up himself without external software. Here's the most relevant section:
Incredibly Fast Testing
He began by building the engine, and to do this he used the ‘HotSwap’ functionality of the Java JVM 1.4.2, which continuously updates the running code when it detects that a class has changed.
When building the engine, Notch wrote a function which would continuously pan the camera around and clip through the walls and keep the view on top, so he could make changes to the code and see the effects they made in real time. I’m used to testing by writing a function, building it, installing it on the device I’m testing on, and then seeing the result, which can take up to a minute at a time, so it’s easy to see how HotSwapping could save a lot of development time.
--- ORIGINAL POST CONTINUED ---
I get a similar effect by using groovysh though, works smoothly and can use all your java classes as is.
What I'll usually do is write all my code in java, then go and fire up "Groovysh" where it will give you a little window to enter commands (You may have to ensure the classpath works correctly outside of eclipse). I can then "new" any of my classes and call methods on them one line at a time. When you do myFrame.setSize([100,100]) you will see it change immediately.
A good test is to just run groovysh and type something like:
import javax.swing.*
f=new JFrame()
f.setVisible(true)
f.setSize(100,100)
or the groovier version:
f=new JFrame(visible:true, size:[100,100])
and you will see your frame resize on the screen. You can even drag it bigger and then do something like:
println f.getWidth()
to show your new width. It's fun to interact this way but it's more complicated if you want to actually change your class definition and see it pick up the change, I have no idea how Notch did that. I looked into it a little--it's possible he was using something like JRebel
It requires something special since you would have to dynamically reload the classfile into your running system on every save--something that should have serious classloader issues.
By the way there is also a way to get your Java program to throw out a little GroovyConsole which will allow you to inspect and modify all the variables in your running code (but again you can't replace definitions of existing classes).
Also see answer here:
Change a method at runtime via a hot swap mechanism
I have made a Screen Recorder using Java Swing and Xuggler 5.4. I have developed it in Windows 8 64 bit. It's working excellent for Windows. But at client side on Linux's environment , nothing is working. I have searched thoroughly but not getting any solutions. I have checked this thread , but it didn't work for me.
Then I tried to create simple Transparent window in Linux but it's also not working. I was not able to click through the Resizeable Panel. I have used the same JRE version (1.7) for both. Have I miss understood Java's Cross Platform Support as far as Swing is concerned?
Please Give Me Some Advice...
I have always found logging to be the best debugging tool at your disposal! Many a times, java debuggers take you into APIs where you need not go every time. Logging values of your variables, and generic 'I have reached till this point' statements make life a lot easier.
So, I suppose you have ample logging done in your code. That could give you clues on what's happening on your client's system.
Are the right environment variables set? Are they pointing to the correct Java versions you need.
If there are some specific Screen capturing requirements(plugins / modules / API) your code has, are they available on the Linux m/c?
Like #MadProgrammer said, in the end, Java has to talk with the native graphics APIs to render your screen.
I would try to debug it in this way -
Check whether my main screen loads or no(by disabling the screen capture functions for a while).
if not, dig deeper.
Check whether all necessary components for capturing screen(audio and video) are available.
Check whether the code is being run with appropriate permissions to control the h/w devices you may need.
I'd like to render a very simple 3D scene in a java applet. I could do all the math myself and render that to a bitmap, but as I'm sure I'm not the first person in history to have to draw a few cubes to the screen, I was wondering how this is usually done.
Every place I've read has said either Java3D or LWJGL, but as I understand it these rely on platform-dependent code and need to be installed separately from Java, making them both unsuitable for graphics.
So how is this usually done?
This old page lists the demos/apps/libraries of 3D Java applets with no hardware dependencies. Unfortunately very few are open-source, others are not even downloadable.
Personally I recommend you to experiment with Java 1.1 3D renderer by Ken Perlin, which has source code available and free to use for academic purposes.
EDIT: jGL is another Java 3D library with no hardware dependencies. It mimics OpenGL 1.* API. It is licensed under GNU Lesser General Public License (LGPL).
In a plug-in 2 JRE (1.6.0_10+), you can use JWS extensions for embedded applets. This is important because JWS makes it much easier to ensure the correct binaries are on the run-time class path. AFAIU JOGL and Java 3D both offer JWS extensions for their APIs.
Should you choose to go that way, please make the applet has the draggable parameter added, so the end user might choose if they want a (mostly useless) browser window wrapped around a 3D animation.
I ran into similar problems when I needed to do some 3d rendering in an applet. My solution was to simply implement from scratch a 3d rendering library in Java. The fear was that it would be a poor performer but on an I5 processor, this proved to not be the case. The added advantage is that I was able to write the library in the way I always wanted graphics to be done. The real advantage,, though, is that it will run regardless of any need to have some graphics library installed on the client and without regard to any graphics card dependencies.
I will gladly share a subset of this code to anyone who wants to look at it.
Could you use JOGL?
http://download.java.net/media/jogl/demos/www/applettest-jnlp.html
I'm not a Java guy, but 2/3 years ago when I was at univeristy I had the same problem :)
I've tried jogl... and for noob in Java like myself I found it too complicated to configure and write something using it.
I used Java3d and it worked like a charm, the only problem I had back then, was that Java3d did not worked with all graphic cards. But fortunatelly it worked with computers at my univeristy :)