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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T13:24:47+00:00 2026-05-29T13:24:47+00:00

I am rendering a cylinder and mapping two different textures to the top and

  • 0

I am rendering a cylinder and mapping two different textures to the top and to the bottom face.

Both the textures are loaded in the following way:

    check3dFloorFile = new File(check3dFloorPath);
    try {
        check3dFloorTexture = TextureIO.newTexture(check3dFloorFile, true);
    } catch (IOException | GLException ex) {
        Logger.getLogger(Viewer.class.getName()).log(Level.SEVERE, null, ex);
    }
       
    check3dFloorTexture.setTexParameteri(gl, GL2.GL_TEXTURE_MIN_FILTER, 
                                                   GL2.GL_LINEAR_MIPMAP_LINEAR);
    check3dFloorTexture.setTexParameteri(gl, GL2.GL_TEXTURE_MAG_FILTER, 
                                                                 GL2.GL_LINEAR);
               
    check3dFloorBackFile = new File(check3dFloorBackPath);
           
    try {
        check3dFloorBackTexture = TextureIO.newTexture(check3dFloorBackFile, true);
    } catch (IOException | GLException ex) {
        Logger.getLogger(Viewer.class.getName()).log(Level.SEVERE, null, ex);
    }
     
    check3dFloorBackTexture.setTexParameteri(gl, GL2.GL_TEXTURE_MIN_FILTER, 
                                                 GL2.GL_LINEAR_MIPMAP_LINEAR);
    check3dFloorBackTexture.setTexParameteri(gl, GL2.GL_TEXTURE_MAG_FILTER, 
                                                               GL2.GL_LINEAR);

The problem arises when I try to render to a texture (a blank one, that has nothing to do with this first two ones):

gl.glGenTextures(1, textureID, 0);
gl.glBindTexture(GL2.GL_TEXTURE_2D, textureID[0]);
    
    gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_S, GL2.GL_REPEAT);
    gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_T, GL2.GL_REPEAT);
    gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_NEAREST);
    gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_NEAREST);
    
    // null means reserve texture memory, but texels are undefined
    gl.glTexImage2D(GL2.GL_TEXTURE_2D, 0, GL2.GL_RGB, floorWidth, floorHeight,
                                                0, GL2.GL_RGB, GL2.GL_FLOAT, null);
    
    gl.glGenFramebuffers(1, frameBufferID, 0);
    gl.glBindFramebuffer(GL2.GL_FRAMEBUFFER, frameBufferID[0]);
    
    //Attach 2D texture to this FBO
    gl.glFramebufferTexture2D(GL2.GL_FRAMEBUFFER, GL2.GL_COLOR_ATTACHMENT0, 
                                    GL2.GL_TEXTURE_2D, textureID[0], 0);
    
    // depth buffer
    //int[] depthRenderBufferID = new int[1];
    gl.glGenRenderbuffers(1, depthRenderBufferID, 0);
    gl.glBindRenderbuffer(GL2.GL_RENDERBUFFER, depthRenderBufferID[0]);
    gl.glRenderbufferStorage(GL2.GL_RENDERBUFFER, GL2.GL_DEPTH_COMPONENT, 
                                            floorWidth, floorHeight);
    gl.glFramebufferRenderbuffer(GL2.GL_FRAMEBUFFER, GL2.GL_DEPTH_ATTACHMENT,
                                        GL2.GL_RENDERBUFFER, depthRenderBufferID[0]);
     
   if(gl.glCheckFramebufferStatus(GL2.GL_FRAMEBUFFER) == GL2.GL_FRAMEBUFFER_COMPLETE)
        System.out.println("[Viewer] GL_FRAMEBUFFER_COMPLETE!!");
    else
        System.out.println("..cazzo ^^");

As soon as this code is executed, the texture mapped on the top of the cylinder disappears and all the top turns to black…

Why?

Ps: my task is to map this third rendered texture on the top of the cylinder, over the already existing one..

  • 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-29T13:24:47+00:00Added an answer on May 29, 2026 at 1:24 pm
    gl.glBindTexture(GL2.GL_TEXTURE_2D, textureID[0]);
    /*... */
    gl.glGenFramebuffers(1, frameBufferID, 0);
    gl.glBindFramebuffer(GL2.GL_FRAMEBUFFER, frameBufferID[0]);
    
    //Attach 2D texture to this FBO
    gl.glFramebufferTexture2D(GL2.GL_FRAMEBUFFER, GL2.GL_COLOR_ATTACHMENT0, 
                                    GL2.GL_TEXTURE_2D, textureID[0], 0);
    

    You need to unbind the texture first from the texture target, before a framebuffer it has been attached to can be selected as render target. Since you don’t do this, you’ll render nothing to that texture thus it will come out blank.

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

Sidebar

Related Questions

since they have same rendering engine, this problem shows in both. it works great
I have rendering a section in the bottom master layout. This is typically section
I am having difficulties rendering several patterns (each with different texture) in the 2d
When rendering a view in an ASP.NET MVC application, I am getting the following
For rendering purposes I need a vtkImageData object with two components where each component
Currently I am rendering HTML views with the following syntax: t = loader.get_template('sometemplate.html') c
I have developed chart rendering functionality in my web application and set following setting
I'm rendering OpenGL Context on a background thread with a different EAGLContext than the
While rendering the view page, based on some condition in the controller action I
I am rendering a rails partial and I want to alternate the background color

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.