Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (736)
Games in Android Showcase (223)
games submitted by our members
Games in WIP (813)
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  
  Writing Java2D BufferedImage Data to Opengl Texture Buffer  (Read 1077 times)
0 Members and 1 Guest are viewing this topic.
Offline otoomey

Junior Newbie


Exp: 5 years



« Posted 2017-08-19 15:00:49 »

I am writing a hud for a project, and because I want to do some complex drawing I want to use a powerful 2D rendering library (like Java2D). My idea is to draw into the BufferedImage whenever the UI needs to update, then take the pixel data from the bufferedimage and bind it into an OpenGL texture buffer. I can then draw the texture on top of my game every frame.

Am I insane? -> yes. But is it really crazier then drawing 2D stuff in OpenGL?

The part that I need help with specifically is transferring the bufferedimage data into the texture buffer. I am using LWJGL.
Offline KaiHH

JGO Kernel


Medals: 442



« Reply #1 - Posted 2017-08-19 21:19:10 »

AWT (i.e. Java2D) can interfere with LWJGL/GLFW when you use non-headless features of it (like creating a Window/drawable/container), since they both want to read the window thread's message queue for window message events.
Read this: http://forum.lwjgl.org/index.php?topic=6310.msg33650#msg33650

LWJGL 3 provides many alternative solutions such as for UI layouting and vector drawing with Nuklear and NanoVG.
If you want layout only then LWJGL 3 also has bindings for Facebook's Yoga library implementing the Flexbox layout. When you want to render font/text and load images then there is stb.

If you only want to look at one of them, then it should definitely be NanoVG. That also supports text rendering (via stb) and image loading (also via stb) and competes feature-wise pretty much with Java2D.
Offline theagentd
« Reply #2 - Posted 2017-08-21 02:03:28 »

Am I insane? -> yes. But is it really crazier then drawing 2D stuff in OpenGL?
Yeah, it is. OpenGL is used for 2D stuff all the time. GPUs can really only draw 2D stuff in the first place; you project your 3D triangles to 2D triangles, so it makes a lot of sense to use the GPU for accelerating 2D stuff as well.

Myomyomyo.
Pages: [1]
  ignore  |  Print  
 
 

 
cybrmynd (117 views)
2017-08-02 12:28:51

cybrmynd (139 views)
2017-08-02 12:19:43

cybrmynd (136 views)
2017-08-02 12:18:09

Sralse (152 views)
2017-07-25 17:13:48

Archive (619 views)
2017-04-27 17:45:51

buddyBro (730 views)
2017-04-05 03:38:00

CopyableCougar4 (1255 views)
2017-03-24 15:39:42

theagentd (1235 views)
2017-03-24 15:32:08

Rule (1213 views)
2017-03-19 12:43:22

Rule (1264 views)
2017-03-19 12:42:17
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

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51
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!