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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:19:04+00:00 2026-06-01T18:19:04+00:00

I have a test program that programmatically renders a texture and then renders a

  • 0

I have a test program that programmatically renders a texture and then renders a simple quad that is skinned with the previously drawn texture. The program is extremely simple and everything is done in 2D. This program works great under linux and everything looks like it should: Running on Linux

However when I run the program on my mac running 10.7 nothing shows up:
Running on Mac

I’m at a complete loss as to why this program isn’t working on my mac.

Here are the relevant bits of the program.

Creating the texture:

void createTextureObject(){
    cout<<"Creating a new texture of size:"<<textureSize<<endl;
    //glDeleteTextures(1, &textureId);
    glGenTextures(1, &textureId);
    glBindTexture(GL_TEXTURE_2D, textureId);
    glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); // automatic mipmap generation included in OpenGL v1.4
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, textureSize, textureSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);

    isTextureValid = true;
    createFBObject();
}

Creating the Frame Buffer Object:

void createFBObject(){
    cout<<"Creating a new frame buffer object"<<endl;

    glDeleteFramebuffers(1, &fboId);
    glGenFramebuffersEXT(1, &fboId);

    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboId);

    glGenRenderbuffersEXT(1, &rboId);
    glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, rboId);
    glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, textureSize, textureSize);
    glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);

    glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, textureId, 0);

    glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, rboId);

    bool status = checkFramebufferStatus();
    if(!status){
        cout<<"FrameBufferObject not created! Quitting!"<<endl;
        exit(1);
        fboUsed = false;
    }

    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
}

Rendering to the texture:

void drawToTexture(){

    if (!isTextureValid)
        createTextureObject();

    glViewport(0, 0, textureSize, textureSize);
    glLoadIdentity();
    // set the rendering destination to FBO
    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboId);
    // clear buffer
    glClearColor(0, 0, 0, 1.0);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   // draw to the texture
    glColor3f(0.0, 1.0, 0.0);

    for (int i=1; i<=5; i++){
        glBegin(GL_LINE_LOOP);
            glVertex2f(-1 * i/5.0f, -1 * i/5.0f);
            glVertex2f( 1 * i/5.0f, -1 * i/5.0f);
            glVertex2f( 1 * i/5.0f,  1 * i/5.0f);
            glVertex2f(-1 * i/5.0f,  1 * i/5.0f);
        glEnd();
    }
    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 
}

Rendering the textured quad:

void drawTexturedQuad(){
    glViewport(50, 50, textureSize, textureSize);
    glLoadIdentity();
    glClearColor(0.2, 0.2, 0.2, 0.2);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glBindTexture(GL_TEXTURE_2D, textureId);

    int size = 1;
    int texS = 1;

    glBegin(GL_QUADS);
        glColor4f(1, 1, 1, 1);
        glTexCoord2f(texS,  texS);  glVertex3f(size,        size,0);
        glTexCoord2f(0,     texS);  glVertex3f(-1 * size ,  size,0);
        glTexCoord2f(0,     0);     glVertex3f(-1 * size,   -1 * size,0);
        glTexCoord2f(texS,  0);     glVertex3f(size,        -1 * size,0);
    glEnd();

    glBindTexture(GL_TEXTURE_2D, 0);
}

I’m using GLUT and my display call back is simply:

void displayCB(){
    drawToTexture();
    drawTexturedQuad();
    glutSwapBuffers();
}

Additionally I have other methods check to see if FrameBufferObjects are supported by OpenGL and if they are not the program quits. Additionally I have other logic that sets textureSize whenever the window is resized.

  • 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-01T18:19:05+00:00Added an answer on June 1, 2026 at 6:19 pm
    glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); // automatic mipmap generation included in OpenGL v1.4
    

    This might be a problem. The GL specification doesn’t say exactly at what point mipmaps should be generated, and of course, this generates problems with render to texture. So the GL_EXT_framebuffer_object (and core versions too) introduced glGenerateMipmapEXT, which you call exactly in the point where you want mipmaps generated (usually after rendering to the texture).

    So, remove the GL_GENERATE_MIPMAP stuff and use glGenerateMipmap manually when needed. You can read more about this problem in the GL_EXT_framebuffer_object specification.

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

Sidebar

Related Questions

I have a strange build problem. I have a simple test program that sends
I wanted to write a program that test if two files are duplicates (have
I have one application that prints messages from Test.exe in console .My java program
I have a very simple test program, running on Solaris 5.8: #include <stdio.h> #include
I have a simple RabbitMQ test program randomly enqueuing messages, and another reading them,
I have a test driver program that launches a separate test server process. The
I have a small test program that creates millions of files (for testing purposes)
I have a test program that demonstrates the end result that I am hoping
I have made a simple, test program to experiment using classes. It creates a
I have a terribly uncomplicated test program that prints out the following numbers. i.e.

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.