ofDocsdocumentation gl ofGLProgrammableRenderer

ofGLProgrammableRenderer

The OpenGL programable renderer is a renderer for OF that is built specifically to support both newer versions of OpenGL (3+) as well as supporting GLES, which is what you'll be using if you're running OF on an ARM Linux (i.e. Raspberry Pi), Android, or iOS device. There are a few key differences between OpenGL 3 and OpenGL 2 that are largely hidden from you by OF. You can still use the same methods for drawing, making meshes, uploading textures, and other drawing operations on the programmable renderer as you could on the direct pipeline, so you're not missing anything if you stick to the older pipeline. The most significant difference probably comes in writing GLSL shaders, since the syntax changes between the older implementation and the newer. One of the important things that the ofGLProgrammableRenderer adds is default shaders. That's right: every time you run your OF application, shaders are created and uploaded to the GPU without you even knowing it. There's also addition parameters that are automatically passed to the shader program that you can leverage if you're writing your own. Check out this chapter about OpenGL in the ofBook and this blog post for more information on using different OpenGL versions.

To initialize the ofGLProgrammableRenderer call ofSetCurrentRenderer() before you call ofSetupOpenGL() in your main.cpp file:

// say that we're going to *use* the fancy new renderer
ofSetCurrentRenderer(ofGLProgrammableRenderer::TYPE);
ofSetupOpenGL(1024,768, OF_WINDOW);         // <-------- setup the GL context

After that, things should remain the same for you whether you're using the older ofGLRenderer or the newer ofGLProgrammableRenderer.

Alternatively, in openFrameworks 0.9 you can directly set the OpenGL version as follows:

// main.cpp (openFrameworks 0.9)
int main(){
    ofGLWindowSettings settings;
    settings.setGLVersion(4,5); /// < select your GL Version here
    ofCreateWindow(settings); ///< create your window here
    ofRunApp(new ofApp());
}


background( ... )

void background(const ofColor &c)

background( ... )

void background(float brightness)

background( ... )

void background(int hexColor, float _a=255.0f)

background( ... )

void background(int r, int g, int b, int a=255)

begin( ... )

void begin(const ofFbo &fbo, ofFboMode mode)

beginDefaultShader( )

void beginDefaultShader()

bind( ... )

void bind(const ofCamera &camera, const ofRectangle &viewport)

bind( ... )

void bind(const ofFbo &fbo)

bind( ... )

void bind(const ofBaseMaterial &material)

bind( ... )

void bind(const ofShader &shader)

bind( ... )

void bind(const ofTexture &texture, int location)

bind( ... )

void bind(const ofBaseVideoDraws &video)

bindForBlitting( ... )

void bindForBlitting(const ofFbo &fboSrc, ofFbo &fboDst, int attachmentPoint)

clear( )

void clear()

clear( ... )

void clear(float brightness, float a)

clear( ... )

void clear(float r, float g, float b, float a)

clearAlpha( )

void clearAlpha()

defaultFragmentShaderHeader( ... )

string defaultFragmentShaderHeader(GLenum textureTarget)

defaultVertexShaderHeader( ... )

string defaultVertexShaderHeader(GLenum textureTarget)

disableAlphaMask( )

void disableAlphaMask()

disableAntiAliasing( )

void disableAntiAliasing()

disableLight( ... )

void disableLight(int lightIndex)

disableLighting( )

void disableLighting()

disablePointSprites( )

void disablePointSprites()

disableSeparateSpecularLight( )

void disableSeparateSpecularLight()

disableTextureTarget( ... )

void disableTextureTarget(int textureTarget, int textureLocation)

draw( ... )

void draw(const ofImage &image, float x, float y, float z, float w, float h, float sx, float sy, float sw, float sh)

draw( ... )

void draw(const ofFloatImage &image, float x, float y, float z, float w, float h, float sx, float sy, float sw, float sh)

draw( ... )

void draw(const ofShortImage &image, float x, float y, float z, float w, float h, float sx, float sy, float sw, float sh)

draw( ... )

