|
Hello. I'm struggling with my textures and I would really appreciate some help.
I have a piece of code which renders a texture from a jpg file. The code gives different result for Linux and Mac and I can't understand if I am the cause for the problem (probably yes). On both machines I'm using Java 7 and the latest jogl libraries (since December 2013). The code is giving me the results that I want on the Linux Machine. On the Mac, however, if the animator is running the image shows for a second and then it shrinks to an invisible size. If I don't start the animator the image stays but is smaller that the square that I'm trying to map it onto. I am inerting screenshots of what the results look like. ![]() ![]() ![]() I am also attaching my code (and the 2 shaders). I think it's simple enough. The java class is justTexture.java, the vertex shader colorTexture.vert and the fragment shader colorTexture.frag. I suspect that maybe I'm doing something wrong when I activate and bind the texture or when I send the sampler2D location to the shader. This is where I initializa the texture texture = TextureIO.newTexture(new File("Varna.jpg"), false); byte[] buf = new byte[texture.getWidth()*texture.getHeight()*4]; ByteBuffer buffer = ByteBuffer.wrap(buf); gl.glGenTextures(1, textureId, 0); gl.glActiveTexture(GL3.GL_TEXTURE0); gl.glBindTexture(GL3.GL_TEXTURE_2D, textureId[0]); gl.glTexImage2D(GL3.GL_TEXTURE_2D, 0, GL3.GL_RGBA, texture.getWidth(), texture.getHeight(), 0, GL3.GL_RGBA, GL3.GL_UNSIGNED_BYTE, buffer); texture.setTexParameteri(gl, GL3.GL_TEXTURE_MIN_FILTER, GL3.GL_LINEAR); texture.setTexParameteri(gl, GL3.GL_TEXTURE_MAG_FILTER, GL3.GL_LINEAR); then I create a location for the sampler iSampler = gl.glGetUniformLocation(iTexProgram, "Tex1"); and the code below goes in the display function gl.glUseProgram(iTexProgram); gl.glUniformMatrix4fv(iTexMVP, 1, false, texMVP, 0); gl.glUniform1i(iSampler, 0); gl.glBindVertexArray(iVao[0]); gl.glDrawArrays(GL3.GL_TRIANGLES, 0, 6); gl.glBindVertexArray(0); Thank you in advance for your help. I really appreciate it. |
|
Administrator
|
Hi
This has nothing to do with the operating system. One of your graphics cards (under Mac) doesn't support non power of two textures. Edit.: Please use at least JOGL 2.1.4 before investigating further.
Julien Gouesse | Personal blog | Website
|
|
Thank you for the response gouessej. I updated my jogl (I didn't realize there was an even newer release than December) and I made my picture 256x256. That gave me the same results.
However, I switched back to Java 6 and now it's working just the way I want it to :) |
|
Administrator
|
I don't understand why switching to Java 1.6 solved your problem :s
Edit.: Use NEWT instead of Swing and AWT. Maybe there is a bug in Oracle Java 1.7 that affects heavyweight / lightweight mixing.
Julien Gouesse | Personal blog | Website
|
|
I am confused too.
Thanks for the suggestion to use NEWT. I will try it next week and will post again with the results. |
|
In reply to this post by Lili
Hi i uploaded your example to
https://github.com/xranby/jogamp-forum-examples/tree/master/Lili/justTexture git clone https://github.com/xranby/jogamp-forum-examples cd jogamp-forum-examples/Lili/justTexture ./fetch-jogamp-build.sh ./run.sh Since i did not have access to your Varna.jpg image i added one i found on the internet that was free for use on desktop systems. It work on my linux system.
|
|
In reply to this post by Lili
I added an AWT -> NEWT port of your example that you can try https://github.com/xranby/jogamp-forum-examples/commit/04e1064fecd54df1b7c16b45d9c3fcd920e536dc |
| Free forum by Nabble | Edit this page |
