Juce and Chromium Embedded Framework

opengl

#1

Hi,

I have got a basic integration of Juce and CEF here: https://github.com/abhijitnandy2011/JuceCEF/tree/master/glcef

It basically uses the CEF offscreen rendering feature to render into a buffer from which I writePixels() to a juce::OpenGLFrameBuffer. The texture is rendered onto a quad.

I am trying to figure out how to get a orthographic projection for a pixel perfect window size of 800 by 600.

I think I have got the shaders correct in: https://github.com/abhijitnandy2011/JuceCEF/blob/master/glcef/Source/MainComponent.cpp

And I have got a ortho projection matrix returned as follows when getting the projection matrix:

   /** Returns a new matrix from the given frustrum values. */
Matrix3D<float> orthoProjection(
	float left, float right, float bottom, float top, float nearDistance, float farDistance)
{
	return Matrix3D<float>(
		2.0f / (right - left),  // m00
		0.0f, // m10
		0.0f, // m20
		-(right + left) / (right - left),  // m30

		0.0f, // m01
		2.0f / (top - bottom), // m11
		0.0f,  // m21
		-(top + bottom) / (top - bottom),  // m31

		0.0f, // m02
		0.0f, // m12
		2.0f / (farDistance - nearDistance), // m22
		-(farDistance + nearDistance) / (farDistance - nearDistance),  // m32

		0.0f, // m03
		0.0f,  // m13
		0.0f,  // m23
		1.0f); // m33
}

But I still seem to get a view like this:

So I know its not orthographic because if I change the camera position, then the size of the rendered texture changes. Is this the fastest way to do this by the way(opengl texture + write pixels to the texture to show a dynamic image generated by another library)

Or maybe I should draw a bigger quad in the Vertex buffer as currently I use very small dimensions for the texture’s quad(30 by 15) as compared to the texture size of 800 by 600: https://github.com/abhijitnandy2011/JuceCEF/blob/master/glcef/Source/MainComponent.h#L149