void draw(const ofTexture &image, float x, float y, float z, float w, float h, float sx, float sy, float sw, float sh)

draw( ... )

void draw(const ofVboMesh &mesh, ofPolyRenderMode renderType)

draw( ... )

void draw(const of3dPrimitive &model, ofPolyRenderMode renderType)

draw( ... )

void draw(const ofNode &node)

draw( ... )

void draw(const ofPath &path)

draw( ... )

void draw(const ofPolyline &poly)

draw( ... )

void draw(const ofVbo &vbo, GLuint drawMode, int first, int total)

draw( ... )

void draw(const ofMesh &vertexData, ofPolyRenderMode renderType, bool useColors, bool useTextures, bool useNormals)

draw( ... )

void draw(const ofBaseVideoDraws &video, float x, float y, float w, float h)

drawCircle( ... )

void drawCircle(float x, float y, float z, float radius)

drawElements( ... )

void drawElements(const ofVbo &vbo, GLuint drawMode, int amt, int offsetelements=0)

drawElementsInstanced( ... )

void drawElementsInstanced(const ofVbo &vbo, GLuint drawMode, int amt, int primCount)

drawEllipse( ... )

void drawEllipse(float x, float y, float z, float width, float height)

drawInstanced( ... )

void drawInstanced(const ofVboMesh &mesh, ofPolyRenderMode renderType, int primCount)

drawInstanced( ... )

void drawInstanced(const ofVbo &vbo, GLuint drawMode, int first, int total, int primCount)

drawLine( ... )

void drawLine(float x1, float y1, float z1, float x2, float y2, float z2)

drawRectangle( ... )

void drawRectangle(float x, float y, float z, float w, float h)

drawString( ... )

void drawString(const ofTrueTypeFont &font, string text, float x, float y)

drawString( ... )

void drawString(string text, float x, float y, float z)

drawTriangle( ... )

void drawTriangle(float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3)

enableAntiAliasing( )

void enableAntiAliasing()

enableLight( ... )

void enableLight(int lightIndex)

enableLighting( )

void enableLighting()

enablePointSprites( )

void enablePointSprites()

enableSeparateSpecularLight( )

void enableSeparateSpecularLight()

enableTextureTarget( ... )

void enableTextureTarget(const ofTexture &tex, int textureLocation)

end( ... )

void end(const ofFbo &fbo)

endSmoothing( )

void endSmoothing()

finishRender( )

void finishRender()

get3dGraphics( )

const of3dGraphics & get3dGraphics()

get3dGraphics( )

of3dGraphics & get3dGraphics()

getBackgroundAuto( )

bool getBackgroundAuto()

getBackgroundColor( )

ofColor getBackgroundColor()

getCoordHandedness( )

ofHandednessType getCoordHandedness()

getCurrentMatrix( ... )

glm::mat4 getCurrentMatrix(ofMatrixMode matrixMode_)

Queries the current OpenGL matrix state

Returns the specified matrix as held by the renderer's current matrix stack.

You can query one of the following:

[OF_MATRIX_MODELVIEW | OF_MATRIX_PROJECTION | OF_MATRIX_TEXTURE]

Each query will return the state of the matrix as it was uploaded to the shader currently bound.

\param matrixMode_ Which matrix mode to query \note If an invalid matrixMode is queried, this method will return the identity matrix, and print an error message.


getCurrentNormalMatrix( )

glm::mat4 getCurrentNormalMatrix()

getCurrentOrientationMatrix( )

glm::mat4 getCurrentOrientationMatrix()

getCurrentShader( )

const ofShader & getCurrentShader()

getCurrentTextureTarget( )

GLenum getCurrentTextureTarget()

getCurrentViewMatrix( )

glm::mat4 getCurrentViewMatrix()

getCurrentViewport( )

ofRectangle getCurrentViewport()

getFillMode( )

ofFillFlag getFillMode()

getGLVersionMajor( )

int getGLVersionMajor()

getGLVersionMinor( )

int getGLVersionMinor()

getLightingEnabled( )

bool getLightingEnabled()

