Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A quick demo of JavaFX PixelBuffer inside an FXGL environment

License

NotificationsYou must be signed in to change notification settings

AlmasB/FXGL-FastRender

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A quick demo of various approaches of rendering a single pixel (fillRect(x, y, 1, 1)) inside anFXGL environment. There are not many online resources that are easily available to refer to when it comes to JavaFX drawing performance. Hence, the aim of this demo is to help identify the fastest practical approach to draw a bunch of unrelated pixels (e.g. particles), specifically in JavaFX.

Note that the approaches are not tested directly (e.g. testing if callingmethod1() is faster than callingmethod2()). Hence, approaches likeCanvas.fillRect() are at a natural disadvantage as they do not support multi-threading and therefore we can see a poor result fromCanvasTestApp.

It should also be noted that the results below are just a single pass (no comprehensive statistics applied) and they are only for illustrative purposes. Depending on the actual use case (e.g.drawImage() ordrawPolygon()), the results of these approaches might differ.

Finally, if you spot an error in implementation or have suggestions on how to improve performance, contributions are welcome.

promo

Run

mvn javafx:run

CPU-based sample tests (how long it took to compute a frame in ms) - 1M particles

  • CanvasTestApp

Note: can only run in 1 thread due to Canvas limitations.

Avg: 68.7463457Min: 59.0025Max: 106.2289
  • CanvasIntBufferTestApp

Note: using its int buffer for speedand having high-level API makes this the most desirable approach.

Avg: 10.3398753Min: 8.0649Max: 23.9596
  • PixelBufferTestApp

Note: there seem to be some flickering issues if fps is low. In addition, no high-level API.

Avg: 10.5120373Min: 7.818Max: 21.9998
  • AWTImageTestApp

Note: better performance than high-level Canvas but slower than Canvas with IntBuffer.

Avg: 45.6501834Min: 41.524Max: 78.3333

GPU-based Sample Tests - 10M particles

  • PixelBufferGPUTest

(GPU needs to support OpenCL 1.2 / 2 and have appropriate drivers installed).

Note: we can see that with GPU we can run 10M particles and still beat CPU at 1M.

Avg: 8.81632675Min: 6.1725Max: 11.0581

About

A quick demo of JavaFX PixelBuffer inside an FXGL environment

Resources

License

Stars

Watchers

Forks

Languages


[8]ページ先頭

©2009-2025 Movatter.jp