Results 1 to 8 of 8

Thread: Background Changing Colour and Images Messed Up

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2009
    Posts
    14

    Background Changing Colour and Images Messed Up

    I've got two problems with OpenGL right now.

    1. A background colour I setup changes colour when nearly everytime the window is redraw.

    http://s377.photobucket.com/albums/o...ismind/OpenGL/

    I set the colour as beige but it doesn't stay for long and gets replaced by darker colours. I have no code setup to setup these colours, so my guess is OpenGL is darkening it, I'm not sure why though.


    2. If you look in the same images: http://s377.photobucket.com/albums/o...ismind/OpenGL/

    You'll notice a button I made at the top with the word "Wall" on it. The image doesn't load properly it has some weird colouration problems on it. If you look closely parts of the top, side, and of the letters has a rainbow covering it. The other image below were loaded with the same functions and had no problem. Does anyone know why this is happening?


    Thanks in Advance.

  2. #2
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: Background Changing Colour and Images Messed Up

    1. no idea. do you play with blending ? what is your clearcolor ?
    2. depends on the image format, color depth, etc. Probably more to do with you loading routine than opengl code.

  3. #3
    Junior Member Newbie
    Join Date
    Jul 2009
    Posts
    14

    Re: Background Changing Colour and Images Messed

    Quote Originally Posted by ZbuffeR
    1. no idea. do you play with blending ? what is your clearcolor ?
    2. depends on the image format, color depth, etc. Probably more to do with you loading routine than opengl code.
    1. I haven't played with blending, no. My clearColour?

    2. I've been using some code from a tutorial I've been following, it loads a bmp image with a 24bit colour depth. But it has worked flawlessly until now.

  4. #4
    Junior Member Newbie
    Join Date
    Jul 2009
    Posts
    14

    Re: Background Changing Colour and Images Messed

    Okay I started using the glClearColor function, but it still does not fix my problem.

  5. #5
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: Background Changing Colour and Images Messed

    Hard to help without more info.

    Backup your current code, then remove things little by little until the problem disappear. You will probably understand yourself how to fix it then. If it still puzzles you, post the simplest compilable code that still has the bug.

    Start to chase the background problem first.

  6. #6
    Junior Member Newbie
    Join Date
    Jul 2009
    Posts
    14

    Re: Background Changing Colour and Images Messed

    Quote Originally Posted by ZbuffeR
    Hard to help without more info.

    Backup your current code, then remove things little by little until the problem disappear. You will probably understand yourself how to fix it then. If it still puzzles you, post the simplest compilable code that still has the bug.

    Start to chase the background problem first.
    Well I narrowed my code to here:

    Code :
    if (!buttonList.isEmpty())
    {
    	ButtonNode *seek = buttonList.first;
     
    	while (seek != 0)
    	{
    		seek->button->draw();
    		seek = seek->next;
    	}
    }

    button->draw(); is this:
    Code :
    void Button::draw() const
    {
    	int textureId;
    	switch (state)
    	{
    	case NORMAL:
    		textureId = normalTexture;
    		break;
     
    	case MOUSE_OVER:
    		textureId = mouseOverTexture;
    		break;
     
    	case ACTIVE:
    		textureId = activeTexture;
    		break;
     
    	default:
    		textureId = normalTexture;
    	}
     
     
    	glPushMatrix();
    	GLAddons::glTranslateVector(Vectorf(positionX, positionY, 0));
     
    	glEnable(GL_TEXTURE_2D);
    	glBindTexture(GL_TEXTURE_2D, textureId);	
    	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    	Colours::White.setAsCurrent();
    	glBegin(GL_QUADS);
     
    	glTexCoord2f(0.0f, 0.0f);
    	glVertex2f(0.0f, 0.0f);
    	glTexCoord2f(1.0f, 0.0f);
    	glVertex2f(width, 0.0f);
    	glTexCoord2f(1.0f, 1.0f);
    	glVertex2f(width, height);
    	glTexCoord2f(0.0f, 1.0f);
    	glVertex2f(0.0f, height);
     
    	glDisable(GL_TEXTURE_2D);
    	glEnd();
     
    	glPopMatrix();
    }

    Any idea what's causing it?


    The same thing occurs in another function where I draw a texture:
    Code :
    void Environment::drawTile(char tile, unsigned int x, unsigned int y) const
    {
    	unsigned int textureId = tileToTexture(tile);
     
    	glPushMatrix();
     
    	//Set the position
    	GLAddons::glTranslateVector(grid.getPosition(x, y));
     
    	glEnable(GL_TEXTURE_2D);
    	glBindTexture(GL_TEXTURE_2D, textureId);	
    	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    	Colours::White.setAsCurrent();
    	glBegin(GL_QUADS);
     
    	glNormal3f(0.0f, 1.0f, 0.0f);
    	glTexCoord2f(0.0f, 0.0f);
    	glVertex2f(0.0f, 0.0f);
    	glTexCoord2f(1.0f, 0.0f);
    	glVertex2f(Avatar::AvatarSize, 0.0f);
    	glTexCoord2f(1.0f, 1.0f);
    	glVertex2f(Avatar::AvatarSize,Avatar::AvatarSize);
    	glTexCoord2f(0.0f, 1.0f);
    	glVertex2f(0.0f, Avatar::AvatarSize);
     
    	glDisable(GL_TEXTURE_2D);
    	glEnd();
     
    	glPopMatrix();
    }

  7. #7
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: Background Changing Colour and Images Messed

    You are on the background color problem, right ?
    How do you draw it ?

  8. #8
    Junior Member Newbie
    Join Date
    Jul 2009
    Posts
    14

    Re: Background Changing Colour and Images Messed

    Quote Originally Posted by ZbuffeR
    You are on the background color problem, right ?
    How do you draw it ?
    Code :
    glPushMatrix();
    GLAddons::glTranslateVector(BACKGROUND_POSITION);
     
    glBegin(GL_QUADS);
    Colours::Beige.setAsCurrent();
     
    glVertex3f(-800, -800, 0);
    glVertex3f(-800, mScreenHeight + 800, 0);
    glVertex3f(mScreenWidth + 800, mScreenHeight + 800, 0);
    glVertex3f(mScreenWidth + 800, -800, 0);
     
    glEnd();
     
    glPopMatrix();

    setAsCurrent(); calls glColor3f

Similar Threads

  1. Background colour does not change on mac OS
    By batman999 in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 11-02-2018, 11:02 AM
  2. FBO and changing the colour attachment
    By IneQuation.pl in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 05-15-2010, 05:38 PM
  3. Writing to target alpha without changing colour
    By James Lohr in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 09-14-2009, 02:47 PM
  4. Changing text colour half-way through?
    By RobertWebb in forum OpenGL: Advanced Coding
    Replies: 11
    Last Post: 02-22-2005, 08:30 AM
  5. Problem changing pixmap font colour
    By Adrian67 in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 05-02-2003, 06:45 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