getNativeViewport( )

ofRectangle getNativeViewport()

getPath( )

ofPath & getPath()

getRectMode( )

ofRectMode getRectMode()

getStyle( )

ofStyle getStyle()

getType( )

const string & getType()

getVideoShader( ... )

const ofShader * getVideoShader(const ofBaseVideoDraws &video)

getViewportHeight( )

int getViewportHeight()

getViewportWidth( )

int getViewportWidth()

isVFlipped( )

bool isVFlipped()

loadIdentityMatrix( )

void loadIdentityMatrix()

loadMatrix( ... )

void loadMatrix(const glm::mat4 &m)

loadMatrix( ... )

void loadMatrix(const float *m)

loadViewMatrix( ... )

void loadViewMatrix(const glm::mat4 &m)

matrixMode( ... )

void matrixMode(ofMatrixMode mode)

multMatrix( ... )

void multMatrix(const glm::mat4 &m)

multMatrix( ... )

void multMatrix(const float *m)

multViewMatrix( ... )

void multViewMatrix(const glm::mat4 &m)

ofGLProgrammableRenderer( ... )

ofGLProgrammableRenderer(const ofAppBaseWindow *window)

popMatrix( )

void popMatrix()

popStyle( )

void popStyle()

popView( )

void popView()

pushMatrix( )

void pushMatrix()

pushStyle( )

void pushStyle()

pushView( )

void pushView()

rotateRad( ... )

void rotateRad(float radians)

rotateRad( ... )

void rotateRad(float radians, float vecX, float vecY, float vecZ)

rotateXRad( ... )

void rotateXRad(float radians)

rotateYRad( ... )

void rotateYRad(float radians)

rotateZRad( ... )

void rotateZRad(float radians)

saveFullViewport( ... )

void saveFullViewport(ofPixels &pixels)

saveScreen( ... )

void saveScreen(int x, int y, int w, int h, ofPixels &pixels)

scale( ... )

void scale(float xAmnt, float yAmnt, float zAmnt)

setAlphaBitmapText( ... )

void setAlphaBitmapText(bool bitmapText)

setAlphaMaskTex( ... )

void setAlphaMaskTex(const ofTexture &tex)

setAttributes( ... )

void setAttributes(bool vertices, bool color, bool tex, bool normals)

setBackgroundAuto( ... )

void setBackgroundAuto(bool bManual)

setBackgroundColor( ... )

void setBackgroundColor(const ofColor &c)

setBitmapTextMode( ... )

void setBitmapTextMode(ofDrawBitmapMode mode)

setBlendMode( ... )

void setBlendMode(ofBlendMode blendMode)

setCircleResolution( ... )

void setCircleResolution(int res)

setColor( ... )

void setColor(const ofColor &color)

setColor( ... )

void setColor(const ofColor &color, int _a)

setColor( ... )

void setColor(int gray)

setColor( ... )

void setColor(int r, int g, int b)

setColor( ... )

void setColor(int r, int g, int b, int a)

setCoordHandedness( ... )

void setCoordHandedness(ofHandednessType handedness)

setCurveResolution( ... )

void setCurveResolution(int resolution)

setDefaultUniforms( )

void setDefaultUniforms()

setDepthTest( ... )

void setDepthTest(bool depthTest)

setFillMode( ... )

void setFillMode(ofFillFlag fill)

setGlobalAmbientColor( ... )

void setGlobalAmbientColor(const ofColor &c)

setHexColor( ... )

void setHexColor(int hexColor)

setLightAmbientColor( ... )

void setLightAmbientColor(int lightIndex, const ofFloatColor &c)

setLightAttenuation( ... )

void setLightAttenuation(int lightIndex, float constant, float linear, float quadratic)

setLightDiffuseColor( ... )

void setLightDiffuseColor(int lightIndex, const ofFloatColor &c)

setLightPosition( ... )

void setLightPosition(int lightIndex, const glm::vec4 &position)

setLightSpecularColor( ... )

void setLightSpecularColor(int lightIndex, const ofFloatColor &c)

