此问题现已修复.我的着色器属性没有正确绑定.
我有一个游戏,从IDE运行时看起来像这样:
但是,当我使用这些设置从Eclipse导出它时,
纹理完全不正确.纹理仍然加载,但它们没有正确地包装到对象上.
代码完全相同,因为我刚刚导出它,而且我目前同时运行游戏的两个窗口(一个在IDE中工作正常,一个从导出的JAR看起来很奇怪).
我还将IDE目录中的所有资源复制到具有外部JAR的文件夹中.IDE目录:

此外,我知道纹理实际上正在加载 - 它们没有正确包装.我知道这是因为:
我已经检查了JAR文件,片段和顶点着色器仍在那里.正确的库也似乎在那里(此外,如果不是,游戏甚至不会开始).

更新:当我多次重新启动游戏以检查更多信息时,我注意到,只要显示器显示(因此我可以看到纹理不正确的地形和平面),游戏就会冻结大约90%的时间.没有Stacktrace,只是"这个窗口没有响应,窗口正在关闭它".当我在IDE中运行游戏时,游戏仍能完美运行而不会崩溃.
游戏服务器导出并运行完美.只有客户才是问题.
那么导出可以使游戏与在IDE中运行游戏有什么不同,我该如何解决呢?
更新:所以这是我的纹理加载代码:
loader.loadTexture("PlaneTexture", 1);
//loadTexture() method:
public int loadTexture(String fileName, int mipmap) {
Texture texture = null;
try {
try{
texture = TextureLoader.getTexture("PNG", new FileInputStream("res/" + fileName + ".png")); //TextureLoader is a Slick-Util class.
}catch (Exception e){
e.printStackTrace();
}
if (texture == null){
throw new Exception("Null texture!");
}
//texture = TextureLoader.getTexture("GIF", new FileInputStream("res/" + fileName + ".png"));
if (mipmap > …Run Code Online (Sandbox Code Playgroud) 我有一些树,这些树大大落后于游戏,所以我想检查一下树是否在镜头前.

我从数学论坛得到了一些帮助,还看了一下这个链接,帮助我将俯仰/偏航转换为所需的方向向量.
但出于某种原因,每当我将摄像机向左移动时,树木都会变得可见,每当我向右移动它们时,它们就会变得不可见(因此,如果摄像机指向Z轴上的+1,它似乎正在渲染树,但Z轴上的-1,似乎没有渲染它们).
(请参阅http://i.gyazo.com/cdd05dc3f5dbdc07577c6e41fab3a549以获得不那么跳跃的.mp4)
我使用以下代码检查对象是否在相机前面:
Ship you = shipsID.get(UID);
int dis = 300;
Vector3f X = new Vector3f(camera.x(), camera.y(), camera.z());
float x = (float) (Math.cos(Math.toRadians(camera.yaw()))*Math.cos(Math.toRadians(camera.pitch())));
float y = (float) (Math.sin(Math.toRadians(camera.yaw()))*Math.cos(Math.toRadians(camera.pitch())));
float z = (float) Math.sin(Math.toRadians(camera.pitch()));
Vector3f V = new Vector3f(x, y, z);
for (Tree tree : trees){
Vector3f Y = new Vector3f(tree.location.x, tree.location.y, tree.location.z);
Vector3f YMinusX = Y.negate(X);//new Vector3f(Y.x - X.x, Y.y - X.y, Y.z - X.z);
float dot = Vector3f.dot(YMinusX, V);
if (dot …Run Code Online (Sandbox Code Playgroud) 经过两个小时的谷歌搜索(这里,这里,这里,这里,这里,以及其他一些我不想找到的东西),我以为我终于学会了将3D坐标转换为2D坐标的理论.但它没有用.我们的想法是将船舶的3D坐标转换为屏幕上的2D坐标,以呈现控制该船舶的玩家的用户名.
但是,文本呈现在错误的位置:

文本是"Test || 2DXCoordinate || 2DZCoordinate".
这是我的getScreenCoords()- 将3D坐标转换为2D.
public static int[] getScreenCoords(double x, double y, double z) {
FloatBuffer screenCoords = BufferUtils.createFloatBuffer(4);
IntBuffer viewport = BufferUtils.createIntBuffer(16);
FloatBuffer modelView = BufferUtils.createFloatBuffer(16);
FloatBuffer projection = BufferUtils.createFloatBuffer(16);
GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, modelView);
GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, projection);
GL11.glGetInteger(GL11.GL_VIEWPORT, viewport);
boolean result = GLU.gluProject((float) x, (float) y, (float) z, modelView, projection, viewport, screenCoords);
if (result) {
return new int[] { (int) screenCoords.get(0), (int) screenCoords.get(1) };
}
return …Run Code Online (Sandbox Code Playgroud) 我试图将统一变量绑定到某个位置,但我目前无法弄清楚如何:
要绑定属性(例如顶点/普通数据),我使用以下代码:
Override
protected void bindAttributes() {
super.bindAttribute(1, "position");
super.bindAttribute(2, "textureCoords");
super.bindAttribute(3, "normal");
}
protected void bindAttribute(int attribute, String variableName){
GL20.glBindAttribLocation(programID, attribute, variableName);
}
Run Code Online (Sandbox Code Playgroud)
我想对统一变量做同样的事情.
目前,我正在获取自动分配的位置,如下所示:
public int location_transformationMatrix;
public int location_lightPosition;
public int location_lightColour;
@Override
public void getAllUniformLocations(){
location_transformationMatrix = super.getUniformLocation("transformationMatrix");
location_lightPosition = super.getUniformLocation("lightPosition");
location_lightColour = super.getUniformLocation("lightColour");
}
Run Code Online (Sandbox Code Playgroud)
然而,由于我随后绑定了属性,这最多会导致数据丢失,例如照明和法线,最糟糕的是,大约有60%的人试图播放它.
我在获取缺少/未使用特定依赖项的对象的声明字段时遇到问题。
Field[] fields = OBJECT.getClass().getDeclaredFields();
Run Code Online (Sandbox Code Playgroud)
NoClassDefFoundError当该对象导入缺少的类时抛出 a 。
我想这样做的原因是为了 Bukkit 插件。我想获取缺少依赖项的插件实例的字段(它们未使用,但插件可以启动)。
在运行时,该插件将检查所需的依赖项是否存在,并根据情况加载这些特定字段。
我想到的可能的解决方案:
1)虚拟创建缺少的类+包,然后使用 ASM 重试。但我真的不知道该怎么做。
问候,
马克西姆
我想将我的 OpenGL 显示设置为最大化。
我可以让用户手动完成,如果我setResizeable(true)然后让玩家点击最大化按钮,正如测试人员所说,这对用户来说是一个痛苦和不必要的步骤。
我可以将显示尺寸设置为与玩家屏幕相同的尺寸,但这看起来很奇怪,而且我不是在寻找全屏模式。
显然我已经可以全屏并设置显示大小,但我目前无法找到任何实际上允许我实际最大化显示的方法。
如果你不明白全屏和最大化之间的区别(Meta Stack Overflow 讨论),那么这里是Maximized的描述,这里是Fullscreen的描述。
就在上周,我在eclipse(K)中安装了插件管理器.现在,我想安装ObjectAid.只是,我的存储库(甚至是标准存储库)都无法连接.
"Could not find... url"
Run Code Online (Sandbox Code Playgroud)
我已经去了首选项 - >安装/更新 - >重新加载了网址,但之后我也收到了错误:
Unable to read repository at http://download.eclipse.org/tools/cdt/releases/kepler/content.xml.
Unable to read repository at http://download.eclipse.org/tools/cdt/releases/kepler/content.xml.
Failure initializing default SSL context
Run Code Online (Sandbox Code Playgroud)
我也查看了网络设置,将"原生"改为"直接",无济于事.
我知道我可以下载插件并手动安装,但这很麻烦,我希望网络安装能够正常工作.
它可能是某种某种"锁定"的文件吗?
我的git push也无效(本地提交工作正常).这可能是相关的.奇怪,内部浏览器工作.
!MESSAGE Provisioning exception
!STACK 1
org.eclipse.equinox.p2.core.ProvisionException: Unable to read repository at http://archive.eclipse.org/tools/cdt/releases/kepler/content.xml.
at org.eclipse.equinox.internal.p2.repository.CacheManager.createCache(CacheManager.java:192)
at org.eclipse.equinox.internal.p2.metadata.repository.SimpleMetadataRepositoryFactory.getLocalFile(SimpleMetadataRepositoryFactory.java:66)
at org.eclipse.equinox.internal.p2.metadata.repository.SimpleMetadataRepositoryFactory.load(SimpleMetadataRepositoryFactory.java:88)
at org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryManager.factoryLoad(MetadataRepositoryManager.java:57)
at org.eclipse.equinox.internal.p2.repository.helpers.AbstractRepositoryManager.loadRepository(AbstractRepositoryManager.java:768)
at org.eclipse.equinox.internal.p2.repository.helpers.AbstractRepositoryManager.loadRepository(AbstractRepositoryManager.java:668)
at org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryManager.loadRepository(MetadataRepositoryManager.java:96)
at org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryManager.loadRepository(MetadataRepositoryManager.java:92)
at org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob.doLoad(LoadMetadataRepositoryJob.java:117)
at org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob.runModal(LoadMetadataRepositoryJob.java:102)
at org.eclipse.equinox.internal.p2.ui.sdk.PreloadingRepositoryHandler$2.runModal(PreloadingRepositoryHandler.java:83)
at org.eclipse.equinox.p2.operations.ProvisioningJob.run(ProvisioningJob.java:177)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
Caused by: java.lang.IllegalStateException: Failure initializing default SSL context …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用glMapData()和glBufferSubData()方法来修改现有的 VBO。
我目前的代码如下:
public void updateBufferData(int vaoID, int vboID, long index, int value){
GL30.glBindVertexArray(vaoID); //bind VAO
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboID); //bind VBO
IntBuffer buffer = storeDataInIntBuffer(new int[]{value}); //I'm not sure if I should do it like this?
GL15.glBufferSubData(vboID, index, buffer); //set data
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); //unbind VBO
GL30.glBindVertexArray(0); //unbind VAO
}
Run Code Online (Sandbox Code Playgroud)
但是,当我调用此方法时,它似乎对 VBO 没有任何影响。渲染的对象仍然相同。
我很确定在updateBufferData()调用该方法时,VBO/VAO 不会绑定到任何其他内容。
我一直得到这个例外:
Exception in thread "main" org.lwjgl.opengl.OpenGLException: Cannot use offsets when Array Buffer Object is disabled
at org.lwjgl.opengl.GLChecks.ensureArrayVBOenabled(GLChecks.java:93)
at org.lwjgl.opengl.GL11.glVertexPointer(GL11.java:2680)
at Joehot200.TerrainDemo.render(TerrainDemo.java:2074)
at Joehot200.TerrainDemo.enterGameLoop(TerrainDemo.java:3266)
at Joehot200.TerrainDemo.startGame(TerrainDemo.java:3490)
at StartScreenExperiments.Test2.resartTDemo(Test2.java:55)
at StartScreenExperiments.Test2.main(Test2.java:41)
Run Code Online (Sandbox Code Playgroud)
但是,数组缓冲区对象IS已启用!
glEnableClientState(GL_VERTEX_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER, vboVertexHandle);
glVertexPointer(3, GL_FLOAT, 0, 0L);
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,在glVertexPointer调用之前的两行(错误所在的那一行),然后我显然启用了数组缓冲区!
这有什么不对?