How to draw a single pixel in OpenGL? - c++

Can someone tell me how to draw a single white pixel at a coordinate, say (100,200)?
I am using GLUT and so far have figured out how to open a blank window. Once I figure out how to draw pixels, I will use that to implement the Bresenham line drawing algorithm. (Yes, I am aware OpenGL can draw lines. I am required to implement this myself).
#include <stdio.h>
#include <GL/glut.h>
static int win(0);
int main(int argc, char* argv[]){
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_RGBA|GLUT_SINGLE);
glutInitWindowSize(500,500);
glutInitWindowPosition(100,100);
//step 2. Open a window named "GLUT DEMO"
win = glutCreateWindow("GLUT DEMO");
glClearColor(0.0,0.0,0.0,0.0); //set background
glClear(GL_COLOR_BUFFER_BIT);
glFlush();
glutMainLoop();
}

glVertex2i(x,y);
Here is the context it needs to work:
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowPosition(80, 80);
glutInitWindowSize(500,500);
glutCreateWindow("A Simple OpenGL Program");
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
gluOrtho2D( 0.0, 500.0, 500.0,0.0 );
glBegin(GL_POINTS);
glColor3f(1,1,1);
glVertex2i(100,100);
glEnd();

This can be done easily by setting the scissor rectangle, and then clearing, which will only clear the specified area in the scissor rectangle. For example:
glEnable(GL_SCISSOR_TEST);
glScissor(100, 200, 1, 1);
glClearColor(1,1,1,1);
glClear(GL_COLOR_BUFFER_BIT);
// Remember to disable scissor test, or, perhaps reset the scissor rectangle:
glDisable(GL_SCISSOR_TEST);

Using modern OpenGL you can combine glScissor() with a quad that fills the entire screen.
The shaders can be as simple as:
// Vertex Shader
#version 330 core
layout (location = 0) in vec3 aPos;
void main()
{
gl_Position = vec4(aPos.x, aPos.y, aPos.z, 1.0);
}
// Fragment Shader
#version 330 core
out vec4 FragColor;
uniform vec4 inColor;
void main()
{
FragColor = inColor;
}
After doing OpenGL and Windows initialization with your preferred method (GLFW, GLAD, GLEN, etc.), create a quad (really two triangles) to cover the entire screen like:
float vertices[] = {
-1.0f, -1.0f, 0.0f,
1.0f, -1.0f, 0.0f,
1.0f, 1.0f, 0.0f,
-1.0f, -1.0f, 0.0f,
1.0f, 1.0f, 0.0f,
-1.0f, 1.0f, 0.0f
};
Then create your buffers, compile your shaders and bind your shader program and VAO.
Then use:
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
Your drawing code would look something like this to draw a green pixel at x = 100, y = 100:
GLint transformLoc = glGetUniformLocation(shaderProgramId, "inColor");
glUniform4f(transformLoc, 0.0f, 1.0f, 0.0f, 1.0f);
glEnable(GL_SCISSOR_TEST);
glScissor(100, 100, 1, 1); // position of pixel
glDrawArrays(GL_TRIANGLES, 0, 6);
glDisable(GL_SCISSOR_TEST);
I wrote a tiny graphics rendering class built on top of OpenGL that has code doing exatly that. Its core function is putPixel(), which receives the x/y coordinates and a color to draw a single pixel on the screen. Feel free to take a look at the code: https://github.com/amengol/MinGL

Related

drawing several triangles with different colours with one glDrawArrays command

