Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libs/openFrameworks/app/ofAppNoWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ class ofNoopRenderer: public ofBaseRenderer{
void enablePointSprites(){};
void disablePointSprites(){};
void setDepthTest(bool){};
void setDepthWrite(bool write){};

// color options
void setColor(float r, float g, float b){}; // 0-1
Expand Down
5 changes: 5 additions & 0 deletions libs/openFrameworks/gl/ofGLProgrammableRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,11 @@ void ofGLProgrammableRenderer::setDepthTest(bool depthTest) {
}
}

//----------------------------------------------------------
void ofGLProgrammableRenderer::setDepthWrite(bool write) {
glDepthMask(write);
}

//----------------------------------------------------------
void ofGLProgrammableRenderer::setLineSmoothing(bool smooth) {
currentStyle.smoothing = smooth;
Expand Down
1 change: 1 addition & 0 deletions libs/openFrameworks/gl/ofGLProgrammableRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ class ofGLProgrammableRenderer: public ofBaseGLRenderer{
void setLineWidth(float lineWidth);
void setPointSize(float pointSize);
void setDepthTest(bool depthTest);
void setDepthWrite(bool write);
void setLineSmoothing(bool smooth);
void setBlendMode(ofBlendMode blendMode);
void enablePointSprites();
Expand Down
5 changes: 5 additions & 0 deletions libs/openFrameworks/gl/ofGLRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1275,6 +1275,11 @@ void ofGLRenderer::setDepthTest(bool depthTest) {
}
}

//----------------------------------------------------------
void ofGLRenderer::setDepthWrite(bool write) {
glDepthMask(write);
}

//----------------------------------------------------------
void ofGLRenderer::setLineSmoothing(bool smooth) {
currentStyle.smoothing = smooth;
Expand Down
1 change: 1 addition & 0 deletions libs/openFrameworks/gl/ofGLRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ class ofGLRenderer: public ofBaseGLRenderer{
void setLineWidth(float lineWidth);
void setPointSize(float pointSize);
void setDepthTest(bool depthTest);
void setDepthWrite(bool write);
void setLineSmoothing(bool smooth);
void setBlendMode(ofBlendMode blendMode);
void enablePointSprites();
Expand Down
1 change: 1 addition & 0 deletions libs/openFrameworks/graphics/ofCairoRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class ofCairoRenderer: public ofBaseRenderer{
void enablePointSprites() {};
void disablePointSprites() {};
void setDepthTest(bool depthTest);
void setDepthWrite(bool write) {};
void setBlendMode(ofBlendMode blendMode);
void setLineSmoothing(bool smooth);
void enableAntiAliasing();
Expand Down
9 changes: 7 additions & 2 deletions libs/openFrameworks/graphics/ofGraphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,11 @@ void ofDisableDepthTest() {
ofSetDepthTest(false);
}

//----------------------------------------------------------
void ofSetDepthWrite(bool write) {
ofGetCurrentRenderer()->setDepthWrite(write);
}

//----------------------------------------
void ofSetCurveResolution(int res) {
ofGetCurrentRenderer()->setCurveResolution(res);
Expand Down Expand Up @@ -1213,7 +1218,7 @@ void ofDrawBitmapStringHighlight(string text, int x, int y, const ofColor & back
int width = maxLineLength * fontSize;

ofPushStyle();
glDepthMask(false);
ofSetDepthWrite(false);
ofSetColor(background);
ofFill();
ofPushMatrix();
Expand All @@ -1231,7 +1236,7 @@ void ofDrawBitmapStringHighlight(string text, int x, int y, const ofColor & back
ofSetColor(foreground);
ofNoFill();
ofDrawBitmapString(text, x, y);
glDepthMask(true);
ofSetDepthWrite(true);
ofPopStyle();
}

Expand Down
4 changes: 4 additions & 0 deletions libs/openFrameworks/graphics/ofGraphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,10 @@ void ofEnableDepthTest();
/// \sa ofEnableDepthTest()
void ofDisableDepthTest();

/// \brief Enable / disable writing to the depth buffer.
/// Helpful when drawing transparent objects while depth testing is enabled.
void ofSetDepthWrite(bool write);

/// \brief Sets and enables the blend mode for drawing. The options are:
///
/// OF_BLENDMODE_DISABLED
Expand Down
3 changes: 3 additions & 0 deletions libs/openFrameworks/graphics/ofGraphicsBaseTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,9 @@ class ofBaseRenderer {
///
/// \param depthTest True to enable depth testing.
virtual void setDepthTest(bool depthTest) = 0;

/// \brief Enable / disable writing to the depth buffer.
virtual void setDepthWrite( bool write ) = 0;

/// \brief Set this renderer's current blend mode.
///
Expand Down
6 changes: 6 additions & 0 deletions libs/openFrameworks/graphics/ofRendererCollection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,12 @@ void ofRendererCollection::setDepthTest(bool depthTest) {
}
}

void ofRendererCollection::setDepthWrite(bool write) {
for(auto renderer: renderers){
renderer->setDepthWrite(write);
}
}

void ofRendererCollection::setBlendMode(ofBlendMode blendMode){
for(auto renderer: renderers){
renderer->setBlendMode(blendMode);
Expand Down
1 change: 1 addition & 0 deletions libs/openFrameworks/graphics/ofRendererCollection.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ class ofRendererCollection: public ofBaseRenderer{
void setLineWidth(float lineWidth);
void setPointSize(float pointSize);
void setDepthTest(bool depthTest);
void setDepthWrite(bool write);

void setBlendMode(ofBlendMode blendMode);
void setLineSmoothing(bool smooth);
Expand Down
Loading