Can someone go over the mechanics of rendering shaders and texture objects

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

Can someone go over the mechanics of rendering shaders and texture objects

ElvJOGL
Hi,

Reading the textbook has been very innovating, but at times they are not showing all the parts that goes into putting the example into a working runnable piece.

However, what are the typical things or patterns of rendering maintenance that you deal with when rendering an image or a model?

For instance, I mean, when rendering a model, can someone give me a top down hierarchy of types of things I have to keep in mind when rendering a model.

Like What goes first, and what should be set last, and how to go into a process of elimination before you rendering something into the screen?

You don't have to give a sample code, I need someone to describe that experience as far as being someone who is adept at setting up a good JOGL context following proper hygiene.

I hope someone can understand my question, is only for learning the descriptions of the steps I should take into preparing a scene for rendering.

Thank you.
Reply | Threaded
Open this post in threaded view
|

Re: Can someone go over the mechanics of rendering shaders and texture objects

elect
I think the HelloTriangle can give you a quick introduction about that

> However, what are the typical things or patterns of rendering maintenance that you deal with when rendering an image or a model?

in general, once you have loaded all the geometry you need, for each frame you load at the begin the mvp (projection * view (or camera) * model) or all of them and you do the multiplication inside the shader

This is the minimalistic manteinance, others more advanced included culling, materials, lights, etc..

> For instance, I mean, when rendering a model, can someone give me a top down hierarchy of types of things I have to keep in mind when rendering a model.

When you render, look at the display() method, you clear depth and color buffer, bind the program, bind the vao (vertex array object), load the matrices as one, and then issue the draw call.
The last bindings are not necessary, they are there only for showing purpouses. CheckError() too.
Reply | Threaded
Open this post in threaded view
|

Re: Can someone go over the mechanics of rendering shaders and texture objects

ElvJOGL
I hope you don't mind @elect I forked you helloTriangle project.

I will read on it as much as possible.

Thank you.

But one question, for rendering a model one only calls the shaders and the texture binding once right? and then just continue displaying the image.

Or the shaders and texture binding continue to happen as much as you continue to render the model?

In other words, does calling the shader to compile and binding it to the program and running the program as well for the texture, does that happen in the Init(GLAutoDrawable) method and then the transformation of the viewport happens in the render(...) method?
Reply | Threaded
Open this post in threaded view
|

Re: Can someone go over the mechanics of rendering shaders and texture objects

elect
ElvJOGL wrote
I hope you don't mind @elect I forked you helloTriangle project.

I will read on it as much as possible.

Thank you.
How dare you...


I can only be happy, cmon


ElvJOGL wrote
But one question, for rendering a model one only calls the shaders and the texture binding once right? and then just continue displaying the image.
there is no shader binding and the texture has to be bound at the creation/generation of the texture itself and everytime you want to execute a draw call where the texture has to rendered, that is the texture is one of the inputs

ElvJOGL wrote
Or the shaders and texture binding continue to happen as much as you continue to render the model?
I guess I got it what you mean, Opengl is a state machine, so when you render you have n states, each of them with a specific value bound/set.

This means, if you are about to execute a drawing call to render the texture Wall, that Wall texture has to be bound. If later you render just pure geometry without any texture, you can leave wall bound, it won't interfere

In general all the calls that reset states to 0, such as

gl4.glBindBuffer(GL4.GL_ARRAY_BUFFER, 0);

gl4.glBindVertexArray(0);

and so on, are totally useless by a practical point of view, and harmful by a performance one..

The only important 0 call is

gl4.glBindFramebuffer(GL_FRAMEBUFFER, 0);

in case you are done rendering one a framebuffer you created and you want to switch back the default one

ElvJOGL wrote
In other words, does calling the shader to compile and binding it to the program and running the program as well for the texture, does that happen in the Init(GLAutoDrawable) method and then the transformation of the viewport happens in the render(...) method?
I am not sure what you mean..

init() is called once at begin, then there is a reshape(), then all displays(), unless you resize the window -> reshape() or close it -> dispose()

in the init you create the shaders, and the program, add the shaders to the program and compile it. Once compiled it can be used to render.
If you have any texture, you have to init it just once, when you need it during runtime or at the startup of your program, depending on your needs.

the viewport, normally, should be performed in the reshape() since it affects the window space/image

the transformation of the matrices, mvp, usually at the begin of the the display or, if you don't change them, do it once and then again once one of them get dirty
Reply | Threaded
Open this post in threaded view
|

Re: Can someone go over the mechanics of rendering shaders and texture objects

ElvJOGL
I don't know why,

but I already had the latest jogl download for jogamp.

I read download the libraries again from jogamp just in case.

but I still get these BROKEN references to the com.jogamp....libraries.

import com.jogamp.nativewindow.util.Dimension;
import com.jogamp.opengl.GL;
import static com.jogamp.opengl.GL.GL_INVALID_ENUM;
import static com.jogamp.opengl.GL.GL_INVALID_FRAMEBUFFER_OPERATION;
import static com.jogamp.opengl.GL.GL_INVALID_OPERATION;
import static com.jogamp.opengl.GL.GL_INVALID_VALUE;
import static com.jogamp.opengl.GL.GL_NO_ERROR;
import static com.jogamp.opengl.GL.GL_OUT_OF_MEMORY;
import static com.jogamp.opengl.GL2ES2.GL_FRAGMENT_SHADER;
import static com.jogamp.opengl.GL2ES2.GL_VERTEX_SHADER;
import com.jogamp.opengl.GL4;
import com.jogamp.opengl.GLAutoDrawable;
import com.jogamp.opengl.GLCapabilities;
import com.jogamp.opengl.GLEventListener;
import com.jogamp.opengl.GLProfile;


all that I pasted here appear RED in your helloTriangle.java file.

Not that you might be thinking wrong, but just in case you are wondering, yes, I know how to include User Libraries to a java eclipse project.

But after I included the jogl-all.jar into the build path and linked the native dll libraries to the build path, all I pasted above is unrecognizable by eclipse, they show up RED.

Any ideas?

Thanks


Reply | Threaded
Open this post in threaded view
|

Re: Can someone go over the mechanics of rendering shaders and texture objects

ElvJOGL
I commented out all the broken references.

And I re-import them, these were the references that were available


import javax.media.nativewindow.util.Dimension;
import javax.media.opengl.GL;
import javax.media.opengl.GL4;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLProfile;

I don't know why your jogamp references go by the com.jogamp.* reference,

But mines go by the javax.media.* reference.

Any idea in how I can revert to having the references the way you have them in your project?

I did add the i586 jar, for 32bit. I am not using 64bit, would that make a difference?

Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: Can someone go over the mechanics of rendering shaders and texture objects

elect
ElvJOGL wrote
I commented out all the broken references.

And I re-import them, these were the references that were available


import javax.media.nativewindow.util.Dimension;
import javax.media.opengl.GL;
import javax.media.opengl.GL4;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLProfile;

I don't know why your jogamp references go by the com.jogamp.* reference,

But mines go by the javax.media.* reference.

Any idea in how I can revert to having the references the way you have them in your project?

I did add the i586 jar, for 32bit. I am not using 64bit, would that make a difference?

Thanks.
those are the past locations, you are using an outdated jogl version.. where did you download it?

use this one
Reply | Threaded
Open this post in threaded view
|

Re: Can someone go over the mechanics of rendering shaders and texture objects

ElvJOGL
Everything is referenced the right way now.

But there still seem something wrong in here.

    private void initVbo(GL4 gl4) {

        gl4.glGenBuffers(1, objects, Semantic.Object.VBO);
        gl4.glBindBuffer(GL4.GL_ARRAY_BUFFER, objects[Semantic.Object.VBO]);
        {
///////////////////////////--> pointing to error /////////////////////////////////////////////////////////////
/            //the GLBuffers reference seems broken, I don't know why I am getting RED.
/            //the eclipse error message says this:
/            //"The type com.jogamp.common.nio.Buffers cannot be resolved. It is
/            //indirectly referenced from required .class files"
/     // ----->      ByteBuffer vertexBuffer = GLBuffers.newDirectByteBuffer(vertexData);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            int size = vertexData.length * Byte.BYTES;
            gl4.glBufferData(GL4.GL_ARRAY_BUFFER, size, vertexBuffer, GL4.GL_STATIC_DRAW);
            BufferUtils.destroyDirectBuffer(vertexBuffer);
        }
        gl4.glBindBuffer(GL4.GL_ARRAY_BUFFER, 0);

        checkError(gl4, "initVbo");
    }

-------------------------

Maybe I am missing a jar?

Like I followed what your GitHub readme file says, to only include the jogl-all.jar in the library path.

But if I need to include something else let me know. please.
Reply | Threaded
Open this post in threaded view
|

Re: Can someone go over the mechanics of rendering shaders and texture objects

elect
jogl-all and gluegen-rt

be sure the native are in the same folder of the jars
Reply | Threaded
Open this post in threaded view
|

Re: Can someone go over the mechanics of rendering shaders and texture objects

ElvJOGL
In reply to this post by ElvJOGL
I got it working never mind.

I needed to include the gluen-rt.jar, I guess I dont' know how to read.

Anyhow, then I updated the shaders root path to the right location in my eclipse project and now I am seeing it run.

Is nice.

I will study your work for a while, until I can get something work of my own and then I will post it in the forum.

Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: Can someone go over the mechanics of rendering shaders and texture objects

elect
Nah, shit happen ;)

Anyway, you see, now you have the power of OpenGL in your hands! ^^


However, if you want to write the superbible sample and if find some passage difficult, take a look on my samples or don't hesitate to ask

learning opengl nowadays is kind of risky because there are many many resourses outdated and one does not know what is updated and what is not
Reply | Threaded
Open this post in threaded view
|

Re: Can someone go over the mechanics of rendering shaders and texture objects

ElvJOGL
Thanks, this is the best and most friendliest forum I have ever been too.

For instance, when learning PHP, I went to their forums and they are a bunch of snotty people. But that's PHP, not JOGAMP.

Looking forward to learning more from here and from you guys.

Thanks a bunch.
Reply | Threaded
Open this post in threaded view
|

Re: Can someone go over the mechanics of rendering shaders and texture objects

elect
We are here to serve you, sir
Reply | Threaded
Open this post in threaded view
|

Re: Can someone go over the mechanics of rendering shaders and texture objects

ElvJOGL
Your helloTriangle project.

What type of project is it?

Is it a netbeans project?

Because I tried to import into eclipse but it does not come up as any project that I can import.

So I was able to just import as a collection of Files, but that's a lot of work if your project were bigger.

Anyhow, could you tell me if it is a netbeans IDE project?

Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: Can someone go over the mechanics of rendering shaders and texture objects

ElvJOGL
Can I dissect your helloTriangle project?

For instance, what's do you mean by initVbo, initIbo, and initVao.

I know that they are used to initialize your buffers, but could you explain the relations between all of them.

I really want to understand the basis of this.

Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: Can someone go over the mechanics of rendering shaders and texture objects

elect
ElvJOGL wrote
Is it a netbeans project?
Yep

ElvJOGL wrote
Can I dissect your helloTriangle project?

For instance, what's do you mean by initVbo, initIbo, and initVao.

I know that they are used to initialize your buffers, but could you explain the relations between all of them.

I really want to understand the basis of this.

Thanks.
Sure, so, initVbo initializes the Vertex Buffer Object, where you store the position of your vertices
initIbo the Index Buffer Object, where you store the indices that indicates which vertex fetching from the vbo
initVao initializes the Vertex Array Objects, that is an object that stores the vertices attributes, basically all this stuff

So instead calling all those calls inside the display() method, there is the vao that remembers all that for you, so you set them inside the vao at begin and then you just need to use (bind) the vao.

notice that we bind the element_array_buffer (ibo) and we left it bound because it is part of the vao. Different story for the vbo, the vbo is not part of the vao, but it has to be bound when you call the corresponding glVertexAttribPointer
Reply | Threaded
Open this post in threaded view
|

Re: Can someone go over the mechanics of rendering shaders and texture objects

ElvJOGL
In reply to this post by elect
elect wrote
ElvJOGL wrote
I commented out all the broken references.

And I re-import them, these were the references that were available


import javax.media.nativewindow.util.Dimension;
import javax.media.opengl.GL;
import javax.media.opengl.GL4;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLProfile;

I don't know why your jogamp references go by the com.jogamp.* reference,

But mines go by the javax.media.* reference.

Any idea in how I can revert to having the references the way you have them in your project?

I did add the i586 jar, for 32bit. I am not using 64bit, would that make a difference?

Thanks.
those are the past locations, you are using an outdated jogl version.. where did you download it?

use this one
Where do I get the Javadoc for jogamp?

You linked the jogamp zip but there are no Javadoc so I can know the description of each method.

Is it possible to get the javadocs?

Reply | Threaded
Open this post in threaded view
|

Re: Can someone go over the mechanics of rendering shaders and texture objects

elect
Sure, they are all the *.zip files at the first level of the file you downloaded, /jogamp-all-platforms, for example jogl-java-src