Problem with client-side textures

classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with client-side textures

opengltester
Hi,

I just spent quite some time trying to get this right but I cannot find what I am doing wrong. The problem is that if you change texUnit in the Scene class to anything other than GL_TEXTURE0 you get a read square. I would be very grateful for any insight.
TextureTest.java
square.dds
Reply | Threaded
Open this post in threaded view
|

Re: Problem with client-side textures

elect
Hi,

you shouldn't use deprecated OpenGL, take a look to this sample
Reply | Threaded
Open this post in threaded view
|

Re: Problem with client-side textures

gouessej
Administrator
In reply to this post by opengltester
Hi

Have you tried with glActiveTexture? You'll have to use texture image units instead of texture units with modern OpenGL.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Problem with client-side textures

Sven Gothel
Administrator
On 08/31/2015 10:11 AM, gouessej [via jogamp] wrote:
> Hi
>
> Have you tried with glActiveTexture? You'll have to use texture image units
> instead of texture units with modern OpenGL.

.. hence have a look at this our API doc:

<http://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/com/jogamp/opengl/util/texture/Texture.html>

~Sven



signature.asc (828 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Problem with client-side textures

opengltester
Hi,

Yes I tried glActiveTexture and it makes no difference. In any case my understanding is that you use glActiveTexture for textures that have been pushed to a shader but glClientActiveTexture as in this sample. Perversely my shader-based code, which is more complex, works but this simpler class doesn't.

Regarding other code samples and deprecated APIs, I have done my homework and read and translated lots of them already (I posted here the one that doesn't work) but also I want to understand what I am doing, step by step. Thus I don't want to dissect yet another sample and go off doing something completely different at the first real difficulty because that's not the way to learn. I want to understand what is wrong with this code. For the same reason I am trying not to use toolkit-specific utilities too much because I want to understand OpenGL, not some derivative, and furthermore I may have to port this code to C++ later.

Thanks again for your understanding
Reply | Threaded
Open this post in threaded view
|

Re: Problem with client-side textures

elect
opengltester wrote
Regarding other code samples and deprecated APIs, I have done my homework and read and translated lots of them already (I posted here the one that doesn't work) but also I want to understand what I am doing, step by step. Thus I don't want to dissect yet another sample and go off doing something completely different at the first real difficulty because that's not the way to learn. I want to understand what is wrong with this code. For the same reason I am trying not to use toolkit-specific utilities too much because I want to understand OpenGL, not some derivative, and furthermore I may have to port this code to C++ later.

Thanks again for your understanding
Using fixed function pipeline will give you the illusion of knowledge, as McKesson says here
You will end copy/pasting code without really understand what it is happening under the hood.
Sooner or later you will have to learn modern opengl and the fixed pipeline is not going to help (unless rare examples).
I did this error and I wish someone has told me that before. If you want to understand than this is the way to go.
You can postpone the use of the Texture class utility if you want.
Anyway, I copied the wrong link, the test I wanted to propose you it was actually this one. The sample is pretty easy, you can't go simpler than that. The lines of code that matter are a dozzen.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with client-side textures

opengltester
As I said, I already have shader-based code that works. Is it so very wrong to want to understand something that's still part of OpenGL? Call it curiosity if you must.

Also, I find your claim that I am "copy/pasting code without really understand[ing]" really offensive since I already explained that I am trying hard to avoid doing that, precisely. It is you who are advocating cargo cult programming right now: "this thing ere doesn't work? never mind, it shouldn't work anyway, go try that other thing over there".

You know what, forget it and go screw yourself.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with client-side textures

gouessej
Administrator
opengltester wrote
You know what, forget it and go screw yourself.
Sorry, I don't want to offend you. I think that we have a working example using several unit textures in the project "jogl-demos", one from the red book.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Problem with client-side textures

opengltester
But again, I did this by looking at examples and reading manuals. At some point you have to stop reading or adapting foreign material and figure out what is wrong with *your* code. You don't seem to want to believe this but I spent quite some time on this and wrote quite a lot more code and it all works. I am just stumped on this particular class.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with client-side textures

elect
In reply to this post by opengltester
Wow, that escalated quickly

opengltester wrote
As I said, I already have shader-based code that works. Is it so very wrong to want to understand something that's still part of OpenGL? Call it curiosity if you must.
And do you understand that shader-based code? That's the point

opengltester wrote
Also, I find your claim that I am "copy/pasting code without really understand[ing]" really offensive since I already explained that I am trying hard to avoid doing that, precisely.
First, it shouldn't have been taken too personally. Second, if you are trying to achieve something and I (think) you are doing it wrong and I make you notice, I don't get how this can be offensive in any way.


opengltester wrote
 It is you who are advocating cargo cult programming right now: "this thing ere doesn't work? never mind, it shouldn't work anyway, go try that other thing over there".

You know what, forget it and go screw yourself.

Take it easy, dear. You seems way too frustrated, calm down and try to listen and read what you are said, I bet you didn't even open that link..
Reply | Threaded
Open this post in threaded view
|

Re: Problem with client-side textures

gouessej
Administrator
In reply to this post by opengltester
glClientActiveTexture can be used when you create your vertex array or your VBO but glActiveTexture should be called before glBindTexture. I have looked at the JOGL renderer of JogAmp's Ardor3D Continuation, it works correctly that way.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Problem with client-side textures

opengltester
There is no VBO in that code: it's old-style code. The flow is

initialization:

<generate texId>
glClientActiveTexture(GL2.GL_TEXTURE1)
gl2.glEnableClientState(GL2.GL_TEXTURE_COORD_ARRAY);
gl2.glBindTexture( GL.GL_TEXTURE_2D, texId );
<make texture>

rendering:

 gl.glClientActiveTexture(GL2.GL_TEXTURE1);
 gl.glEnableClientState( GL2.GL_VERTEX_ARRAY );
 gl.glEnableClientState( GL2.GL_TEXTURE_COORD_ARRAY );
<call glVertexPointer>
<call glTexCoordPointer>
<call glDrawArrays>

This works fine with GL_TEXTURE0 but not any other.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with client-side textures

Sven Gothel
Administrator
In reply to this post by opengltester
On 08/31/2015 06:00 PM, opengltester [via jogamp] wrote:
> Hi,
>
> Yes I tried glActiveTexture and it makes no difference. In any case my
> understanding is that you use glActiveTexture for textures that have been
> pushed to a shader but glClientActiveTexture as in this sample. Perversely my
> shader-based code, which is more complex, works but this simpler class doesn't.

Its all written up in the API doc I have referenced.
Its mapped active-texture-unit -> texture-unit in shader code.
All texture states relate to the current active texture-unit!

In JOGL we also have a few texture unit tests w/ shader
and they all work just fine:

TextureDraw01ES2Listener:
<http://jogamp.org/git/?p=jogl.git;a=blob;f=src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw01ES2Listener.java;h=e29981bb5cbb1c0d32555779e2501b33c5786be9;hb=HEAD>

Vertex Shader:
<http://jogamp.org/git/?p=jogl.git;a=blob;f=src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texture01_xxx.vp;h=1030dab4725980de44acbf32373a85b2f9cb6f07;hb=HEAD>

Fragment Shader:
<http://jogamp.org/git/?p=jogl.git;a=blob;f=src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texture01_xxx.fp;h=93f252cd67b9fc7077442e2ad236b70789c99a5a;hb=HEAD>

+++

Here is one used internally e.g. for rendering
and vertical flipping a previous rendered texture via FBO
as used in GLJPanel:

GLSLTextureRaster:
<http://jogamp.org/git/?p=jogl.git;a=blob;f=src/jogl/classes/jogamp/opengl/util/glsl/GLSLTextureRaster.java;h=66c5c855b6205ece068de8572228c46d7d887096;hb=HEAD>

Its shaders:
<http://jogamp.org/git/?p=jogl.git;a=tree;f=src/jogl/classes/jogamp/opengl/shader;h=b93bf63564e2f89b0daf25096df11ca9d9f3d1a4;hb=HEAD>

+++

They all follow the same principles as laid out...

Maybe you want to play with this code while reading the
GL ES 2/3 or GL 3/4 core spec .. and become more familiar w/ it.

Hope it helps a bit.

~Sven


signature.asc (828 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Problem with client-side textures

opengltester
Thanks but for the umpteenth time I already have working shader-based code and the code that is giving me trouble is not shader-based.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with client-side textures

elect
opengltester wrote
Thanks but for the umpteenth time I already have working shader-based code and the code that is giving me trouble is not shader-based.
You see, opengltester, if you understood shader-based code you'd have also no problem understanding the fixed pipeline, or at least debugging it and finding out what it is not working. But clearly this is not the case. No offense, just simple plain facts.

We do want to help you, but you are acting a little arrogant and counter-productive.

Show us this shader-based code, let us help you. We can clarify you what is working how so that you can better understand and have an idea about how things work under the hood in fixed pipeline.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with client-side textures

gouessej
Administrator
In reply to this post by opengltester
gouessej wrote
glClientActiveTexture can be used when you create your vertex array or your VBO
opengltester wrote
There is no VBO in that code: it's old-style code. The flow is
opengltester wrote
<call glDrawArrays>
Please read more carefully my comments, I mentioned the vertex arrays too. Sven just tried to show you some working examples (look at mgl_ActiveTexture in the GLSL fragment shader and glActiveTexture in the Java code) so that you can use as source of inspiration to fix your own code.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Problem with client-side textures

opengltester
I uploaded the relevant code in my very first posting.