Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (538)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (600)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Active rendering and GUI components  (Read 1843 times)
0 Members and 1 Guest are viewing this topic.
Offline cookie

Junior Devvie


Medals: 1



« Posted 2013-06-20 11:49:46 »

Hello all,
I've read this tutorial ( http://docs.oracle.com/javase/tutorial/extra/fullscreen/rendering.html ) about active rendering, but I don't know if any GUI components can still be used in conjunction with active rendering. Can active rendering be only used in full-screen mode or also on a single component in a GUI application window?

As far as I understand, GUI components can't be used when doing active rendering, because active rendering means bypassing the OS's GUI control and give it completely to the application.

Please correct me if my understanding is wrong  Smiley
Offline RobinB

JGO Ninja


Medals: 44
Projects: 1
Exp: 3 years


Spacegame in progress


« Reply #1 - Posted 2013-06-20 13:58:35 »

This can be used on single components, but you really should not draw this way.
Active rendering just repaints the component multiple times a second.
So all events and functions would still work on this and other coponents.

However you really should NOT use this method to draw a game.
Use something with hardware accelleration, so you dont stress (and eventually max out) your cpu usage.
When you hit this limit (what happens really fast) you need to convert your code to other rendering methods anyways.
OPENGL is the way to go, using a library like LWJGL or LIBGDX will make it easyer.
Offline davedes
« Reply #2 - Posted 2013-06-20 14:33:15 »

LibGDX's GUI uses active rendering, and is built on OpenGL, so it's very fast. And it's generally much easier for game- and mobile-related purposes than Swing (i.e. theming, touch input, etc).

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline cookie

Junior Devvie


Medals: 1



« Reply #3 - Posted 2013-06-20 15:01:02 »

Thanks. I have read here http://docs.oracle.com/javase/1.5.0/docs/guide/2d/flags.html that the standard Java 2D API is also hardware accelerated, hence I don't understand why I a 3rd party library is more efficient.
Offline RobinB

JGO Ninja


Medals: 44
Projects: 1
Exp: 3 years


Spacegame in progress


« Reply #4 - Posted 2013-06-20 15:18:31 »

Because Java2D decides for its own when to do this, most of the time it uses software accelleration only.
Java2D only works for really light stuff, try rendering a big texture (1024 x 1024), it will take a lot of time in java2d.
Imagine needing to draw 20 of these images, Java2D will maybe get at 5fps, while OpenGL still draws at 1000+ fps.

Java2D is just not trustworthy when it comes to hardware accelleration.
Offline cookie

Junior Devvie


Medals: 1



« Reply #5 - Posted 2013-06-20 16:03:34 »

Thank you. So you would generally recommend to get accustomed to OpenGL, even when doing 2D games?

The docu here http://docs.oracle.com/javase/1.5.0/docs/guide/2d/new_features.html#ogl says: "J2SE 5.0 includes a new OpenGL-based pipeline for Java 2D. This pipeline provides hardware acceleration for simple rendering operations (text, images, lines, and filled primitives) as well as those that involve complex transforms, paints, composites, and clips. This pipeline is available on all platforms (Solaris, Linux, and Microsoft Windows) and is currently disabled by default. To silently enable the OpenGL-based pipeline, specify the following system property on the command line:
  -Dsun.java2d.opengl=true".


Well, that sounds like OpenGl could be explicitly enabled.


Offline RobinB

JGO Ninja


Medals: 44
Projects: 1
Exp: 3 years


Spacegame in progress


« Reply #6 - Posted 2013-06-20 16:59:48 »

Indeed, its possible to use Java2D with the opengl pipeline, but you wil still hit some limit soon enough.
Most functions just dont translate to opengl very well.
I also tryd to use Java2D as long as possible(also using this pipeline), you will really hit a wall eventually as your game expands.

If you have an really simple game with limited particles (particle engines will be really slow) Java2d will suffice.
But why stay at such an limited platform, as you get more experienced and the game grows, you will eventually use opengl anyways.
Pure opengl also has advantages like Shaders and Vertex buffers (or displaylists) wich will open a new world for you.

Also as sidenote, Opengl is not for 3D games, its for rendering anything on screen.
The librarys also provide acces to the other accellerated outputs (OpenAL for sound), (OpenCL for hardware calculations), and others

As library LibGDX is really recommended, it makes the switch from Java2D not very hard.
Offline davedes
« Reply #7 - Posted 2013-06-20 18:14:38 »

Aside from the performance; it also makes more sense to use a 3rd party game-centric library to reduce the time you spend writing boilerplate, and increase your overall productivity. For example; fonts, GUI, tiled map loading, asset loading management, and so forth. And, best of all, LibGDX will distribute to more platforms than Java2D (i.e. mobile, WebGL).

Offline RobinB

JGO Ninja


Medals: 44
Projects: 1
Exp: 3 years


Spacegame in progress


« Reply #8 - Posted 2013-06-20 20:03:08 »

I think writing your own library the first time is important for knowing whats happening under the hood.
But besides that or extreme performance tuning, there is no reason for not using an library.
Offline cookie

Junior Devvie


Medals: 1



« Reply #9 - Posted 2013-06-20 20:14:36 »

Thanks for your helpful answers :-) I learned a lot about OpenGL and computer graphics theory (midpoint algorithm, render pipeline, projections, matrix transformations and blabla...) some years ago, but I can't  work creatively with it. However, as far as I know OpenGL is nearly the same on all platforms, hence it's easy to write portable games which wouldn't be possible with an API like Java2D.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

rwatson462 (29 views)
2014-12-15 09:26:44

Mr.CodeIt (20 views)
2014-12-14 19:50:38

BurntPizza (40 views)
2014-12-09 22:41:13

BurntPizza (76 views)
2014-12-08 04:46:31

JscottyBieshaar (37 views)
2014-12-05 12:39:02

SHC (50 views)
2014-12-03 16:27:13

CopyableCougar4 (47 views)
2014-11-29 21:32:03

toopeicgaming1999 (114 views)
2014-11-26 15:22:04

toopeicgaming1999 (102 views)
2014-11-26 15:20:36

toopeicgaming1999 (30 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!