Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
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  
  GUI for active rendering in Java2D  (Read 5313 times)
0 Members and 1 Guest are viewing this topic.
Offline kaffiene
« Posted 2012-11-29 01:53:23 »

I wrote a basic little artillery game in Java2D which runs well and looks pretty good.  Then I went to add some GUI elements to it.  Swing doesn't really work under active rendering.  Does anyone know of any good GUI toolkits that will work with active rendering?

Not the end of the world if there's nothing available - I'll just convert the code to libgdx or lwjgl.  That said, it runs great now so I'd like to avoid rearchitecting unless I absolutely have to.
Offline namrog84

JGO Ninja

Medals: 46
Projects: 4

Keep programming!

« Reply #1 - Posted 2012-11-29 02:03:37 »

I think a lot of times people have the main application utilize the standard swing GUI elements and such, or whatever standard toolkit of your choice

and then have an embedded`panel` in the screen, which utilizes active rendering.

"Experience is what you get when you did not get what you wanted"
Offline ra4king

JGO Kernel

Medals: 508
Projects: 3
Exp: 5 years

I'm the King!

« Reply #2 - Posted 2012-11-29 06:14:50 »

Nope none that I know of. Back when I used to use Java2D, I simply created my own GUI "framework" that just consisted of a Button, Label, and Slider with update and render methods.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline kaffiene
« Reply #3 - Posted 2012-11-29 07:18:01 »

that's what I started doing before I figured it wasn't the best use of my time :o)
Offline davedes
« Reply #4 - Posted 2012-11-29 07:29:57 »

Java2D isn't the best use of your time... Undecided

Offline kaffiene
« Reply #5 - Posted 2012-11-29 20:16:10 »

Java2D isn't the best use of your time... Undecided

My game is looking good and running at hundred to thousands of frames per second.  There's nothing wrong with Java2D for the right kind of game.
Offline theagentd
« Reply #6 - Posted 2012-11-29 21:20:47 »

There's nothing wrong with Java2D for the right kind of game on the right kind of computers.


Offline CaptainJester

JGO Knight

Medals: 12
Projects: 2
Exp: 14 years

Make it work; make it better.

« Reply #7 - Posted 2012-11-29 22:51:33 »

namrog84's suggestion is the way to go. Use a standard JFrame with normal Swing components and put your active rendered code on a panel by itself.

Offline noblemaster

« JGO Spiffy Duke »

Medals: 35
Projects: 11

Age of Conquest makes your day!

« Reply #8 - Posted 2012-11-30 03:24:07 »

You can tell Swing to do active rendering (although the article is in the "fullscreen" section, it works under windowed mode too!):

Here is how to disable passive rendering:
Use the setIgnoreRepaint method on your application window and components to turn off all paint events dispatched from the operating system completely, since these may be called during inappropriate times, or worse, end up calling paint, which can lead to race conditions between the AWT event thread and your rendering loop.

Offline kaffiene
« Reply #9 - Posted 2012-12-01 13:09:10 »

Thanks for the suggestions, guys.

I decided not to go for the idea of having the active rendered content on another panel - that doesn't work for my design.

@noblemaster: yeah, I've read that stuff already: it doesn't work, or at least it didn't for me.

I've gone with refactoring the code into LWJGL code, rather than compromising the design.  It's been pretty easy: I just set the viewport upside down and the coordinates are all the same as the Java2d version so the code is happy.
Pages: [1]
  ignore  |  Print  

EgonOlsen (79 views)
2018-06-10 19:43:48

EgonOlsen (59 views)
2018-06-10 19:43:44

EgonOlsen (78 views)
2018-06-10 19:43:20

DesertCoockie (261 views)
2018-05-13 18:23:11

nelsongames (159 views)
2018-04-24 18:15:36

nelsongames (158 views)
2018-04-24 18:14:32

ivj94 (901 views)
2018-03-24 14:47:39

ivj94 (162 views)
2018-03-24 14:46:31

ivj94 (813 views)
2018-03-24 14:43:53

Solater (177 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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‑
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!