本帖最后由 冰冷冷 于 2020-5-8 12:14 编辑 
我现在先将BufferedImage画到Canvas上
之后使用Display.setParent(canvas) Display.update();
没有任何效果 不知道怎么才能渲染图片覆盖住整个窗口
不知道怎么才能渲染图片覆盖住整个窗口
对opengl不是很了解,求各位大佬轻点喷
我现在先将BufferedImage画到Canvas上
之后使用Display.setParent(canvas) Display.update();
没有任何效果
对opengl不是很了解,求各位大佬轻点喷
 本帖最后由 阴阳师元素祭祀 于 2020-5-8 12:35 编辑 
具体mc版本?forge还是fabric?
我的fabric (应该无关)
依赖的mc 依赖的lwjgl
没有BufferedImage和Canvas和Display
如果你要渲染图片覆盖窗口
直接glViewport(0, 0, w, h)
然后从-1, -1画纹理到1 1这个地方即可(cost 6个顶点) (渲染纹理..如果有轮子就用轮子? 没有就用我的方法)
https://learnopengl-cn.github.io/
(-1, 1) (1, 1)
----------------
| |
----------------
(-1,-1) (1, -1)
我的fabric (应该无关)
依赖的mc 依赖的lwjgl
没有BufferedImage和Canvas和Display
如果你要渲染图片覆盖窗口
直接glViewport(0, 0, w, h)
然后从-1, -1画纹理到1 1这个地方即可(cost 6个顶点) (渲染纹理..如果有轮子就用轮子? 没有就用我的方法)
https://learnopengl-cn.github.io/
(-1, 1) (1, 1)
----------------
| |
----------------
(-1,-1) (1, -1)
阴阳师元素祭祀 发表于 2020-5-8 12:31
具体mc版本?forge还是fabric?
我的fabric (应该无关)
我这用的forge-1.12.2-14.23.5.2847,谢谢大佬指导
Caused by: java.lang.IllegalArgumentException: Number of remaining buffer elements is 1125387, must be at least 1229760. Because at most 1229760 elements can be returned, a buffer with at least 1229760 elements is required, regardless of actual returned element count
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight, 0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, allocate);
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight, 0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, allocate);
 本帖最后由 冰冷冷 于 2020-5-8 20:01 编辑 
复制代码
 我这样写入材质之后要怎么才能渲染到窗口上
我这样写入材质之后要怎么才能渲染到窗口上
阴阳师元素祭祀 发表于 2020-5-8 12:31
具体mc版本?forge还是fabric?
我的fabric (应该无关)
- int i1 = GL11.glGenTextures();
 
- GL11.glBindTexture(GL11.GL_TEXTURE_2D,i1);
 
- GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);
 
- GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT);
 
- GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
 
- GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
 
- GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB,frame.imageWidth, frame.imageHeight, 0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE,frame.data);
 
- GL11.glViewport(-1,-1,frame.imageWidth, frame.imageHeight);
冰冷冷 发表于 2020-5-8 19:50
我这样写入材质之后要怎么才能渲染到窗口上
mojang应该有轮子吧
你可以翻一下MinecraftClient相关的field
然后从你的mod加载图片 然后直接交给forge或者mojang渲染即可