Skip to content

Instantly share code, notes, and snippets.

@jvcleave
Created July 31, 2016 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jvcleave/7ad83dde34acf30f7b7d4d2b1c847892 to your computer and use it in GitHub Desktop.
Save jvcleave/7ad83dde34acf30f7b7d4d2b1c847892 to your computer and use it in GitHub Desktop.
fbo checkerboard
fbo.allocate(256, 256);
fbo.begin();
ofClear(0);
int step = 16;
int numRows, numCols;
numRows = numCols = fbo.getWidth() / step;
ofColor color1 = ofColor::white;
ofColor color2= ofColor::black;
ofColor lastColor = color1;
for (int y = 0; y < numRows; y++)
{
for (int x = 0; x < numCols; x++)
{
ofSetColor(lastColor);
ofDrawRectangle(x * step, y * step, step, step);
if(lastColor == color1)
{
lastColor = color2;
}else
{
lastColor = color1;
}
if (x + 1 == numCols && x % 2 != 0)
{
if(lastColor == color1)
{
lastColor = color2;
}else
{
lastColor = color1;
}
}
}
}
@jvcleave
Copy link
Author

jvcleave commented Aug 1, 2016

    ofFbo::Settings settings;
    settings.width = 256;
    settings.height = 256;

    settings.textureTarget = GL_TEXTURE_RECTANGLE_ARB;          // GL_TEXTURE_2D or GL_TEXTURE_RECTANGLE_ARB
    settings.internalformat = GL_RGBA;          // GL_RGBA, GL_RGBA16F_ARB, GL_RGBA32F_ARB, GL_LUMINANCE32F_ARB etc.
    settings.depthStencilInternalFormat = GL_DEPTH_STENCIL;     // GL_DEPTH_COMPONENT(16/24/32)
    settings.wrapModeHorizontal = GL_CLAMP_TO_EDGE;     // GL_REPEAT, GL_MIRRORED_REPEAT, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_BORDER etc.
    settings.wrapModeVertical = GL_CLAMP_TO_EDGE;       // GL_REPEAT, GL_MIRRORED_REPEAT, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_BORDER etc.
    settings.minFilter = GL_LINEAR;             // GL_NEAREST, GL_LINEAR etc.
    settings.maxFilter = GL_LINEAR;             // GL_NEAREST, GL_LINEAR etc.
    settings.numSamples=0;              // number of samples for multisampling (set 0 to disable)

if 0

    stringstream info;
    info << "GL_TEXTURE_RECTANGLE_ARB: " << GL_TEXTURE_RECTANGLE_ARB << endl;
    info << "GL_TEXTURE_2D: " << GL_TEXTURE_2D << endl;
    info << "GL_REPEAT: " << GL_REPEAT << endl;
    info << "GL_CLAMP_TO_EDGE: " << GL_CLAMP_TO_EDGE << endl;
    info << "GL_NEAREST: " << GL_NEAREST << endl;
    info << "GL_LINEAR: " << GL_LINEAR << endl;
    info << "GL_RGBA: " << GL_RGBA <<endl;
    ofLogVerbose() << info.str();


textureTarget: GL_TEXTURE_RECTANGLE_ARB
internalformat: GL_RGBA
wrapModeHorizontal: GL_CLAMP_TO_EDGE
minFilter: GL_LINEAR
depthStencilInternalFormat: GL_DEPTH_STENCIL

endif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment