Person having trouble with the same openGL book.

Looks like some helpful hints here.

Lesson 3 source can be found here.
But is not the official source. (If there is any)

Note to self: Should have bought my openGL book directly from
“The Pragmatic Bookshelf” instead of
They are offering DRM free eBook versions.

Ah! Official source code here.
See if I can get the official source code running.


Need 50 reputation on stack overflow

This person seems to be having the same problem I am.
And it is specific to Android 4.1 and 4.2 it seems.

But… I can’t leave a comment stating I have the same problem, or get
ahold of them in general.

I find I have this problem on stack overflow a lot.
But it is probably by design that I can’t reach out and communicate
with people on there.

Compiling program in correct context?

I read something about in OpenGL things don’t exist unless the proper context
is set… Maybe my program linking is failing because the proper context is set?

Maybe all the commands are correct. And the source shaders are correct.
But some type of state/context needs to be set properly before my
code is called?

Or possibly a driver bug?

But that doesn’t make any sense. I’ve gotten code to work.
Just never code that I’ve done step-by step without copying.

So I feel like the error is me.

Maybe I need to somehow append C-Style null terminated lines to my
shader source strings?

This thread:

Makes mention of a program called gDEBbugger.
I guess it is not uncommon to have zero errors in compilation of shaders,
but then have error on linking for unknown reasons.

Looks like AMD took over developement of gDEBbugger and
that gDEBbugger is being replaced by CodeXL

CodeXL Landing Page:

shaders compile but do not link openGL

Narrowed down my problem.
Shaders successfully compile…
Program handle is successfully made.
But linking of program fails…

Solution not covered here. But good read.
OpenGL: Why is your code producing a black window?

Stack Overflow maybe?
Unable to link compiled shaders:
This is telling me my code for reading in the shader might be printing some
bad characters or something?

Common OpenGL Pitfalls
Interesting notes:
1: glDrawPixels() command.

2: Slow pixel transfer performance
Pixel Transfer:
2.1: glReadPixels
2.2: glTexSubImage
4. Overflowing the Projection Matrix Stack
glGetIntergerv to see max depth of stack supported.
Default/Min requirement: 32 for ModelView Matrix, 2 for everything else.

7. Watch Your Pixel Store Alignment
pixels = (GLubyte*) malloc(3 * 11 * 8); /* Wrong! */
OpenGL's default 4-byte row alignment.

10. The Viewport Does Not Clip or Scissor

12. OpenGL's Lower Left Origin
Will affect reading in textures. Because it will try to
read from the bottom most scan line first.

15. Much OpenGL State Affects All Primitives
This issue is not unique to the per-fragment and rasterization state. The pixel path state is shared by the draw pixels (glDrawPixels), read pixels (glReadPixels), copy pixels (glCopyPixels), and texture download (glTexImage2D) paths. If you are not careful, it is easy to get into situations where a texture download is screwed up because the pixel path was left configured for a pixel read back.

A bit of hacking:
From my kevin021 that covers up to INCLUDING chapter 3 of my openGL book.
1. Maybe there should be a position pointer reset in that function?
2. Maybe uColorLocation = glGetUniformLocation(program, U_COLOR);

Current plan:
1. Find source for lesson 3.
2. Assemble source.
3. Run source.
4. Get source working.
5. Re-do chapter 3 by hand.
6. Diff the two projects in a differ to see where I made the
critical mistake that is stopping the rendering from showing up.

Chapter 3 Failure.

Wow… OpenGL… Errors… Are silent and hard to find I guess.
You’d think I’d be rendering triangles flawlessly by now.

It’s been over a week and I still haven’t mastered the OpenGL
equivalent of “Hello World”???

Kevin on hard to find open GL Errors:

“Passing incorrect arguments to glVertexAttribPointer() can lead to strange
results and can even cause the program to crash. These kinds of crashes
can be hard to trace, so I can’t overstate how important it is to make sure we get
these arguments right.”
Page 50: OpenGL ES 2.0 for Android.