Hi
I’m running into a basic problem of sending ofTexture with custom data to shader. I modified the simple quad example. I expected a noisy visual but instead get a black screen. Any idea whats wrong? I’m using of_v0.11.2_linux64gcc6_release
ofApp.h
#pragma once
#include "ofMain.h"
class ofApp : public ofBaseApp{
public:
void setup();
void update();
void draw();
void keyPressed(int key);
void keyReleased(int key);
void mouseMoved(int x, int y);
void mouseDragged(int x, int y, int button);
void mousePressed(int x, int y, int button);
void mouseReleased(int x, int y, int button);
void windowResized(int w, int h);
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);
ofShader shader;
ofTexture noise;
};
OK glad you have a main.cpp that calls for a programmable pipeline.
oF has a default name of tex0 (zero not “oh”) for the texture (sampler2DRect ?). Calling .bind() or .draw() on various objects will result in them arriving in the shader with the name of tex0. So, you can either call ofTexture::bind() and change the name of the texture in the shader to tex0, or you can send the texture with a specific name with ofShader::setUniformTexture(). Drawing the rectangle sends some texcoord into the shader, which also happens if ofTexture()::draw() is called (instead of .bind()).
Also, the shader code above uses normalized coordinates (0.0 - 1.0). So, if you get a screen that is a solid color (the color at (0, 0)), the texture does not have normalized coordinates. So just try using gl_FragCoord.xy in the call to texture(). Calling ofDisableArbTex() has something to do with using sampler2D (no arbitrary rectangles) and (probably) normalized coordinates.
Also I remember reading this forum thread about GL_LUMINANCE so you may need to pick a different type of format for the ofTexture.