| 127 | } |
| 128 | |
| 129 | void histogram_impl::render(const int pWindowId, |
| 130 | const int pX, const int pY, const int pVPW, const int pVPH, |
| 131 | const glm::mat4& pView, const glm::mat4& pOrient) |
| 132 | { |
| 133 | CheckGL("Begin histogram_impl::render"); |
| 134 | glDepthMask(GL_FALSE); |
| 135 | glEnable(GL_BLEND); |
| 136 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
| 137 | |
| 138 | mProgram.bind(); |
| 139 | |
| 140 | glUniform1f(mYMaxIndex, mRange[3]); |
| 141 | glUniform1f(mNBinsIndex, (GLfloat)mNBins); |
| 142 | glUniformMatrix4fv(mMatIndex, 1, GL_FALSE, glm::value_ptr(pView)); |
| 143 | glUniform1i(mPVCIndex, mIsPVCOn); |
| 144 | glUniform1i(mPVAIndex, mIsPVAOn); |
| 145 | glUniform4fv(mBColorIndex, 1, mColor); |
| 146 | |
| 147 | /* render a rectangle for each bin. Same |
| 148 | * rectangle is scaled and translated accordingly |
| 149 | * for each bin. OpenGL instanced rendering is used to do it.*/ |
| 150 | histogram_impl::bindResources(pWindowId); |
| 151 | glDrawArraysInstanced(GL_TRIANGLE_FAN, 0, 4, mNBins); |
| 152 | histogram_impl::unbindResources(); |
| 153 | |
| 154 | mProgram.unbind(); |
| 155 | glDisable(GL_BLEND); |
| 156 | glDepthMask(GL_TRUE); |
| 157 | CheckGL("End histogram_impl::render"); |
| 158 | } |
| 159 | |
| 160 | } |
| 161 | } |