Hello Guest

Recent Posts

Pages: 1 2 [3] 4 5 ... 10
21
OpenGL / GL error 0x505 while drawing elements
« Last post by 128_bit_guy on October 30, 2019, 05:05:28 »
I get gl error 0x505 (out of memory) when drawing elements for seemingly no reason. I have a lot of free GPU memory when this happens. Eventually, aftor a lot of this errors i get this crash: https://pastebin.com/8HDkqVqj. Please help.
22
Lightweight Java Gaming Library / GL error 0x505 while drawing elements
« Last post by 128_bit_guy on October 30, 2019, 05:01:29 »
I get gl error 0x505 (out of memory) when drawing elements for seemingly no reason. I have a lot of free GPU memory when this happens. Eventually, aftor a lot of this errors i get this crash: https://pastebin.com/8HDkqVqj. Please help.
23
OpenGL / Access violation exception by glTexImage2D
« Last post by True_han on October 25, 2019, 21:45:04 »
I'm trying to make a font renderer (using java.awt) but getting error uploading texture. The texture constructor for fonts:
Code: [Select]
public Texture(ByteBuffer image, int width, int height) {
    this.id = glGenTextures();

    glBindTexture(GL_TEXTURE_2D, this.id);

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image);
    glGenerateMipmap(GL_TEXTURE_2D);
  }

Font renderer code (method of my Font class):
Code: [Select]
  public IObject getStringAsObject(String string, Vector3f position) {
    Rectangle2D rect = this.fontAWT.getStringBounds(string, context);

    this.gfx.dispose();

    this.image = new BufferedImage(
      (int) Math.ceil(rect.getWidth()),
      (int) Math.ceil(rect.getHeight()),
      BufferedImage.TYPE_4BYTE_ABGR
    );

    this.gfx = image.getGraphics();

    this.gfx.setColor(this.color);
    this.gfx.setFont(this.fontAWT);
    this.gfx.drawString(string, 0, this.gfx.getFontMetrics().getAscent());
    this.gfx.dispose();

    byte[] pixelData = ((DataBufferByte) this.image.getRaster().getDataBuffer()).getData();
    byte[] pixelDataRGBA = pixelData;

    assert pixelData.length % 4 != 0;

    for(int i = 0; i < pixelData.length; i += 4) {
      pixelDataRGBA[i] = pixelData[i + 3]; // r1 / r4
      pixelDataRGBA[i + 1] = pixelData[i + 2]; // g2 / g3
      pixelDataRGBA[i + 2] = pixelData[i + 1]; // b3 / b2
      pixelDataRGBA[i + 3] = pixelData[i]; // a4 / a1
    }

    System.out.println(Arrays.toString(pixelDataRGBA));
    System.out.println(pixelDataRGBA.length == image.getWidth() * image.getHeight() * 4); // true so opengl doesn't have to break

    SimpleObject object = new SimpleObject(
      position,
      new Texture(ByteBuffer.wrap(pixelDataRGBA), image.getWidth(), image.getHeight()),
      new Vertex[] {
        new Vertex(0, 0, 0, 0, 1), // 1 triangle
        new Vertex(0, (float) rect.getHeight(), 0, 0, 0),
        new Vertex((float) rect.getWidth(), (float) rect.getHeight(), 0, 1, 0),
        new Vertex(0, 0, 0, 0, 1), // 2 triangle
        new Vertex((float) rect.getWidth(), 0, 0, 1, 1),
        new Vertex((float) rect.getWidth(), (float) rect.getHeight(), 0, 1, 0)
      }
    );

    object.model.scale(0.01f);

    return object;
  }
I should flip ABGR to RGBA to get colors that OpenGL can read.
And also I have this part of code:
Code: [Select]
System.out.println(pixelDataRGBA.length == image.getWidth() * image.getHeight() * 4); It prints true.
IObject and SimpleObject are made by me.

Can anyone help me? EXCEPTION_ACCESS_VIOLATION (0xc0000005) at org.lwjgl.opengl.GL11C.nglTexImage2D(IIIIIIIIJ)V+0
24
Bug Reports / RFE / Re: NanoVG nvgImagePattern draws at wrong position on OSX?
« Last post by mudlee on October 24, 2019, 10:18:05 »
OK, after digging more into the code, the problem is somewhere in my code, with the screen resolution.
25
Bug Reports / RFE / NanoVG nvgImagePattern draws at wrong position on OSX?
« Last post by mudlee on October 23, 2019, 18:46:18 »
First time (yes, really) that I'm trying to draw an image with nanovg. It works perfect on simple HD and 4K monitor on Linux, but on OSX (macbook pro with retina screen) the image's position is incorrect.

I'm drawing a simple png with a cursor at the mouse's position. Top-left (0,0) is correct but as soon as I go to let's say bottom-right, the diff between the cursor's real position and the png's position is like quadratic (when the real cursor at the bottom rigth, the png is somewhere 1/4 from the top left). Am I missing something?

Code:
Code: [Select]
float x = image.getPosition().getLeft();
float y = image.getPosition().getTop();