I'm trying to write something in OpenGL, and I'm a beginner so sorry for any mistakes I make.
in general I just wanted to draw two triangles with different colours and I did using the following code:
float vertices[] = {
-0.5f, -0.6f, 0.0f,
0.5f, -0.6f, 0.0f,
0.4f, 0.5f, 0.0f,
0.5f, 0.6f, 0.0f,
-0.5f, 0.6f, 0.0f,
-0.4f, -0.5f, 0.0f
};
void display() {
std::cout << "frame";
glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Set background color to black and opaque
glClear(GL_COLOR_BUFFER_BIT); // Clear the color buffer
// activate and specify pointer to vertex array
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, vertices);
// draw a cube
glColor3f(1.0f, 0.0f, 0.0f); // Red
glDrawArrays(GL_TRIANGLES, 0, 3);
//glColor3f(0.0f, 1.0f, 0.0f); // Green
glDrawArrays(GL_TRIANGLES, 3, 3);
glDisableClientState(GL_VERTEX_ARRAY);
glFlush(); // Render now
}
int main(int argc, char** argv) {
glutInit(&argc, argv); // Initialize GLUT
glutCreateWindow("OpenGL Setup Test"); // Create a window with the given title
glutInitWindowSize(320, 320); // Set the window's initial width & height
glutInitWindowPosition(50, 50); // Position the window's initial top-left corner
glutDisplayFunc(display); // Register display callback handler for window re-paint
glutMainLoop(); // Enter the infinitely event-processing loop
return 0;
}
now.. if I . want to draw both triangles in the same command I can do
glDrawArrays(GL_TRIANGLES, 0, 6);
but then it draws the two triangles in the same colour.
is there a way to draw each triangle in a different colour by still using only one glDrawArrays() command?
if not.. is there some other command I should go for ?
thank you
In the description of glDrawArrays it is written :
Instead of calling a GL procedure to pass each individual vertex attribute, you can use glVertexAttribPointer to prespecify separate arrays of vertices, normals, and colors and use them to construct a sequence of primitives with a single call to glDrawArrays.
Is that your solution ?
"if not.. is there some other command I should go for ?" Fixed function attributes and client-side capability is deprecated since decades.See Fixed Function Pipeline and Legacy OpenGL.
Read about Vertex Specification and Shader for a state of the art way of rendering.
Anyway you can define an array of color attributes by glColorPointer, so each vertex coordinate is associated to an individual color attribute:
float colors[] = {
1.0f, 0.0f, 0.0f, // red
1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, // green
0.0f, 1.0f, 0.0f,
0.0f, 1.0f, 0.0f
};
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, vertices);
glEnableClientState(GL_COLOR_ARRAY);
glColorPointer(3, GL_FLOAT, 0, colors);
glDrawArrays(GL_TRIANGLES, 0, 6);

OpenGL texture is all black when rendered with shader

