Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (804)
Games in Android Showcase (239)
games submitted by our members
Games in WIP (868)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 2 [3]
  ignore  |  Print  
  Threads, games and running on all CPU's  (Read 20238 times)
0 Members and 1 Guest are viewing this topic.
Offline nsigma
« Reply #60 - Posted 2015-09-25 11:14:33 »

RE: here is the line in your init method...
this.og = this.OffscreenImage.getGraphics();
right after you create a BufferedImage for OffscreenImage ... It's not clear at which point, re: JDK 6/7/8, BufferedImages get accelerated more or what exactly is the promotion strategy or how translucent images are handled.

 Emo

You've kind of side-stepped the point there - that graphics object is not, never was and never will be accelerated!  It would break the BufferedImage API.  That offscreen image needs to be a VolatileImage if you want to speed up rendering to it.

And if you're drawing into a BufferedImage every frame, then it's never going to be promoted to a managed image either because you're constantly invalidating any cached copy.

Praxis LIVE - hybrid visual IDE for (live) creative coding
Offline Catharsis

JGO Ninja


Medals: 76
Projects: 1
Exp: 21 years


TyphonRT rocks!


« Reply #61 - Posted 2015-09-25 12:58:01 »

You've kind of side-stepped the point there - that graphics object is not, never was and never will be accelerated!  It would break the BufferedImage API.  That offscreen image needs to be a VolatileImage if you want to speed up rendering to it.

I know... ;P I probably could have added a paragraph break in there somewhere. I'm advocating going all in with the VolatileImage API as it's not too hard to support it and be absolutely certain things are accelerated.

@mike_bike_kite
When you move over to the VolatileImage API just implement the loading first as found in the tutorial (Code Example 5 / loadFromFile) and when making the OffscreenImage use createVolatileImage instead.  Once you verify that things are working then figure out a way to do any stale image verification in your render loop.

For classpath stuff...

Try this...
javac -cp ".;tinysound-1.1.1.jar" neptune.java
jar -cfm neptune.jar Manifest.txt *.class *.png *.wav

java -cp ".;tinysound-1.1.1.jar" -jar neptune.jar
or
java -cp ".;neptune.jar;tinysound-1.1.1.jar" neptune

------

BTW as Cas and nSigma mentioned you don't need "-Dsun.java2d.noddraw=true". It actually crashes / prevents your game for running on my Windows box. I just get a white screen with this error:

Exception in thread "main" java.lang.InternalError: Could not set display mode
        at sun.awt.Win32GraphicsDevice.configDisplayMode(Native Method)
        at sun.awt.Win32GraphicsDevice.setDisplayMode(Unknown Source)
        at test.main(test.java:418)

So something might be particularly wrong with your dev box.

Check out the TyphonRT Video Suite:
http://www.typhonvideo.com/

Founder & Principal Architect; TyphonRT, Inc.
http://www.typhonrt.org/
http://www.egrsoftware.com/
https://plus.google.com/u/0/+MichaelLeahy/
Offline mike_bike_kite
« Reply #62 - Posted 2015-09-27 19:49:03 »

This has all been very helpful to me. Things I've learnt so far have been:
  • Do not create anything in the draw routines ie (new Color, new int[10] etc).
  • Fewer calls to draw routines the better - a single fillPolygon is much better than multiple smaller polygons.
  • Get as much processing out the draw loops as possible - the single call above meant I could build the polygon array elsewhere.
  • The standard java sound is useless for gaming. I quite liked TinySound when I tried it.

The end result is my game now runs smoothly on my cheap chromebook (converted to Linux) using only 25% CPU which is better than I expected. The threads I now need for the game are just the main game thread and one to handle IO from the web for high scores etc. I currently don't need to speed the game up any more but I will look into using BufferedImages or VolatileImages. A few small questions remain though:

How do I change the volume or pan left to right with TinySound?

I currently call pain in my main run loop and record FPS as well as number of moves (of creatures/sea etc) per second (MPS). I limit the MPS to 30 to make the game playable but obviously with
my set up I also get 30 FPS as well. It's not an issue for me but I was curious how you limit the number of moves but allow the FPS to climb on faster machines?

So far there seems to be lots of ways of calling the program to get it to work. I need the nodraw option otherwise I'm met with a blank screen but others don't. If the user is on Linux then the java commands need to have a colons rather than semi colons in the path. Should I include a bat file (or many files) to run on Windows and a sh file to run on Linux?

I looked into JavaFX and some of it's features are neat but perhaps a little complex (30 lines to say hello world!!) but I'll try to persevere. It's big advantage to me though is being able to produce an executable so I'll continue to look into this.

I've uploaded the latest version to the web page now.

Mike

PS Has anybody actually played the game?

Arcade swarm
Board Chess - Checkers - Othello
Pages: 1 2 [3]
  ignore  |  Print  
 
 

 
Riven (579 views)
2019-09-04 15:33:17

hadezbladez (5504 views)
2018-11-16 13:46:03

hadezbladez (2398 views)
2018-11-16 13:41:33

hadezbladez (5766 views)
2018-11-16 13:35:35

hadezbladez (1220 views)
2018-11-16 13:32:03

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

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

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

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

nelsongames (5114 views)
2018-04-24 18:15:36
A NON-ideal modular configuration for Eclipse with JavaFX
by philfrei
2019-12-19 19:35:12

Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08
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!