Tag Info

Hot answers tagged

7

No, OpenGL is a library written in C. You will need some binary file for each platform to interface correctly with OpenGL. There has to be some platform specific part because the JavaVM does not virtualize the OpenGL device for you. However when developing with JAVA you can use MAVEN which is a sort of advanced build system, like Ants but done right I heard ...


5

Your timer event has an infinite loop. This blocks the event dispatch thread, blocking any other GUI events like painting or the frame closing from occurring. Learn the Java code conventions, they make your programs much easier to read. Variables should not start with an uppercase letter.


4

An alternative to JOGL is LWJGL. It really is "lightweight", as the name suggests, both in terms of installation and in terms of provided functionality - it's a pure wrapper to the C functions, with some additional (and really helpful) checkers. The documentation is certainly sufficient for me to install it on Windows, Linux and Mac; however, while 32-bit ...


3

Possible cause : From your code, no visible sources of lag are present. The lag may come from the way they are accessed from the game loop thread. Dont forget, the variables have to be synchronized, or you have to use locks for your app to be thread safe. The lag you experienced may be from the fact that you increment the x and y by 5 each. I am guessing ...


3

If you use a build system like MAVEN it is actually fairly easy to use JOGL. (But it is indeed stupidly hard to configure without it). Just add this to your POM file <dependencies> <dependency> <groupId>org.jogamp.gluegen</groupId> <artifactId>gluegen-rt-main</artifactId> ...


3

You should really consider the lwjgl solution http://www.lwjgl.org/, even though you clearly stated in your question that you dont want to rely on libraries. It includes alot of what you will need. Think about it again.


3

A cursory bit of searching with Google suggests that you probably want to use JPanel for this, although it's possible you could make use of any control since it looks like the technique you'll want to use is to subclass the control and override a method (the paintComponent method, specifically), which will give you a Graphics instance you can use for ...


2

I'm adding this by way of expansion on a comment I made to a previous answer. This question in itself shows a fundamental misunderstanding of what OpenGL is so I believe it's necessary to say more. OpenGL is not software OpenGL is "a software interface to graphics hardware" (page 1 of the OpenGL specification until the ARB changed the terminology a little ...


2

No there isn't. What you can do is use OpenGL in Java with Java™ Binding for the OpenGL® (JOGL). JOGL can interoperate with Swing pretty well, so you can render 3D (or 2D) graphics with GLSL shaders in your Swing components.


2

Your problem is that you are doing the update logic in keyPressed() method. When you press a key, AWT will call this method once. After a delay (typically 250-1000 milliseconds) it starts calling this method again repeatedly with a smaller delay (typically 30-400 milliseconds). When the key is released, this repetition stops and keyReleased() method is ...


2

Use the focus subsystem, as documented here. An example of detecting focus being gained: //Make textField get the focus whenever frame is activated. frame.addWindowFocusListener(new WindowAdapter() { public void windowGainedFocus(WindowEvent e) { textField.requestFocusInWindow(); } });


2

Smooth movement can be achieved in a number of ways. And it really depends on what kind of movement you want to allow. Movement still restricted to tiles. This type is the easiest for doing things like collision detection and other movement checks. For this type of movement you'll simply be interpolating the position over time as you transition between ...


1

If you want to use swing, you have to run it on the EDT, so option wouldn't work. As you mentioned any long-running stuff should'nt be on the EDT and any minecraft-like game would be pretty intensive so that makes option 3 the best one. Just make sure that everything in the logic thread is threadsafe and that you use invokeLater() to do anything on the ...


1

Take a look at BufferStrategy, it's the preferred way to use multibuffering for java 2d, - and it works like a charm. Searching google for examples on how to use it should be straightforward :)


1

Pixel-pushing speeds are a known limitation of Java's out-of-box software renderer. Even with GPU hardware rendering, built for pushing pixels, overdraw / pixel blending / fill rates are known to have profound impacts on performance. Nevertheless, this is one of the reasons we have GPUs. If it's mission critical, I suggest a low-level library that provides ...


1

First of all you should use paintComponent instead of paint (paint method is used by Swing it self. Avoid it in application code.) So first of all refactor the method of Pong this way: public void paintComponent(Graphics g) { super.paintComponent(g); .... } Moreover, the way you are trying to use thread is not correct and safe, at least for a ...


1

Firstly, You may want to check google for basic tutorials. To make your class appear and work as expected, we first need to set it's size. You would do so with YourClass.setSize(x-dimension, y-dimension). Then, if you want it to close properly, you need to use YourClass.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE). This allows the frame to close and ...


1

The "best" way is a little too subjective to tell. In my case, I've built an UI library myself, from Panels and Buttons to Lists. I use Java with lwjgl and Slick2D to make my games. If you don't want to build an UI from scratch, here are some Java libraries you can use. Tiny SUI: https://code.google.com/p/tinysui/ Nifty: http://nifty-gui.lessvoid.com/ ...


1

When you want the current standard method to build a game engine then I have to disappoint you: there is no such thing. The reason why you see so many "best ways" is that there is no such thing as a best way to program a game. There are countless ways to skin the cat. Some are faster or slower, some are cleaner or messier. In the end every game plays ...


1

The question is somewhat contradictory. First of all, if you want make game, even very simple you should use libaries that help you in that task. Otherwise you are just unreasonably making things hard for youself and simultaneously losing time (eventually you will be forced to use some kind of library or engine anyway). So if you think that using libraries ...


1

I found these youtube tutorial series to be very informative: http://www.youtube.com/playlist?list=PL656DADE0DA25ADBB http://www.youtube.com/playlist?list=PLlrATfBNZ98eOOCk2fOFg7Qg5yoQfFAdf http://www.youtube.com/show/java2dgameenginedevelopment


1

This answers the main question: "So my question really is how would I be able to stick OpenGL (I would like OpenAL and maybe OpenCL too) in a single jar and nothing else?" You may choose to place all the JogAmp JOGL 2.0 JARs inside your main JAR when you export your application using Eclipse. Use the "Package required libraries into generated JAR" in the ...


1

No. Swing components wont render nicely in custom drawing. Actually the layout manager stores the coordinates of the object (component) and renders it by translating the graphics object. When in custom rendering, you do @Override public void paintComponent(Graphics g){ super.paintComponent(g); // Original graphics } This overwrites the original ...


1

From Java Passive vs. Active Rendering instructions: If you use lightweight components, such as Swing components, you may have to fiddle with them a bit so that they draw using your Graphics, and not directly as a result of calling the paint method. Feel free to call Swing methods such as paintComponents, paintComponent, paintBorder, and ...



Only top voted, non community-wiki answers of a minimum length are eligible