Hello Guest

Recent Posts

Pages: 1 ... 8 9 [10]
Lightweight Java Gaming Library / Re: Simple Question
« Last post by Swedberg on June 12, 2020, 06:23:13 »
I'm a student from Austria (studying Game Engineering and Simulation Technology at Fachhochschule Technikum Wien) and I need to write a 3D game for a student's contest. Can I use the LWJGL 3 library for this and what about the license? Thank you.

OpenGL / Re: Blending question
« Last post by Aisaaax on June 10, 2020, 11:56:13 »
So, there really is no other way than rendering to texture and putting it on a quad in front of the screen?

I am a bit hesitant about doing two render passes like that, as I am working with ARM device that isn't really performant.

Is there a way to access current frameBuffer and make all fragments have alpha of 1? So that I could render part of the image, change alpha and then render the rest?
OpenGL / Re: Blending question
« Last post by KaiHH on June 10, 2020, 10:42:30 »
You need to composite the objects from group A and the objects from group B separately in a full-screen render pass.
So, if you don't need objects from group A to depth-sort with objects from group B (so only correctly depth-sort objects within a single group) and you want group A to overlay over group B transparently, then:
1. render group B to the final render target first with opaque blending (i.e. no blending)
2. render group A to a temporary render target (i.e. render to texture, also without blending)
3. do a full-screen pass (render a full-screen triangle or quad) sampling from the render target of step 2 and applying blending
OpenGL / Blending question
« Last post by Aisaaax on June 10, 2020, 09:47:26 »

I have a specific task where I need to render a bunch of entities that can overlap a bit, and then I need the resulting figure to be transparently rendered on top of a bunch of other entities.
But I don't want entities within those two layers to be transparent in relation to each other.

I.e. Objects A, B, C are rendered together, they are not transparent towards each other and cover each other

Objects D, E, F and on the other layer, the same deal - they are not transparent to each other

But then Group A is overlayed over group B, and it is transparent.

Is rendering to texture the only way to do that?

One other question: I am currenly using
glBlendFunc(ONE_MINUS_DST_ALPHA, GL_ONE) to basically render the object "underneath" whatever is already in the frame buffer.
But if the contents of frame buffer have alpha below 1, the results are blended - i.e. transparency is applied.

Can I somehow make it not render the fragments AT ALL, if there's something already in the buffer?

Basically what I want is
glBlendFunc (SRC_ALPHA > 0 ? GL_ZERO : GL_ONE, GL_ONE)
Lightweight Java Gaming Library / Re: Screenshots using GPU.
« Last post by abcdef on June 09, 2020, 12:38:02 »
Sounds like a fun project!

LWJGL needs you to create a window (using GLFW) and that is the window context you have access to. I don't believe you can get access to the screen as a whole.
Lightweight Java Gaming Library / Re: I can't seem to find docs for imgui
« Last post by sp on June 02, 2020, 09:44:53 »
Dear ImGui binding for Java with renderer for LWJGL: https://github.com/SpaiR/imgui-java
OpenGL / Resetting context but keeping the data
« Last post by Aisaaax on June 01, 2020, 05:32:08 »
Is it possible to re-create context but keep the VAO/VBO's?

In my application, sometimes the window (surface) to which I render gets hidden completely. When it gets shown again - the surface ID changes, and I can't keep rendering to it with the context that I had before.

My solution is to close the context completely as soon as the surface gets hidden, and then create a new one when it gets re-opened.

The problem here is lots of data that I don't necessarily want to re-create. For example I have to triangulate shapes that are calculated in a different part of the program, and that work is quite CPU-intensive. Maybe I could instead just keep the previous VBO and use it? But all attempts have given me no success.

Maybe I'm missing something? Or maybe I can even do away with closing the context (again, I didn't find a solution).

It works as is, but I feel that it's sub-optimal.

Thank you!
Lightweight Java Gaming Library / Re: Loading texture arrays crashes the JVM
« Last post by Zeno on May 30, 2020, 19:57:00 »
You are using width=size[0] and height=size[1] which is probably fine, but then you are telling OpenGL that the depth=index.

Ah so I'm misinterpreting that third size component? The way I understood it, it refers to the index of the given sprite in the texture array. But when I read the documentation again, it seems to refer to the total amount of sprites that you are trying to load, is this correct? So to be fully clear, my line would have to look as follows

Code: [Select]
GL45.glTextureSubImage3D(ID(), lod, 0, 0, index, size[0], size[1], 1, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, data);
As an aside, I'm assuming this also means you can load multiple sprites through one call, and appropriately changing that '1' into however many sprites are stored in your data buffer? How would this data then have to be laid out? I assume the sprites cannot be interleaved, they would have to be stored in the buffer sequentially?
Lightweight Java Gaming Library / Re: Loading texture arrays crashes the JVM
« Last post by KaiHH on May 30, 2020, 18:51:33 »
Code: [Select]
glTextureSubImage3D(ID(), lod, 0, 0, 0, size[0], size[1], index, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, data);
makes no sense. Please look at the definition of this function again: https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glTexSubImage3D.xhtml
You are using width=size[0] and height=size[1] which is probably fine, but then you are telling OpenGL that the depth=index. So, later indexes will upload an always bigger and bigger sub-texture. This is wrong. Your slices all have the same size 128x128x1 (w x h x d). You should use index as the zoffset parameter instead.
Lightweight Java Gaming Library / Loading texture arrays crashes the JVM
« Last post by Zeno on May 30, 2020, 16:47:23 »
Hello everybody!

I've recently decided to switch out my single-texture sprite sheets with the use of texture arrays. I cannot seem to get this to work as the JVM crashes in the middle of loading the images. I have 12 images of size 128x128 that I loop over and load with the glTextureSubImage3D command, the relevant code is given below. My code loops over the load method 12 times, and you can see I print some text to the console. The end result is that the JVM crashes after finishing a handful (between 6 and 8 images) of these methods, and failing to do the next one. Am I actually using the TextureSubImage method right? Is this perhaps not a method you can use repeatedly in quick succession? I've also added a crash log, see here. This was run through LWJGL 3.2.3. Thanks in advance for any help!

Code: [Select]
private void initialize(int lod, int count, int... size)
case 1:
GL45.glTextureStorage2D(ID(), lod, GL11.GL_RGBA8, size[0], count); break;
case 2:
GL45.glTextureStorage3D(ID(), lod, GL11.GL_RGBA8, size[0], size[1], count); break;

public void load(ByteBuffer data, int lod, int index, int... size)
System.out.print("Loading " + lod + ":" + index + ":" + size[0] + ":" + size[1] + ":" + data.remaining() + ":");
case 1:
GL45.glTextureSubImage2D(ID(), lod, 0, 0, size[0], index, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, data); break;
case 2:
GL45.glTextureSubImage3D(ID(), lod, 0, 0, 0, size[0], size[1], index, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, data); break;

public void load(Image image, int lod, int index)
int w = image.Width(); int h = image.Height();
byte[] data = ((DataBufferByte) image.Raster().getDataBuffer()).getData();
ByteBuffer buffer = BufferUtils.createByteBuffer(data.length);
load(buffer.put(data).flip(), lod, index, w, h);
Pages: 1 ... 8 9 [10]