setLightSpotConcentration( ... )

void setLightSpotConcentration(int lightIndex, float exponent)

setLightSpotDirection( ... )

void setLightSpotDirection(int lightIndex, const glm::vec4 &direction)

setLightSpotlightCutOff( ... )

void setLightSpotlightCutOff(int lightIndex, float spotCutOff)

setLineSmoothing( ... )

void setLineSmoothing(bool smooth)

setLineWidth( ... )

void setLineWidth(float lineWidth)

setOrientation( ... )

void setOrientation(ofOrientation orientation, bool vFlip)

setPolyMode( ... )

void setPolyMode(ofPolyWindingMode mode)

setRectMode( ... )

void setRectMode(ofRectMode mode)

setSmoothLighting( ... )

void setSmoothLighting(bool b)

setStyle( ... )

void setStyle(const ofStyle &style)

setVideoShaderUniforms( ... )

void setVideoShaderUniforms(const ofBaseVideoDraws &video, const ofShader &shader)

setup( ... )

void setup(int glVersionMajor, int glVersionMinor)

setupGraphicDefaults( )

void setupGraphicDefaults()

setupScreen( )

void setupScreen()

setupScreenOrtho( ... )

void setupScreenOrtho(float width, float height, float nearDist, float farDist)

setupScreenPerspective( ... )

void setupScreenPerspective(float width, float height, float fov, float nearDist, float farDist)

startRender( )

void startRender()

startSmoothing( )

void startSmoothing()

translate( ... )

void translate(const glm::vec3 &p)

translate( ... )

void translate(float x, float y, float z)

unbind( ... )

void unbind(const ofCamera &camera)

unbind( ... )

void unbind(const ofFbo &fbo)

unbind( ... )

void unbind(const ofBaseMaterial &material)

unbind( ... )

void unbind(const ofShader &shader)

unbind( ... )

void unbind(const ofTexture &texture, int location)

unbind( ... )

void unbind(const ofBaseVideoDraws &video)

uploadCurrentMatrix( )

void uploadCurrentMatrix()

uploadMatrices( )

void uploadMatrices()

viewport( ... )

void viewport(ofRectangle viewport)

viewport( ... )

void viewport(float x, float y, float width, float height, bool vflip=true)

Variables

conststring TYPE
ofShader alphaMask2DShader
ofShader alphaMaskRectShader
int alphaMaskTextureTarget
bool bBackgroundAuto
ofBitmapFont bitmapFont
bool bitmapStringEnabled
ofShader bitmapStringShader
ofVboMesh circleMesh
ofPolyline circlePolyline
bool colorsEnabled
GLuint currentFramebufferId< the framebuffer id currently bound to the GL_FRAMEBUFFER target
constofBaseMaterial* currentMaterial
ofShader currentShader
ofStyle currentStyle
int currentTextureTarget
GLuint defaultFramebufferId< default GL_FRAMEBUFFER_BINDING, windowing frameworks might want to set this to their MSAA framebuffer, defaults to 0
ofShader defaultNoTexColor
ofShader defaultNoTexNoColor
ofShader defaultTex2DColor
ofShader defaultTex2DNoColor
ofShader defaultTexRectColor
ofShader defaultTexRectNoColor
ofShader defaultUniqueShader
of3dGraphics graphics3d
ofVboMesh lineMesh
int major
ofMatrixStack matrixStack
ofVbo meshVbo
int minor
bool normalsEnabled
ofPath path
ofVboMesh rectMesh
bool settingDefaultShader
ofShader shaderNV12
ofShader shaderNV12Rect
ofShader shaderNV21
ofShader shaderNV21Rect
ofShader shaderPlanarYUV
ofShader shaderPlanarYUVRect
ofShader shaderPlanarYUY2
ofShader shaderPlanarYUY2Rect
bool texCoordsEnabled
ofVboMesh triangleMesh
bool uniqueShader
bool usingCustomShader
bool usingVideoShader
bool verticesEnabled
constofAppBaseWindow* window
bool wrongUseLoggedOnce

Methods