Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: How to delete a texture which is on a quad?

  1. #1
    Intern Contributor
    Join Date
    Oct 2011
    Posts
    67

    How to delete a texture which is on a quad?

    Hello trying to delete a texture off a quad and I can't seem to figure out how to do it I tried

    glDeleteTexture();
    glCullFace();

    I even tried putting alpha information after every frame hoping that it would create a overlap but no luck

    heres my code for the texture loading


    Code :
    void MarioRunAnimation(void)
    {
          glViewport(0,-280,640,480);
                  ///////////////
                  //First Frame
                  //////////////
     
                 //Mario Left Texture Enable
                glEnable(GL_TEXTURE_2D);
     
                glEnable(GL_BLEND);
                glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     
                //Shading
     
                //Storage for Texture for OpenGL
                GLuint MarioLeftTexture;
                glPixelStorei(GL_PACK_ALIGNMENT,2);
     
                //OpenGL Generate Texture
                glGenTextures(1,&  MarioLeftTexture);
                glBindTexture(GL_TEXTURE_2D,  MarioLeftTexture);
     
                //Setting Up Texture
     
                glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, MarioRun1->w,MarioRun1->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, MarioRun1->pixels);
                //Enviroment Variable for OpenGL
                glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
     
                //Texture Parameter information
                glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
                glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
     
     
                    //////////////////
            //Background
            /////////////////
             glBegin(GL_QUADS);
             //X is left and right// Y is Up and Down // and Z is how far it is to the camera or not
                               //x       y        z
            //Bottom Left
             glTexCoord2f(1,1);
            glVertex2f(0, 1);
     
            //bottom right
            glTexCoord2f(0,1);
            glVertex2f(60,1);
     
            //top right
            glTexCoord2f(0,0);
            glVertex2f(60, 80);
     
            //top left
             glTexCoord2f(1,0);
            glVertex2f(0,80);
            glEnd();
     
     
          SDL_GL_SwapBuffers();
          SDL_Delay(100);
    }

    but the question is does anyone know how to delete a texture off a quad :>?

  2. #2
    Member Regular Contributor
    Join Date
    Apr 2010
    Posts
    495

    Re: How to delete a texture which is on a quad?

    In general you can not "undo" any drawing done in OpenGL, all you can do is not draw the object in the next frame.
    There is also no association between the texture and the quad, so it is not necessary to "delete the texture off the quad" (I'm just pointing this out cause that is not how OpenGL works and it's probably not helpful to think about it that way). To have the quad drawn without the texture, you need to disable texturing:

    Code :
    glDisable(GL_TEXTURE_2D);

  3. #3
    Intern Contributor
    Join Date
    Oct 2011
    Posts
    67

    Re: How to delete a texture which is on a quad?

    so how would I Remove the remains off the framebuffer without deleting everything else on the framebuffer which are just textured mapped vertexes?

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    Mar 2009
    Location
    Singapore
    Posts
    802

    Re: How to delete a texture which is on a quad?

    Usually at the start of each frame you clear the framebuffer like this,
    Code :
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    Regards,
    Mobeen

  5. #5
    Intern Contributor
    Join Date
    Oct 2011
    Posts
    67

    Re: How to delete a texture which is on a quad?

    When I do that my other vertexes on the first viewport get cleared I only want my Animated textured vertex on the second viewport to be cleared every frame how would I do that?

  6. #6
    Intern Contributor
    Join Date
    Oct 2011
    Posts
    67

    Re: How to delete a texture which is on a quad?

    could someone help me?

  7. #7
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,732

    Re: How to delete a texture which is on a quad?

    You didn't even wait two hours to bump this.

    The correct answer is redraw everything on every frame. That's how just about every game you've ever seen does it. That's how it is intended to work.

    You don't "remove" things. You simply don't draw them the next frame. You don't take a texture away from a quad; you draw the quad without a texture the next frame. You don't keep pixels around from frame to frame. If you want something to appear at a location, you must draw it again and again, every frame.

    That is the way of things. Restructure your code to be able to do this.

  8. #8
    Intern Contributor
    Join Date
    Oct 2011
    Posts
    67

    Re: How to delete a texture which is on a quad?

    thanks alfonse you saved me alot of hassle wait no you didn't I want to create an animation with textures on a quad and every frame of the texture stays on the screen and the problem is I want it too not do that

    this is what it looks like

    image of the animation


    now do you Understand what I'm asking :>
    If I redraw everything which Is what I'm doing then thats fine but with the animation it is not because it stays

    the last frame that was before the current frame stays on screen and this animation on this vertex is on another viewport

  9. #9
    Advanced Member Frequent Contributor
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    906

    Re: How to delete a texture which is on a quad?

    Texture animation doesn't involve removing something from the framebuffer. Depending on the situation, and I assume you're talking about moving a texture, it merely involves shifting the texture coordinates of the vertices of the quad in the desired direction to produce the illusion of movement. Draw your frame, then shift the tex coords, then draw the next frame and so on.

    thanks alfonse you saved me alot of hassle. wait no you didn't.
    Sarcasm isn't going to get you anywhere. Do you think anyone here wants to spend their time to decode your posts just to have sarcasm thrown their way?

    The first few lines of your initial post reveal once more the tremendous lack of knowledge about even the most basic practices in computer graphics. I said it in another thread you started, I'll say it again now: pick up a book and read!

  10. #10
    Intern Contributor
    Join Date
    Oct 2011
    Posts
    67

    Re: How to delete a texture which is on a quad?

    it wasn't sarcasm and that's not what my question was I think you are getting the wrong idea I just want to know how to get rid of the remains of the animation frames on a texture on a quad.

    Reading a book dude Iv created my own graphical user interface using opengl and SDL don't tell me I have no understanding of basic concepts I just don't know what functions are needed to do what I ask so I come too you in hopes for help and you keep slagging me off like some noob or idiot who doesn't understand without understanding the question first.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •