无法在minecraft初始化后调用两次glteximage2d

rqdpfwrv  于 2021-06-29  发布在  Java
关注(0)|答案(0)|浏览(243)

我正在用1.16.4制作一些fabrimc mod。
当minecraft初始化时,代码可以完美地工作。
但如果我加入到服务器或单个播放器,代码会崩溃,异常是访问权限(0xc0000005)。
字节缓冲区翻转,检查剩余字节是否等于图片大小。
它第一次起作用。
但如果render方法被调用两次,minecraft就会崩溃。
使用代码:

// Force-load
       ImageUtil.ImageBufferData bd = ImageUtil.toBuffer(VideoPanel.LOADING_CUTSCENE);
       ByteBuffer buffer = new CutSceneData.BufferData(bd.getBuffer(), bd.getWidth(), bd.getHeight());
       GL11.glClearColor(0f, 0f, 0f, 1f);
       GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
       RenderSystem.translatef(0.0F, 0.0F, -2000.0F);
       GlStateManager.pushMatrix();
       RenderSystem.enableTexture();
       RenderSystem.bindTexture(cutScene.getTextureID());
       RenderSystem.texParameter(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR);
       RenderSystem.texParameter(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
       GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA8, (int) (buffer.getWidth()), (int) (buffer.getHeight()), 0, GL11.GL_RGBA, GL_UNSIGNED_BYTE, buffer.getBuffer().duplicate());
       GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);
       drawQuadFully();
       RenderSystem.popMatrix();
       RenderSystem.disableTexture();

java转储:

Current thread (0x00000212074e4800):  JavaThread "Render thread" [_thread_in_native, id=38608, stack(0x000000d5a8000000,0x000000d5a8100000)]

Stack: [0x000000d5a8000000,0x000000d5a8100000],  sp=0x000000d5a80fca58,  free space=1010k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [nvoglv64.dll+0xc11760]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
J 18048  org.lwjgl.opengl.GL11C.nglTexImage2D(IIIIIIIIJ)V (0 bytes) @ 0x00000212180d7e4c [0x00000212180d7dc0+0x000000000000008c]
j  org.lwjgl.opengl.GL11C.glTexImage2D(IIIIIIIILjava/nio/ByteBuffer;)V+17
j  org.lwjgl.opengl.GL11.glTexImage2D(IIIIIIIILjava/nio/ByteBuffer;)V+14
J 11250 c1 skywolf46.videopanel.renderer.CutSceneRenderer.renderToScreen()Z (215 bytes) @ 0x0000021210fb38e4 [0x0000021210faf880+0x0000000000004064]
J 11248 c1 net.minecraft.client.render.GameRenderer.render(FJZ)V (886 bytes) @ 0x0000021210f985f4 [0x0000021210f983e0+0x0000000000000214]
J 11125 c1 net.minecraft.client.MinecraftClient.render(Z)V (946 bytes) @ 0x0000021210f49aec [0x0000021210f459a0+0x000000000000414c]
j  net.minecraft.client.MinecraftClient.run()V+83
j  net.minecraft.client.main.Main.main([Ljava/lang/String;)V+1366

附加信息
bytebuffer remaining()返回 width * height * 4 .
使用minecraft 1.16.4的最新结构。
试图在屏幕上画些东西。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题