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

  • SEARCH
  • Home
  • 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 895579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:34:51+00:00 2026-05-15T14:34:51+00:00

In my next project, I’m trying to learn JOGL. The result should be a

  • 0

In my next project, I’m trying to learn JOGL. The result should be a simple 2d animation.

I’ve heard, that a texture must be 2^n*2^n in size. Can I still use images which don’t have this size, or do I have to edit all images in advance? What do I have to take care of, when using such textures?

As an example, I want to show a kind of progress bar, whose image is at the size of 1024*96px. Do I have to define a quad (eg.1024*1024 in size if you calculate the pixels) and use alpha blending to show only the “filled” part? Or are texture coordinates the way to go?

[Edit]
Works, solution looks like this (using orthogonal projection):

@Override
public void init(GLAutoDrawable drawable) {
    GL gl = drawable.getGL(); // get GL
    glu = new GLU();
    //...
    t  = load(".\\TEXTURES\\ProgressBarBG.png");
            //...
}

   public Texture load(String fileName){
    Texture text = null;
    try{
        text = TextureIO.newTexture(new File(fileName), false);
        text.setTexParameteri(GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST);
        text.setTexParameteri(GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST);
    }catch(Exception e){
        System.out.println(e.getMessage());
        System.out.println("Error loading texture " + fileName);
    }
    return text;
}

    private void drawProgressBG(GL gl, int z) {

    gl.glPushMatrix();
    gl.glLoadIdentity();

    gl.glEnable(GL.GL_BLEND);
    gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);

    gl.glEnable(GL.GL_ALPHA_TEST);
    gl.glAlphaFunc(GL.GL_GREATER, 0); // only render if alpha > 0

    // don't show source alpha parts in the destination
    gl.glEnable(GL.GL_TEXTURE_2D);

    TextureCoords tc = t.getImageTexCoords();

    t.enable();
    t.bind();


    gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE,
            GL.GL_REPLACE);

    gl.glBegin(GL.GL_QUADS);

    gl.glTexCoord2f(tc.left(), tc.bottom()); gl.glVertex3f( 0f, 0f, z);
    gl.glTexCoord2f(tc.right(), tc.bottom()); gl.glVertex3f( 1024f, 0f, z);
    gl.glTexCoord2f(tc.right(), tc.top()); gl.glVertex3f( 1024f, 96f, z);
    gl.glTexCoord2f(tc.left(), tc.top()); gl.glVertex3f( 0f, 96f, z);

    gl.glEnd();

    gl.glDisable(GL.GL_TEXTURE_2D);
    // switch back to modulation of quad colours and texture
    gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE,
    GL.GL_MODULATE);
    gl.glDisable(GL.GL_ALPHA); // switch off transparency
    gl.glDisable(GL.GL_BLEND);


    gl.glPopMatrix();

}

[/EDIT]

  • 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-15T14:34:52+00:00Added an answer on May 15, 2026 at 2:34 pm

    I don’t think it has to be 2^n anymore. You could test it easily
    nehe.gamedev.net has great opengl tutorials and some also in JOGL. Using only 9% of your 1024*1024 texture is a big waste of video ram. You’d better edit it. Use texture coordinates if you only need a portion of your texture, that’s why we have them.

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

Sidebar

Related Questions

Trying to create a simple noddy example so that I can build my next
I am beginning to think that my next project I am wanting to do
I've been thinking about using SQLite for my next project, but I'm concerned that
For my next project I started analyzing apps that measure pulse via camera (you
I'm trying to see if HashSet would be the solution for my next project
I'm playing around with using Simple.Data for my next project, and ran across something
I'm thinking about throwing away my DB in my next project to simplify development/evolution.
Our client wants to support both SQL Server and Oracle in the next project.
I'm currently learning C for my next emulation project, a cycle accurate 68000 core
I'm interested in using a code coverage tool for my next .NET project but

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.