Creating a checkered ground

Hello! I am kind of new to Cinder and the concepts around it.
I am trying to change the background to white and have a semi transparent ground on the XZ plane. Preferably I would try to have it checkered with 2 different tones of light grey.
How should I approach this?

Thank you for your time,

Hey buddy, I’m out on site doing an installation at the moment so I don’t have time to talk you through what this does, but I’ve knocked together a little sample app so you can at least see how one such approach might work. Good luck :slight_smile:

#include "cinder/app/App.h"
#include "cinder/app/RendererGl.h"
#include "cinder/ip/Checkerboard.h"
#include "cinder/CameraUi.h"
#include "cinder/gl/gl.h"

using namespace ci;
using namespace ci::app;

class BasicApp : public App
    void            setup ( ) override;
    void            draw  ( ) override;
    gl::BatchRef    _floor;
    CameraPersp     _camera;
    CameraUi        _cameraUi;
    gl::TextureRef  _texture;

void prepareSettings( App::Settings * settings )
    settings->setWindowSize ( 1280, 720 );

void BasicApp::setup ( )
    _camera = CameraPersp { getWindowWidth(), getWindowHeight(), 60.0f, 0.1f, 1000.0f };
    _camera.lookAt ( vec3 ( 0, 15, 25 ), vec3 ( 0 ) );
    _cameraUi = CameraUi { &_camera, getWindow() };
    _cameraUi.setMinimumPivotDistance ( 0.0f );
    auto fmt = gl::Texture::Format().mipmap().minFilter(GL_LINEAR_MIPMAP_LINEAR).magFilter(GL_LINEAR).wrap(GL_REPEAT);
    _texture = gl::Texture::create( ip::checkerboard ( 1024, 1024, 16, Colorf::gray(0.1f), Colorf::gray(0.8f) ), fmt );
    auto shader = gl::getStockShader( gl::ShaderDef().color().texture ( _texture ) );
    _floor = gl::Batch::create( geom::Plane().size ( vec2 ( 512 ) ).normal ( vec3 ( 0, 1, 0 ) ), shader );

void BasicApp::draw ( )
    gl::clear ( Colorf::white() );
        gl::setMatrices( _camera );
        gl::ScopedTextureBind tex0 { _texture, 0 };
        gl::ScopedDepth depth { true };
        gl::drawCoordinateFrame( 10.0f );

CINDER_APP ( BasicApp, RendererGl, prepareSettings )

First of all, thank you for your response! I have been on medical leave for a while so I couldn’t check it out or get back to you.
I’ve implemented your code and it worked beautifully, but rather than having black and while or other shades of gray, I had black and red.
I checked the color codes and everything seemed fine, so my guess is that it might be the shader doing something weird. Could you please give me your thoughts on the matter please?

This is a screenshot of the test project I made:

Thank you again for your time,

Looks like you might have an errant gl::color somewhere that’s modulating the colour. OpenGL is just a big state machine, so all the state stays the same until you tell it otherwise. Try adding this before _floor->draw();

gl::ScopedColor color { Colorf::white() };

Hope you’re on the mend,


Thank you very much! It worked.