Posted February 25, 20223 yr I want to render image from server so I'm going to use glTexImage2D for render the image. This is my code for GUI screen in 1.16.5 int texture = -1; void initializeGl() { texture = glGenTextures(); glBindTexture(GL_TEXTURE_2D, texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, myImagePixelArray); glBindTexture(GL_TEXTURE_2D, 0); } @override void render(MatrixStack mat, int mouseX, int mouseY, float partialTicks) { if(texture == -1) initializeGl(); glBindTexture(GL_TEXTURE_2D, texture); RenderUtil.renderRect(0, 0, 10, 10); glBindTexture(GL_TEXTURE_2D, 0); super.render(matrixStack, mouseX, mouseY, partialTicks); } Sometimes It works what I excepted but randomly it shows black texture or render only helf. What's wrong with my code? I cached array so myImagePixelArray always has same data. Edited February 25, 20223 yr by Dayo
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.