I have a very simple OpenGL application that renders only one textured quad. This is my code, which works just fine (the textured quad appears just fine):
// Bind the test texture
glBindTexture(GL_TEXTURE_2D, mTestTexture);
// Draw the quad
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(x, y + (float)height, 0.0f);
glTexCoord2f(1.0f, 0.0f);
glVertex3f(x + (float)width, y + (float)height, 0.0f);
glTexCoord2f(1.0f, 1.0f);
glVertex3f(x + (float)width, y, 0.0f);
glTexCoord2f(0.0f, 1.0f);
glVertex3f(x, y, 0.0f);
glEnd();
Then I wanted to intoduce a simple shader. So I modified my code a little:
// Use shader and point it to the right texture
auto texLocation = glGetUniformLocation(mProgram, "tex");
glUseProgram(mProgram);
glUniform1i(texLocation, mTestTexture);
// Draw the quad
// Same drawing code as before...
Vertex shader:
void main(void)
{
gl_Position = ftransform();
gl_TexCoord[0] = gl_MultiTexCoord0;
}
Fragment shader:
uniform sampler2D tex;
void main()
{
vec4 color = texture2D(tex, gl_TexCoord[0].st);
gl_FragColor = color;
}
Now all I get is a black quad :-(
I already tried and tested a lot of things:
The shaders compile fine (no errors)
The quad is visible (vertex shader seems OK)
If I change the shader to produce a fixed color ("gl_FragColor = vec4(1,0,0,1);") my quad becomes red -> fragment shader is doing something!
glGetError() does not return any errors
My texLocation, mProgram and mTestTexture all seem to be valid IDs
Does anyone have an idea why I won't see my texture when using the shader?
glUniform1i(texLocation, mTestTexture);
^^^^^^^^^^^^ texture object
Texture unit indexes are bound to samplers, not texture objects.
Use texture unit zero instead:
glUniform1i(texLocation, 0);

How to change fragment shader color between renders?

I am struggling with coding this simple boat scene. It is a homework question but I am truly stumped. I have two models which I upload. One is a cube which has a fragment shader to color itself blue. The second is a boat which has a fragment shader to color itself white. When I use two different shaders the boat model is invisible. With much struggling and searching
I am stumped so I am trying plan B which is find a way to change the colors of a fragment shader between rendering the two objects, but I can't find out how to do so.
void render() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//BOAT START
//Rocks the ship, simulating ocean rocking
if(shiprocker < 5000){
shiprocker++;
theta += 0.00002f;
}
if(shiprocker ==15000){
shiprocker = -5000;
}
if(shiprocker > 4999){
shiprocker++;
theta -= 0.00002f;
}
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
boat_model->mR = glm::rotate(
glm::mat4( 1.0f ),
glm::degrees( theta ),
glm::vec3(0.0f, 0.0f, 1.0f)
);
glm::mat4 mtx_trans = glm::translate(
glm::mat4(1.0f),
glm::vec3( 0.0f, 0.0f, -15.0f )
);
boat_model->mM = mtx_trans * boat_model->mR;
boat_model->render();
//BOAT END
//OCEAN CUBE START
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glm::mat4 mtx_trans_cube = glm::translate(
glm::mat4( 1.0f ),
glm::vec3( -20.0f, -50.0f, -50.0f )
);
plane_model->mM = glm::scale(
mtx_trans_cube,
glm::vec3( 10.0f, 10.0f, 10.0f )
);
//gl_FragColor = (0.0f, 0.0f, 1.0f , 1.0f); wont compile
//glColor3f(0.0f, 0.0f, 1.0f); changes nothing
camera->set_uniform_view_perspective( plane_model->shader->program_ID );
plane_model->render();
//OCEAN CUBE END
glutSwapBuffers();
}
int main (int argc, char** argv) {
// Initialize GLUT
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA|GLUT_DEPTH|GLUT_MULTISAMPLE | GLUT_RGB);
//WINDOW SETTINGS
glutInitWindowSize(1000, 1000);
glutCreateWindow("SailBoat");
//PASSIVE FUNCS
glutReshapeFunc(change_viewport);
glutDisplayFunc(render);
glutIdleFunc( animate );
//ERROR CHECK
if (GLEW_OK != glewInit()) {
exit(1);
}
//Clear color used for sky tones.
glClearColor(0.529f, 0.807f, .98f, 1.0f);
glEnable (GL_DEPTH_TEST);
glEnable (GL_MULTISAMPLE);
Shader* boatShader = new Shader( VERTEX_SHADER, BOAT_FRAGMENT_SHADER );
Shader* cubeShader = new Shader( VERTEX_SHADER, CUBE_FRAGMENT_SHADER );
//BOAT
boat_model = new Model(boatShader);
load_model(boat_model ,MODEL_BOAT_FILENAME);
boat_model->upload_2_server();
//OCEAN CUBE
plane_model = new Model( boatShader );
load_model(plane_model ,MODEL_PLANE_FILENAME);
plane_model->upload_2_server();
// Set up the camera
theta = 0.0f;
shiprocker = 0;
camera = new FPSCamera(60.0f, 1.0f, 1.0f, 10000.0f, true);
glutMainLoop();
return 0;
}
FRAGMENT SHADER
#version 150
in vec4 color;
out vec4 fColor;
void main () {
fColor = vec4(1.0, 1.0, 1.0, 0.5);
}
You can use uniform variables in GLSL to pass in values in between render calls. Set up your fragment shader like so:
#version 150
in vec4 color;
out vec4 fColor;
uniform vec3 boatColor;
void main () {
fColor = vec4(boatColor, 0.5);
}
And in your C++ code:
glUseProgram(program); // Where program is your shader program
GLint uniform = glGetUniformLocation(program, "boatColor"); // since boatColor is what we called the uniform variable in our fragment shader
glUniform3f(uniform, 1.0f, 0.0f, 0.0f); // Set the boatColor variable to be a solid red
// Render your first boat
glUniform3f(uniform, 0.0f, 0.0f, 1.0f); // Set the second boat to be a solid blue
// Render your second boat
glUseProgram(0);
And that should work nicely. If anyone else here has a better way, please let me know; I'm relatively new to GLSL.

How to display a sphere correctly in openGL

