Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7728505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:44:03+00:00 2026-06-01T05:44:03+00:00

I’m trying to get my rendering-to-texture working. So far, it does all the necessary

  • 0

I’m trying to get my rendering-to-texture working. So far, it does all the necessary GL gubbins to draw on the texture and everything – the only problem is its getting the scaling all off.

I figured I’d want to set the viewport to the size of the texture, and the gluOrtho2d (the way I’m going to be drawing onto the texture) as -halfwidth, halfwidth, -halfheight, halfheight. This means when drawing position 0,0 should be in the center. A position of halfwdith, halfheight should be in the top right corner etc etc.

I’m getting really weird effects though, it seems that its not drawing on the texture in the right scale – so everything gets skewed, can anyone suggest what I might be doing wrong?

Thanks

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());
      if (mFrameBuffer == -1)
      {
        return;
      }
      gl11ep.glBindFramebufferOES(GL11ExtensionPack.GL_FRAMEBUFFER_OES, mFrameBuffer);

      int halfWidth = texture.getWidth()/2;//width/2;
      int halfHeight = texture.getHeight()/2;//height/2;

      gl.glViewport(0,0,texture.getWidth(), texture.getHeight());
      gl.glLoadIdentity();

      GLU.gluOrtho2D(gl, -halfWidth, halfWidth , -halfHeight, halfHeight);

      gl.glMatrixMode(GL10.GL_MODELVIEW);
      gl.glLoadIdentity();

      gl.glClearColor(0f, 1f, 0f, 1f);
      gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);

      //draw the old version of the texture to framebuffer:
      Quad quad = new Quad(texture.getWidth(), texture.getHeight());
      quad.setTexture(texture);

      SpriteRenderable sr = new SpriteRenderable(quad);
      sr.renderTo(glRenderer, gl, 1);

      //draw the new gl objects etc to framebuffer
      for (Renderable renderable : renderThese)
      {
        if (renderable.isVisible()) {
          renderable.renderTo(glRenderer, gl, 1);
        }
      }

      //default to the old framebuffer
      gl11ep.glBindFramebufferOES(GL11ExtensionPack.GL_FRAMEBUFFER_OES, 0);
    }
  }

images:

This one is the game prior to any texture rendering.

image1

This is after the “blood splats” (currently pigs!) are rendered on the “arena” background texture shown in picture 1. Notice that the original texture has shrunk too small to see in the middle (its a few pixles) and the pig “blood splat” jumps in a zig-zag, flipping over the center of the texture and becoming smaller…

image2

(sorry, dont have enough rep to post images in the post!)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T05:44:05+00:00Added an answer on June 1, 2026 at 5:44 am

    Just a speculative guess, but do you remember to set matrixMode to GL_PROJECTION prior to entering renderToTexture function? It’s not set inside the function, where it seems like it should be. Also don’t forget to restore projection matrix and viewport at the end of the function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to render a haml file in a javascript response like so:
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Does anyone know how can I replace this 2 symbol below from the string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.