LWJGL / lwjgl3

LWJGL is a Java library that enables cross-platform access to popular native APIs useful in the development of graphics (OpenGL, Vulkan, bgfx), audio (OpenAL, Opus), parallel computing (OpenCL, CUDA) and XR (OpenVR, LibOVR, OpenXR) applications.
https://www.lwjgl.org
BSD 3-Clause "New" or "Revised" License
4.83k stars 642 forks source link

The most simplest opengl texture drawing will not work. #1015

Closed goofyseeker311 closed 3 weeks ago

goofyseeker311 commented 3 weeks ago

Question

The opengl window shows up normally and otherwise its working. even the triangles are drawn with the color, but not with the texture data. graphicsbuffer is an int[] buffer with working int8888 data.

What would be the problem. also fbo's blitting did not seem to work either with same data. if its about the core profile missing functions then why does GL46 include any pointers to missing deprecated code.

while(!GLFW.glfwWindowShouldClose(window)) {
    GL46.glClear(GL46.GL_COLOR_BUFFER_BIT | GL46.GL_DEPTH_BUFFER_BIT);

    GL46.glColor3f(0.0f, 0.0f, 1.0f);
    GL46.glTexImage2D(GL46.GL_TEXTURE_2D, 0, GL46.GL_RGBA8, graphicswidth, graphicsheight, 0, GL46.GL_RGBA, GL46.GL_UNSIGNED_INT_8_8_8_8, graphicsbuffer);
    GL46.glBindTexture(GL46.GL_TEXTURE_2D, 0);

    GL46.glEnable(GL46.GL_TEXTURE_2D);

    GL46.glBegin(GL46.GL_TRIANGLE_STRIP);
    GL46.glTexCoord2f(1.0f, 0.0f); GL46.glVertex2f(1.0f, -1.0f);
    GL46.glTexCoord2f(1.0f, 1.0f); GL46.glVertex2f(1.0f, 1.0f);
    GL46.glTexCoord2f(0.0f, 0.0f); GL46.glVertex2f(-1.0f, -1.0f);
    GL46.glTexCoord2f(0.0f, 1.0f); GL46.glVertex2f(-1.0f, 1.0f);
    GL46.glEnd();
    GL46.glFlush();

    GLFW.glfwSwapBuffers(window);
    GLFW.glfwPollEvents();
}
goofyseeker311 commented 3 weeks ago

Self-answer: if you change TEXTURE_2D to TEXTURE_RECTANGLE in both the TexImage2D() function and the glEnable() function, then it will work. but the TEXTURE_2D will not work.

edit: just putting the TexImage2D() function to TEXTURE_RECTANGLE instead of TEXTURE_2D works also.

liskar-dev commented 3 weeks ago

Please learn how to use modern OpenGL before creating issues. https://learnopengl.com/ should help you

goofyseeker311 commented 3 weeks ago

issues and especially questions are just for questions eh. you actually want the opposite. no questions. thanks. the original issue I posted should work without questions. opengl seems to be a bit shaky in the implementation robustness. maybe I dont need to learn it. I rather do OpenCL instead. opengl was just to copy the opencl image buffer faster to the system display, gpu. keep your opengl mate.

in other words: no. you dont want to help, but only to obstruct. already figured out the issue on my own. sorry for bothering you.