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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:44:09+00:00 2026-05-30T10:44:09+00:00

If I run this code as it is, I see a line from the

  • 0

If I run this code as it is, I see a line from the bottom left corner of the screen to the top right corner of the screen. However, afaik I set glOrthox and glViewport, so why it’s using the default projection is a mystery to me… what’s wrong? the lower left of the screen should be 0,0, and 1,1 should be basically 1 pixel over and up into the screen.. not the whole screen.

package com.opengl.hello;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;

import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;

import android.content.Context;
import android.opengl.GLSurfaceView.Renderer;

public class Renderer2d implements Renderer {
    Context mContext;

    public static ByteBuffer newByteBuffer(int size)
    { return ByteBuffer.allocateDirect(size).order(ByteOrder.nativeOrder()); }

    public static FloatBuffer newFloatBuffer(int size)
    { return newByteBuffer(size * 4).asFloatBuffer(); }

    public static ByteBuffer newByteBuffer(byte[] buf)
    { ByteBuffer out=newByteBuffer(buf.length); out.put(buf).position(0); return out; }

    public static FloatBuffer newFloatBuffer(float[] buf)
    { FloatBuffer out=newFloatBuffer(buf.length); out.put(buf).position(0); return out; }

    public Renderer2d(Context context)
    {
        mContext=context;
    }

    int mWidth;
    int mHeight;
    @Override
    public void onDrawFrame(GL10 gl) {
        gl.glViewport(0, 0, mWidth, mHeight);
        // Reset projection
        gl.glMatrixMode(GL10.GL_PROJECTION);
        gl.glLoadIdentity();

        // Set up our ortho view
        gl.glOrthox(0, mWidth, 0, mHeight, 0, 0);

        // Reset model view
        gl.glMatrixMode(GL10.GL_MODELVIEW);

        gl.glLoadIdentity();
        gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

        // Build buffers sufficient to draw a single
        ByteBuffer indicesBuffer=newByteBuffer(new byte[] { 0, 1 });

        // PROBLEM: I expect this to draw a small line, from the bottom left to 1,1 (a single pixel over and up into the image).. 
        // as well as sticking off-screen down and to the left.  Instead, this covers the entire screen, corner to corner!
        FloatBuffer vertexBuffer=newFloatBuffer(new float[]{ -1.f, -1.f, 1.f, 1.f });

        // Enable vertex arrays, as we're about to use them
        gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);

        // Each point in the vertex buffer has two dimensions.
        gl.glVertexPointer(2, GL10.GL_FLOAT, 0, vertexBuffer);

        // Draw one point
        gl.glDrawElements(GL10.GL_LINES, 2, GL10.GL_UNSIGNED_BYTE, indicesBuffer);

        // No longer need vertex arrays
        gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
    }

    /**
     * If the surface changes, reset the view.
     */
    @Override
    public void onSurfaceChanged(GL10 gl, int width, int height)
    {
        mWidth=width;
        mHeight=height;
        // Moved code to onDrawFrame just to group everything together
    }

    /**
     * The Surface is created/init()
     */
    @Override
    public void onSurfaceCreated(GL10 gl, EGLConfig config) {
        // Yellow Background
        gl.glClearColor(1.0f, 1.0f, 0.0f, 0.0f);        
        // Disable dithering for better performance
        gl.glDisable(GL10.GL_DITHER);
        // enable texture mapping
        gl.glEnable(GL10.GL_TEXTURE_2D);          
        //enable transparency blending
        gl.glEnable(GL10.GL_BLEND);
        // use opaque texturing 
        gl.glBlendFunc(GL10.GL_ONE, GL10.GL_SRC_COLOR);
        // Disable the depth buffer, we're drawing in 2D.
        gl.glDisable(GL10.GL_DEPTH_TEST);
        // Smooth shading
        gl.glShadeModel(GL10.GL_SMOOTH);
        // Really Nice Perspective Calculations
        gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST);
    }

}
  • 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-30T10:44:10+00:00Added an answer on May 30, 2026 at 10:44 am
    gl.glPointSize(150);
    

    I suspect that 150 is far greater than the upper ends of GL_ALIASED_POINT_SIZE_RANGE and GL_SMOOTH_POINT_SIZE_RANGE. Try something smaller like 1 or 2.

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

Sidebar

Related Questions

Why do I not see the spinner image when I run this code? However
When I run this code url = ('http://maps.google.com/maps/nav?'+ 'q=from%3A'+from_address+ '+to%3A'+to_address+ '&output=json&oe=utf8&key='+api_key) request = urllib2.Request(url)
I am trying to run demo code from Matplotlib: the legend_picking example . This
I can run this command from the command line without any problem (the validation
Why this code don't work,when i want run this code vwd 2008 express show
When I run this code the selected item is not visible. I've already tried
when i run this code : CONADefinitions.CONAPI_FOLDER_INFO2 FolderInfo; int iResult = 0; IntPtr Buffer
When I run this code, About half-way through the concatenation loop, $xml becomes null
I'm trying to run this code: let coins = [50, 25, 10, 5, 2,1]
If I run this code, will each AppDomain execute in a different thread? ThreadPool.QueueUserWorkItem(delegate

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.