Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: How can i highlight a single Texture?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member Newbie
    Join Date
    Jan 2017
    Posts
    4

    How can i highlight a single Texture?

    Hey

    Im currently coding my own GUI for my game and i want to highlight a texture (single texture, it could be, that one texture is transposed multiple times) if the mouse hovers the texture.

    Does anyone has ideas of how to highlight a 2d element?

    My idea was to add a bit of white (vec4(0.3, 0.3, 0.3, 1.0)) to the texture-Color when hovering the texture.
    But this is not good, because all elements gets a bit more white

    Thanks for any ideas

    Greetings

    Fabi

  2. #2
    Junior Member Newbie
    Join Date
    Jan 2018
    Posts
    3
    Don't know how about mouse and open gl, but when I did GUI with the keyboard I did something like this

    Code cpp:
    for(int i = 0; i < menuOptions.size(); ++i)
    {
            if(activeOption == i) {
                option.setColor(r, g, b, a); // r g b a - colors when option is active, if going mouse if cursor is on the option
            } else {
                option.setColor(rgba); // rgba - when cursor is not on the option
            }
     
             //or you can use 
             //activeOption == i ? option.setColor(rgba) : option.setColor(rgba) 
             //it means exactly the same
    }

    also you can leave colors and just mix alpha value, for example if option is selected alpha = 255 else alpha = 100, or the dimension, if option is selected w = 100 and h = 50 else w = 50 and h = 25

    also there is https://www.youtube.com/watch?v=L7L9ZUWisfM&t=2s engine which is not so good, because he uses glBegin for drawing but you could get some GUI stuff
    Last edited by Dark Photon; 01-11-2018 at 02:56 PM.

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    2,926
    Quote Originally Posted by Fabiii View Post
    Does anyone has ideas of how to highlight a 2d element?
    However you want. Realistically, you need something which fits the colour scheme in use (e.g. if everything is fairly bright, lightening the colours will often make something stand out less rather than more).

    Quote Originally Posted by Fabiii View Post
    My idea was to add a bit of white (vec4(0.3, 0.3, 0.3, 1.0)) to the texture-Color when hovering the texture.
    But this is not good, because all elements gets a bit more white
    Well, you need to either draw the highlighted portion separately or have some other way to allow different primitives to be styled differently (e.g. vertex attributes).

Tags for this Thread

Posting Permissions

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