Results 1 to 7 of 7

Thread: FLICKERING PROBLEM.....Please Help

  1. #1
    Member Contributor
    Join Date
    Mar 2006
    Location
    chicago
    Posts
    72

    FLICKERING PROBLEM.....Please Help

    Can someone please help me find out why the texture is flickering? HERE IS MY CODE:


    #include <OpenGLSB.h>
    #include <GLTools.h>
    #include "glbmp.h"


    GLfloat a = 0.0;
    GLfloat s = 0.0;
    GLfloat x = 0.0;
    GLfloat y = 0.0;
    GLfloat anisosize;


    void init(void)
    {

    glEnable(GL_MULTISAMPLE);
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_TEXTURE_3D);

    }


    void RenderScene(void)
    {


    GLuint texture = 0;

    glbmp_t bitmap;

    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

    glbmp_LoadBitmap("grass.bmp", 1, &bitmap);

    //generate and bind the OpenGL texture
    glGenTextures(1, &texture);
    glBindTexture(GL_TEXTURE_2D, texture);


    //copy data from bitmap into texture
    glTexImage2D(GL_TEXTURE_2D, 0, 3, bitmap.width, bitmap.height,0, GL_RGB, GL_UNSIGNED_BYTE, bitmap.rgb_data);


    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);



    glViewport(0, 0, 1024, 76;
    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);


    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(75.0, 1.0, -2.0, 2.0);


    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    gluLookAt(0.0, 0.0, 0.0, 0.0 ,0.0, 0.0, 0.0, 1.0, 0.0);


    glShadeModel(GL_SMOOTH);



    glFrontFace(GL_CCW);
    glEnable(GL_CULL_FACE);


    glBegin(GL_QUAD_STRIP);

    glTexCoord3f(0.0, 0.0, 0.0);
    glVertex3f(0.0f, 0.0f, 0.0f);

    glTexCoord3f(0.0, 1.0, 0.0);
    glVertex3f(0.0f, 1.0f, 0.0f);

    glTexCoord3f(1.0, 1.0, 0.0);
    glVertex3f(1.0f, 1.0f, 0.0f);

    glTexCoord3f(1.0, 0.0, 0.0);
    glVertex3f(1.0f, 0.0f, 0.0f);

    glEnd();





    glDeleteTextures(1, &texture);
    glbmp_FreeBitmap(&bitmap);


    glutSwapBuffers();


    }


    void TimerFunction(int value)
    {

    glutTimerFunc(1, TimerFunction, 1);

    glutPostRedisplay();
    }


    void SpecialKeys(int key, int x, int y)
    {
    if (key == GLUT_KEY_RIGHT)
    s = s - .015;

    if (key == GLUT_KEY_LEFT)
    s = s + .015;

    if (key == GLUT_KEY_UP)
    a = a + .015;

    if (key == GLUT_KEY_DOWN)
    a = a - .015;


    glutPostRedisplay();
    }


    int main(int argc, char *argv[])
    {
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_MULTISAMPLE);
    glutInitWindowSize(1024, 76;
    glutCreateWindow("STONES OF");
    glutDisplayFunc(RenderScene);
    glutSpecialFunc(SpecialKeys);
    glutTimerFunc(1, TimerFunction, 1);
    init();

    glutMainLoop();

    return 0;
    }
    zadeh

  2. #2
    Senior Member Frequent Contributor
    Join Date
    Aug 2004
    Location
    munich, germany
    Posts
    659

    Re: FLICKERING PROBLEM.....Please Help

    glEnable(GL_TEXTURE_3D); could be the problem.

    ahem... and glTexCoord3f, too. what you need is

    glEnable(GL_TEXTURE_2D);
    glTexImage2D(...);
    glTexCoord2f(...);

  3. #3
    Member Contributor
    Join Date
    Mar 2006
    Location
    chicago
    Posts
    72

    Re: FLICKERING PROBLEM.....Please Help

    I already tried changing that to glEnable(GL_TEXTURE_2d) and it DID NOT STOP FLICKERING.
    zadeh

  4. #4
    Senior Member Frequent Contributor
    Join Date
    Aug 2004
    Location
    munich, germany
    Posts
    659

    Re: FLICKERING PROBLEM.....Please Help

    YOU ARE A BIT FRUSTRATED, AREN'T YOU?????

    maybe you should take into consideration to clear the color and depth buffer.

  5. #5
    Member Contributor
    Join Date
    Mar 2006
    Location
    chicago
    Posts
    72

    Re: FLICKERING PROBLEM.....Please Help

    glEnable(GL_TEXTURE_2D);
    glTexImage2D(...);
    glTexCoord2f(...);

    I tried all of this and for some reason it didn't stop flickering..

    ......... I HAVE A NEWER INtel MOTHERBOARD WITH ONBOARD VIDEO. I'M WONDERiNG IF THAT COULD BE PART OF THE PROBLEM.
    zadeh

  6. #6
    Senior Member Frequent Contributor
    Join Date
    Aug 2004
    Location
    munich, germany
    Posts
    659

    Re: FLICKERING PROBLEM.....Please Help

    does "all of this" include clearing the depth buffer?

    btw: it's not a good idea to load and destroy the bitmap each time the scene is redrawn. a better way is to load the bitmap and use glTexImage2D once, right after you've made the gl context current.

  7. #7
    Member Contributor
    Join Date
    Mar 2006
    Location
    chicago
    Posts
    72

    Re: FLICKERING PROBLEM.....Please Help

    ALL RIGHT, THE FLICKERING WENT AWAY. THNX.
    zadeh

Similar Threads

  1. Flickering Problem with Display Lists
    By jcoplan in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 05-06-2008, 09:51 AM
  2. problem with flickering
    By presoftdev in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 11-28-2005, 09:11 PM
  3. Texture flickering problem.
    By zenon in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 02-24-2003, 12:21 AM
  4. flickering problem
    By prashantgp in forum OpenGL: Basic Coding
    Replies: 17
    Last Post: 12-19-2002, 05:20 AM
  5. flickering problem
    By monka in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 09-17-2002, 06:41 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean