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 3952418
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:50:53+00:00 2026-05-20T01:50:53+00:00

I am just trying to understand what is going on here. I have a

  • 0

I am just trying to understand what is going on here. I have a textured quad on the screen but I am really confused why it takes up the entire screen. If my texture is 64X64 and I wanted a quad at the top left of the screen that was 64X64 what would I need to change? Is my viewport or my vertices positions causing it to take up the whole screen?

With changes so far:

public void onSurfaceCreated(GL10 gl, EGLConfig config) {

        myquad.loadGLTexture(gl, this.context);

        gl.glEnable(GL10.GL_BLEND);
        gl.glBlendFunc(gl.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
        gl.glEnable(GL10.GL_TEXTURE_2D);
        gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
        gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
        gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_FASTEST);
        gl.glDisable(GL10.GL_DEPTH_TEST);
    }

    public void onSurfaceChanged(GL10 gl, int w, int h) {
        width=w;
        height=h;
        gl.glViewport(0, 0, w, h);
        gl.glLoadIdentity();
        gl.glOrthof(0.0f, w, 0, h, -1.0f, 1.0f);        
    }

    public void onDrawFrame(GL10 gl) {
        // define the color we want to be displayed as the "clipping wall"
        gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
        // clear the color buffer to show the ClearColor we called above...
        gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
        gl.glLoadIdentity();

        myquad.Draw(gl);
        //gl.glTranslatef(.5f, 2.0f, 0.0f);
        //gl.glScalef(.5f, .5f, 0);
    }

private float vertices[] = {
         // Vertices for the square
          -1.0f, -1.0f,  0.0f,  // 0. left-bottom
           1.0f, -1.0f,  0.0f,  // 1. right-bottom
          -1.0f,  1.0f,  0.0f,  // 2. left-top
           1.0f,  1.0f,  0.0f   // 3. right-top
};

private float texture[] = {          
        //Mapping coordinates for the vertices
        0.0f, 1.0f,
        1.0f, 0.0f,
        1.0f, 1.0f,
        0.0f, 1.0f, 
};
public void Draw(GL10 gl)
{   
    // set the color for the triangle
    gl.glColor4f(0.0f, 1.0f, 0.0f, 0.5f);

    //Enable the vertex and texture state
    gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, texturebuffer);
    gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexbuffer);

    //gl.glTranslatex(-20, 0, 0);
    // Draw the vertices as triangle strip
    gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, vertices.length / 3);

}
  • 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-05-20T01:50:54+00:00Added an answer on May 20, 2026 at 1:50 am

    Right now you have your projection set up wrong. If you want to draw as if you were dealing with pixels, you would want…
    this line
    gl.glOrthof(0.0f, w, -h, 0.0f, -1.0f, 1.0f);
    to be more like this
    gl.glOrthof(0.0f, width, 0.0f, height, -1.0f, 1.0f);
    where width and height are the size of your context in pixels.

    EDIT:
    gl.glOrthof(0.0f, w, -h, 0.0f, -1.0f, 1.0f);
    has to be called after each call to glLoadIdentity().
    Now you have to adjust your vertex coords. As right now they are set up to render a 1px by 1px box 1px outside the bottom left corner of the screen.

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

Sidebar

Related Questions

Just trying to understand that - I have never used it before. How is
I am trying to understand if I really have any case for using git/mercurial.
OK, I have a question I'm too confused to ask properly but here's a
I'm trying to understand what's happening here: I have a supervisor that is cyclically
Am just trying to understand why this exception throws. Cannot implicitly convert type 'System.DateTime?'
I was just trying to understand delegates using the following code. public class delegatesEx
I am just trying to understand the extends keyword in Java Generics. List<? extends
I'm just trying to understand how does non-blocking recvfrom works? I'm writing an application
I grabbed this code form JCarousel and just trying to understand these lines below.
I've been a visual studio developer for long and just trying to understand how

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.