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  
  Writing Java2D BufferedImage Data to Opengl Texture Buffer  (Read 4554 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: 520

« 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:

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.

Pages: [1]
  ignore  |  Print  

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

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

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

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

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

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

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

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

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

Solater (143 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!