int imageID = nvglCreateImageFromHandle(pointer, image.getTextureId(), width, height, 0);
NVGPaint paint = NVGPaint.create();
nvgImagePattern(pointer, x, y, width, height, 0, imageID, 1f, paint);
nvgBeginPath(pointer);
nvgRect(pointer, x, y, width, height);
nvgFillPaint(pointer, paint);
nvgFill(pointer);
26
OpenGL / eglCreatePBufferSurface returns EGL_BAD_CONFIG
« Last post by kyasbal on October 16, 2019, 09:33:30 »
Hi, I'm trying to use EGL to render several images on a headless server.
I initialized EGL egl surface to create eglContext with the following code.  (This code is written by Kotlin)

Code: [Select]
   
    val display = eglGetDisplay(EGL_DEFAULT_DISPLAY)
    if(display == EGL_NO_DISPLAY){
        error("Failed to eglGetDisplay")
    }
    val major = stack.mallocInt(1)
    val minor = stack.mallocInt(1)
    val eglStatus = eglInitialize(display,major,minor)
    if(!eglStatus){
        error("Failed to eglInitialize")
    }

    val eglConfigs = stack.ints(
        EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
        EGL_BLUE_SIZE, 8,
        EGL_GREEN_SIZE, 8,
        EGL_RED_SIZE, 8,
        EGL_DEPTH_SIZE, 8,
        EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
        EGL_NONE)
    val pBufferAttribs = stack.ints(EGL_WIDTH,8, EGL_HEIGHT,8, EGL_NONE)
    val numConfig = stack.mallocInt(1)
    check(
        eglChooseConfig(
            display,
            eglConfigs,
            null,
            numConfig
        )
    ) { String.format("eglChooseConfig failed [0x%X]", eglGetError()) }

    val configs = stack.mallocPointer(numConfig[0])
    val numConfig2 = stack.mallocInt(1)
    check(eglChooseConfig(display, eglConfigs, configs, numConfig2)){
        error("Failed to choose config with EGL")
    }
    val eglSurf = eglCreatePbufferSurface(display,configs.address(),pBufferAttribs)
    if(eglSurf == EGL_NO_SURFACE){   
val display = eglGetDisplay(EGL_DEFAULT_DISPLAY)
    if(display == EGL_NO_DISPLAY){
        error("Failed to eglGetDisplay")
    }
    val major = stack.mallocInt(1)
    val minor = stack.mallocInt(1)
    val eglStatus = eglInitialize(display,major,minor)
    if(!eglStatus){
        error("Failed to eglInitialize")
    }

    val eglConfigs = stack.ints(
        EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
        EGL_BLUE_SIZE, 8,
        EGL_GREEN_SIZE, 8,
        EGL_RED_SIZE, 8,
        EGL_DEPTH_SIZE, 8,
        EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
        EGL_NONE)
    val pBufferAttribs = stack.ints(EGL_WIDTH,8, EGL_HEIGHT,8, EGL_NONE)
    val numConfig = stack.mallocInt(1)
    if(!eglChooseConfig(
            display,
            eglConfigs,
            null,
            numConfig
        )
    ) { String.format("eglChooseConfig failed [0x%X]", eglGetError()) }

    val configs = stack.mallocPointer(numConfig[0])
    val numConfig2 = stack.mallocInt(1)
    if(!eglChooseConfig(display, eglConfigs, configs, numConfig2)){
        error("Failed to choose config with EGL")
    }
    val eglSurf = eglCreatePbufferSurface(display,configs.address(),pBufferAttribs)
    if(eglSurf == EGL_NO_SURFACE){
        error("Failed to initialize surface" + eglGetError())
    }

Even each eglChooseConfig returns true, eglCreatePbufferSurface returns EGL_NO_SURFACE with the error of EGL_BAD_CONFIG.
I wonder that should mean the returned egl config from eglChooseConfig is wrong.  How can I correct my code to use LWJGL?
27
Thanks !
28
I'm sorry, forgot to reply to this. Looks like it's a known issue: stb#787. For now, you can safely ignore the error message, as long as you get a non-NULL result.
29
Lightweight Java Gaming Library / Trouble using Assimp.
« Last post by Kneesnap on October 13, 2019, 21:18:20 »
I'm trying to write some code to generate a 3D model, and save that model.
At this point, I just want to write something that can make a single face, or a cube, or something simple.

This code, however, crashes the JVM, and I'm not entirely sure why.
I'm new to LWJGL, so it is very likely I am using it wrong.

Could someone help me turn this code into something which will create and save a basic 3D model?
Thanks for the help!

Code: [Select]
public static void exportModel(File outputFile) {
    AIScene scene = AIScene.create();
    scene.mMeshes(PointerBuffer.allocateDirect(1));
    AIMesh mesh = AIMesh.create(scene.mMeshes().get(0));
    scene.mMeshes().put(mesh.address());
   
    mesh.mNumVertices(3);
    mesh.mVertices().put(0, AIVector3D.create().x(0).y(0).z(0)); // THIS CRASHES THE JVM.
    .......
    Assimp.aiExportScene(scene, "dae", outputFile.getPath(), 0);
}
30
Bug Reports / RFE / Re: New crash on MacOS with LWJGL2
« Last post by princec on October 10, 2019, 12:43:06 »
I would do except this is old code and I'd really rather not ever see it ever again as it doesn't make me any money...

Cas :)
Pages: 1 2 [3] 4 5 ... 10