I don't know very much about openGL/glut, but I've used it before successfully for some exceedingly simple things in 2D.
Now I want to be able to draw spheres in 3D. I'm trying to simulate particle collisions, so all I'm really going to need to do on the graphics end is draw spheres.
Here's my abortive attempt
void renderScene()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
// Set the camera
gluLookAt(1.0f, 1.0f, 1.0f,
0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f);
glutSwapBuffers();
}
void timerProc(int arg)
{
glutTimerFunc(50,timerProc,0);
// Reset transformations
glLoadIdentity();
// Set the camera
gluLookAt(1.0f, 1.0f, 1.0f,
0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f);
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
glColor3f(0.0,0.0,0.0); //color = black
glPushMatrix();
glTranslated(0,0,0);
glutSolidSphere(.74, 500, 500);
glPopMatrix();
glutSwapBuffers();
}
int main(int argc, char **argv)
{
srand(time(NULL));
init();
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(50,30);
glutInitWindowSize(glutGet(GLUT_SCREEN_WIDTH)-80,glutGet(GLUT_SCREEN_HEIGHT)-60);
mainWindow=glutCreateWindow("New Window"); //global variable
WIDTH=glutGet(GLUT_WINDOW_WIDTH); //global variable
HEIGHT=glutGet(GLUT_WINDOW_HEIGHT); //global variable
glutDisplayFunc(renderScene);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glutTimerFunc(50,timerProc,0);
glutMainLoop();
return 0;
}
Hopefully all of my problems stem from one really basic mistake...
For some reason, this creates an oval. And, though the oval is pretty big (maybe about an 1/8th of the screen wide and tall), if I lower the radius down to .73 it vanishes, I'm guessing because it's too small to see.
How would I make it so that this sphere would show up circular like you'd expect, and so that as I can see everything that's happening in a given volume, say a 10x10x10 box, the way you would if you were just standing next to a box of particles that were flying around and peering into it, or a reasonable approximation. Right now it's hard to tell what exactly I'm looking at (I know that I'm standing at 1,1,1 and looking at the origin, but it's hard to grasp exactly what I'm seeing)
Also, occasionally when I run it the whole screen is just black. Then when I clean and build and run again it's fine. Not really a huge concern, but annoying, and I'd love to understand what was going on.
Also, when I the number of slices and stacks was lower, it would look fine if the radius was large, but become extremely distorted when the radius was small, which I thought was very strange...
The main problem you are having here is Z clipping. The initial Z range for the scene is (-1, 1) so you only see a part of the actual sphere and by change in its size you go out of z range.
Image
There are several problems I see in the code.
It is good to get a grasp of how the GLUT workflow actually works.
Lets see what the code does wrong.
Main
int main(int argc, char **argv)
{
srand(time(NULL));
init();
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(50, 30);
glutInitWindowSize(glutGet(GLUT_SCREEN_WIDTH) - 80,
glutGet(GLUT_SCREEN_HEIGHT) - 60);
mainWindow = glutCreateWindow("New Window"); //global variable
WIDTH = glutGet(GLUT_WINDOW_WIDTH); //global variable
HEIGHT = glutGet(GLUT_WINDOW_HEIGHT); //global variable
glutDisplayFunc(renderScene);
Here you define the display function. It is called every time the window contents has to be invalidated. In this case it is invalidated only at start. The renderScene function does not do anything awesome, just clears the screen. So you get a black screen at the beginning.
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
No need for blending at the moment. You can skip that part altogether.
glutTimerFunc(50, timerProc, 0);
Now you set up the timerProc function to be called in 50 milliseconds.
glutMainLoop();
As the documentation states: glutMainLoop enters the GLUT event processing loop. This routine should be called at most once in a GLUT program. Once called, this routine will never return. It will call as necessary any callbacks that have been registered.
return 0;
}
Render Scene
void renderScene()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
This is the only place where you clear the screen. Timer Func does not do this.
glLoadIdentity();
You are reseting the matrices.
// Set the camera
gluLookAt(1.0f, 1.0f, 1.0f,
0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f);
Setting up the matrices. (One matrix to be precise)
glutSwapBuffers();
And without drawing anything you swap buffers.
}
Scene rendering function is called each time the window frame has to be redrawn.
Timer
This function does rely on the screen being cleared at first by the renderScene.
void timerProc(int arg)
{
glutTimerFunc(50, timerProc, 0);
// Reset transformations
glLoadIdentity();
// Set the camera
gluLookAt(1.0f, 1.0f, 1.0f,
0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f);
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
Not clearing this time. Only setting the color.
glColor3f(0.0, 0.0, 0.0); //color = black
glPushMatrix();
glTranslated(0, 0, 0);
glutSolidSphere(.74, 500, 500);
glPopMatrix();
glutSwapBuffers();
}
How to fix it?
Just setup the matrices. With proper Z range.
void resetTransformations() {
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-1, 1, -1, 1, -1000, 1000);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(1.0f, 1.0f, 1.0f,
0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f);
}
void renderScene()
{
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Reset transformations
resetTransformations();
// Just to see some triangles
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glColor3f(0.0, 0.0, 0.0); //color = black
glPushMatrix();
glTranslated(0, 0, 0);
glutSolidSphere(0.74, 500, 500);
glPopMatrix();
glutSwapBuffers();
}
int main(int argc, char **argv)
{
srand(time(NULL));
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(50, 30);
glutInitWindowSize(256, 256);
mainWindow = glutCreateWindow("New Window"); //global variable
WIDTH = glutGet(GLUT_WINDOW_WIDTH); //global variable
HEIGHT = glutGet(GLUT_WINDOW_HEIGHT); //global variable
glutDisplayFunc(renderScene);
glutIdleFunc(renderScene);
glutMainLoop();
return 0;
}

