| 133 | uint image_impl::size() const { return (uint)mPBOsize; } |
| 134 | |
| 135 | void image_impl::render(const int pWindowId, |
| 136 | const int pX, const int pY, const int pVPW, const int pVPH, |
| 137 | const glm::mat4 &pView, const glm::mat4 &pOrient) |
| 138 | { |
| 139 | CheckGL("Begin image_impl::render"); |
| 140 | |
| 141 | float xscale = 1.f; |
| 142 | float yscale = 1.f; |
| 143 | if (mKeepARatio) { |
| 144 | if (mWidth > mHeight) { |
| 145 | float trgtH = pVPW * float(mHeight)/float(mWidth); |
| 146 | float trgtW = trgtH * float(mWidth)/float(mHeight); |
| 147 | xscale = trgtW/pVPW; |
| 148 | yscale = trgtH/pVPH; |
| 149 | } else { |
| 150 | float trgtW = pVPH * float(mWidth)/float(mHeight); |
| 151 | float trgtH = trgtW * float(mHeight)/float(mWidth); |
| 152 | xscale = trgtW/pVPW; |
| 153 | yscale = trgtH/pVPH; |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | glm::mat4 strans = glm::scale(pView, glm::vec3(xscale, yscale, 1)); |
| 158 | |
| 159 | glDepthMask(GL_FALSE); |
| 160 | glEnable(GL_BLEND); |
| 161 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
| 162 | |
| 163 | mProgram.bind(); |
| 164 | |
| 165 | glUniform1i(mNumCIndex, gl::GLint(mFormatSize)); |
| 166 | glUniform1f(mAlphaIndex, mAlpha); |
| 167 | |
| 168 | // load texture from PBO |
| 169 | glActiveTexture(GL_TEXTURE0); |
| 170 | glUniform1i(mTexIndex, 0); |
| 171 | glBindTexture(GL_TEXTURE_2D, mTex); |
| 172 | // bind PBO to load data into texture |
| 173 | glBindBuffer(GL_PIXEL_UNPACK_BUFFER, mPBO); |
| 174 | glPixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| 175 | glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, mWidth, mHeight, mGLformat, mGLType, 0); |
| 176 | glPixelStorei(GL_UNPACK_ALIGNMENT, 4); |
| 177 | |
| 178 | glUniformMatrix4fv(mMatIndex, 1, GL_FALSE, glm::value_ptr(strans)); |
| 179 | |
| 180 | glUniform1f(mCMapLenIndex, (GLfloat)mUBOSize); |
| 181 | glBindBufferBase(GL_UNIFORM_BUFFER, 0, mColorMapUBO); |
| 182 | glUniformBlockBinding(mProgram.getProgramId(), mCMapIndex, 0); |
| 183 | |
| 184 | // Draw to screen |
| 185 | bindResources(pWindowId); |
| 186 | glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0); |
| 187 | unbindResources(); |
| 188 | |
| 189 | glBindTexture(GL_TEXTURE_2D, 0); |
| 190 | glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); |
| 191 | |
| 192 | // ubind the shader program |
nothing calls this directly
no test coverage detected