I'm trying to render to a texture (really thought it would be easier than this!)
I found this resource: which seems to be exactly what I want
I'm getting a ClassCastException however, on GL11ExtensionPack gl11ep = (GL11ExtensionPack) gl;
Can anyone tell me why?
public void renderToTexture(GLRenderer glRenderer, GL10 gl)
{
boolean checkIfContextSupportsExtension = checkIfContextSupportsExtension(gl, "GL_OES_framebuffer_object");
if(checkIfContextSupportsExtension)
{
GL11ExtensionPack gl11ep = (GL11ExtensionPack) gl;
int mFrameBuffer = createFrameBuffer(gl,texture.getWidth(), texture.getHeight(), texture.getGLID());
gl11ep.glBindFramebufferOES(GL11ExtensionPack.GL_FRAMEBUFFER_OES, mFrameBuffer);
gl.glViewport(0, 0,texture.getWidth(), texture.getHeight());
gl.glLoadIdentity();
int halfWidth = texture.getWidth()/2;//width/2;
int halfHeight = texture.getHeight()/2;//height/2;
GLU.gluOrtho2D(gl, -halfWidth, halfWidth , -halfHeight, halfHeight);
gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glLoadIdentity();
gl.glEnable(GL10.GL_TEXTURE_2D);
Quad quad = new Quad(texture.getWidth(), texture.getHeight());
quad.setTexture(texture);
SpriteRenderable sr = new SpriteRenderable(quad);
//sr.setPosition(new Interpolation<Vector2>(new Vector2(-(float)texture.getWidth()/2f,-(float)texture.getHeight()/2f)));
//sr.setPosition(new Interpolation<Vector2>(new Vector2((float)(texture.getWidth()/2f),0)));
//sr.setPosition(new Interpolation<Vector2>(new Vector2(200,-200)));
sr.setAngle(0.05f);
sr.renderTo(glRenderer, gl, 1);
for (Renderable renderable : renderThese)
{
if (renderable.isVisible()) {
renderable.renderTo(glRenderer, gl, 1);
}
}
gl11ep.glBindFramebufferOES(GL11ExtensionPack.GL_FRAMEBUFFER_OES, 0);
}
}