1

does java Graphics or Graphics2D class uses graphics card? I am trying to draw a ton of things inside paintComponent() method in my JPanel, and I'm scared that it might take longer than it should.

Victor2748
  • 4,149
  • 13
  • 52
  • 89
  • I don't believe it does (not it any real way anyway) But don't worry about that until it becomes an issue; it probably never will (unless you're doing 3D). Likelyhood is that if you get an issue it will be the logic not the actual draw calls – Richard Tingle Jun 09 '14 at 22:18
  • There's some info [here](http://www.oracle.com/technetwork/java/index-137037.html#Q_What_kinds_of_graphics_hardwar) and [here](http://www.javalobby.org/forums/thread.jspa?threadID=16840&tstart=0) on hardware accelerated Java 2D – DNA Jun 09 '14 at 22:27
  • @drewmore for 3D applications you can use an openGL binding (e.g. JMonkey) which will very much be on the GPU. Graphics2D may pass the finished image to a graphics card (I'm not sure) but I wouldn't really count that as running on the graphics card – Richard Tingle Jun 09 '14 at 22:28
  • See also https://stackoverflow.com/questions/4627320/java-hardware-acceleration – DNA Jun 09 '14 at 22:29
  • @drewmore your revision comment is also very misleading bordering on incorrect, you should probably remove that also – user1231232141214124 Jun 09 '14 at 22:29
  • @redFIVE yeah, I'm gonna quit while I'm behind on this one – drew moore Jun 09 '14 at 22:29
  • 2
    The actual pipeline use is OS and JVM specific. Swing uses a double buffering approach, so when using `paintComponent`, it's not likely that you are painting directly to the screen device. At some point after the call to your paint methods, the JVM will push the result to the graphics library in use (DirectX or OpenGL) and that will then interact with the hardware through what ever means it has available. I've renderer 10, 000 rotating images at 25fps through this process before, so unless you're doing silly things (loading images/resources), it should be okay – MadProgrammer Jun 10 '14 at 00:30

0 Answers0