Sending two textures to GLSL shader

When sending two textures to my GLSL shader only one actually arrives. What is strange is the first texture I bind is used for both textures slots in my shader. This leads me to believe the way I am passing my textures in OpenGL is wrong. However, I am unable to track down the problem.
Here is the code where I configure the textures for use in my shader.
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo2);
glPushAttrib(GL_VIEWPORT_BIT | GL_ENABLE_BIT);
glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Get uniforms
GLuint pass_3O = glGetUniformLocation(blend_shader, "org");
GLuint pass_3B = glGetUniformLocation(blend_shader, "blur");
// Activate shaders
glUseProgram(blend_shader);
// Bind first texture
glActiveTexture(GL_TEXTURE0 );
glBindTexture(GL_TEXTURE_2D, init_texture);
// Bind the second texture
glActiveTexture(GL_TEXTURE1 );
glBindTexture(GL_TEXTURE_2D, third_texture);
// Assign index to 2d images
glUniform1i(pass_3O, 0);
glUniform1f(pass_3B, 1);
The code above is passing in two textures. The first is a 2D image of the first rendering pass of the 3D scene. The third is that same texture with x2 levels of blur added. This final stage is to blend them together for a poor mans bloom.
Here is the code where I am drawing both textures to the quad.
// Draw to quad
glBegin(GL_QUADS);
glMultiTexCoord2f(GL_TEXTURE0, 0.0f, 0.0f);
glMultiTexCoord2f(GL_TEXTURE1, 0.0f, 0.0f);
glVertex3f(-w_width/2.0, -w_height/2.0, 0.5f);
glMultiTexCoord2f(GL_TEXTURE0, 0.0f, 1.0f);
glMultiTexCoord2f(GL_TEXTURE1, 0.0f, 1.0f);
glVertex3f(-w_width/2.0, w_height/2.0, 0.5f);
glMultiTexCoord2f(GL_TEXTURE0, 1.0f, 1.0f);
glMultiTexCoord2f(GL_TEXTURE1, 1.0f, 1.0f);
glVertex3f(w_width/2.0, w_height/2.0, 0.5f);
glMultiTexCoord2f(GL_TEXTURE0, 1.0f, 0.0f);
glMultiTexCoord2f(GL_TEXTURE1, 1.0f, 0.0f);
glVertex3f(w_width/2.0, -w_height/2.0, 0.5f);
glEnd();
glFlush();
glPopAttrib();
// Unbind textures
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, 0);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, 0);
// Disable blend shader
glUseProgram(0);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,0);
And here is the shader I am using to render the final image.
Vert
#version 120
void main()
{
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_TexCoord[1] = gl_MultiTexCoord1;
gl_Position = ftransform();
}
Frag
#version 120
uniform sampler2D org;
uniform sampler2D blur;
void main()
{
vec4 orig_clr = texture2D( org, gl_TexCoord[0].st);
vec4 blur_clr = texture2D( blur, gl_TexCoord[1].st );
//gl_FragColor = orig_clr;
gl_FragColor = blur_clr;
}
If I switch between the last two lines in the fragment shader I get the same exact results. The only way to change which texture gets render is to change the order in which I bind them.
For example, the following would finally pass me the blurred image. Once again, only getting one of the two images.
glActiveTexture(GL_TEXTURE0 );
glBindTexture(GL_TEXTURE_2D, third_texture);
glActiveTexture(GL_TEXTURE1 );
glBindTexture(GL_TEXTURE_2D, init_texture);
Any thoughts on what I am overlooking?
Look at this code:
glUniform1i(pass_3O, 0);
glUniform1f(pass_3B, 1);
you have some small typo here, it should be glUniform1*i* instead of Uniform1*f* in the second call. The type must match that of the shader variable, so this call should just result in some error, leaving the uniform initialized at 0, which completely explains your results.