Results 1 to 4 of 4

Thread: Boolean Help

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2009
    Posts
    13

    Boolean Help

    Another Day, Another Problem! Heh, but this one is truely confusing me, due to the fact i think it should be working. Basically I am trying to create textures based on the position of an object, so i have created a function seen below:

    void DropFunc(void){
    if (Drop == true)
    {
    glPushMatrix();
    glBindTexture(GL_TEXTURE_2D, texture[2]);
    glBegin(GL_QUADS);
    glTexCoord2f(0.0f, 0.0f); glVertex3f(DropTileX + 0.0,0.1,DropTileZ + 5.0);
    glTexCoord2f(1.0f, 0.0f); glVertex3f(DropTileX + 5.0,0.1,DropTileZ + 5.0);
    glTexCoord2f(1.0f, 1.0f); glVertex3f(DropTileX + 5.0,0.1,DropTileZ + 0.0);
    glTexCoord2f(0.0f, 1.0f); glVertex3f(DropTileX + 0.0,0.1,DropTileZ + 0.0);
    glEnd();
    glPopMatrix();
    glutPostRedisplay();
    Drop = false;
    }
    }

    This is the formula for the x and z values:

    int DropTileX = (Dropi * 5) - 5;
    int DropTileZ = (Dropj * 5) - 5;

    where Dropi and Dropj are constantly being updates by the moving object, so you press the right key and j increases by 1 etc. This function should basically (as far as i know) create a square with the desired vertex, and apply texture[2] to that object. I know this as it works elsewhere in my code (and basically forms the grid my objects move about). Except for this placement, I have increased the y co-ord by 0.1 so it sits above the main floor.

    In my drop key i have:

    case 'X': //drops bottom texture
    case 'x': Drop = true;
    glutIdleFunc(DropFunc);
    glutPostRedisplay(); // Redisplay with dropped textures
    break;

    which as far as I know sets Drop to true, which should activate the function, then it should create the tile as described, then set drop to false so it doesnt loop.

    If anyone can understand what i'm trying to do, can you help me?

    Thanks,

    EJD

  2. #2
    Member Contributor
    Join Date
    Feb 2005
    Posts
    90

    Re: Boolean Help

    Hi,

    What exactly is the problem?
    No texture?, no quad? empty display?

    Ido

  3. #3
    Senior Member OpenGL Pro dletozeun's Avatar
    Join Date
    Jan 2006
    Location
    FRANCE
    Posts
    1,367

    Re: Boolean Help

    Am I blind, I just can't find what is your problem in your post, you only talk about what you should obtain. You see nothing?

    Does it work putting simple values in the glVertex3d calls?
    How do you set your projection matrix?
    Are you sure the geometry is in the view volume? Especially z coordinate that should be in the [znear zfar] range.

    By the way, the glPush/glPop calls are useless in your case.

  4. #4
    Junior Member Newbie
    Join Date
    Apr 2009
    Posts
    13

    Re: Boolean Help

    Hey sorry i'm not very good at explaining. The basic issue was that it wasnt displaying, but that is because I forgot to call the function that displays it in main. The issue I have now, yes i gained another one, is that due to the way I have written it. I can now drop the texture, but it follows under the cube, i.e the variables DropTileX and DropTileZ are constantly updating with every move made. Is there anyway to stop this, i'm thinking storing the created textures in an array? but have no idea how to do it.

Similar Threads

  1. Boolean Branches in shader
    By techwinder in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 04-03-2016, 01:54 PM
  2. Boolean operation
    By James.W in forum OpenGL: General
    Replies: 3
    Last Post: 11-14-2013, 07:56 AM
  3. Boolean operation in moding
    By James.W in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 04-21-2013, 08:12 PM
  4. Boolean operations
    By in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 10-04-2001, 04:19 AM
  5. Boolean operations...
    By Fisher in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 11-14-2000, 05:13 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