Login  Register

Re: Need Help Solving OpenGL/GLSL 4.4 Issues

Posted by xghost on Jul 20, 2014; 10:03pm
URL: https://forum.jogamp.org/Need-Help-Solving-OpenGL-GLSL-4-4-Issues-tp4032557p4032605.html

jmaasing wrote
That's not how shader based OpenGL works.
Sorry, but I'm not sure I'm correctly following what you're referring to by simply saying 'that' here. Which part, specifically, were you referring to?

jmaasing wrote
...right now your shader hardcodes both position and color so that's what you get.
Perhaps there's a misunderstanding here. For this specific demo, I want the values in the shaders to be hard-coded. The problem is that, when you edit the hard-coded data and set it to other values and re-build/re-launch the application, contrary to expectations, there is no visible difference.

This is why I pointed out that the black color being displayed does not match the hard-coded values being used in the fragment shader (note that they're not all 0.0's in RGB, so it shouldn't be black). For example, if you edit the fragment shader RGB component values to all be 1.0's, then you'd expect the output to be white, correct? Well, I don't see that happening when I'm using JOGL, though in C++ it works fine (see bottom).

When you say that's not how it works, are you trying to suggest that the behaviour I'm seeing in JOGL is actually correct and that my expectations for this demo are wrong, despite the fact that the OpenGL SB6 C++ demo doing the same thing works just fine?

As I've mentioned previously, the OpenGL SB 6 book reference code has this sample as a simple introductory application and it works as I'd expect --i.e. change hard-coded shader values, rebuild, and it looks different.

This is what I expected to see with JOGL, but I'm not and you seem to suggest that I'm getting what I should be getting. Please let me know if I've misunderstood what you're trying to say.


jmaasing wrote
On the OpenGL side you must set up input data that your shader reads. There are many ways to do so but usually it involves creating vertex buffers with data that is different for each vertex. Or by using shader uniforms for data that is the same for all vertices.
I think I'm aware of this, but the goal of this demo is different, as I attempted to explain above. There's also no point in building something more complex if the simple things are not behaving as expected.


jmaasing wrote
Here is a good tutorial I used when learning modern OpenGL: http://www.arcsynthesis.org/gltut/
gouessej wrote
This ported examples are worth a look too:
https://github.com/elect86/modern-jogl-examples
Thanks for the additional reference and samples. I was already using the OpenGL Super Bible 6, but I'll certainly take a look. Currently though, I'm trying to find a more immediate/specific explanation for what I've described.

Thanks again for the help.


-----------------
Below is a small diff of a hard-coded fragment shader I modified and the actual output, which is consistent with expectations in the C++ based application, but not the result I get in the JOGL equivalent.
diff --git a/src/singletri/singletri.cpp b/src/singletri/singletri.cpp
index 54160df..792170f 100644
--- a/src/singletri/singletri.cpp
+++ b/src/singletri/singletri.cpp
@@ -58,7 +58,7 @@ class singlepoint_app : public sb6::application
             "                                                                  \n"
             "void main(void)                                                   \n"
             "{                                                                 \n"
-            "    color = vec4(0.0, 0.8, 1.0, 1.0);                             \n"
+            "    color = vec4(1.0, 1.0, 1.0, 1.0);                             \n"
             "}                                                                 \n"
         };