mouse picking in opengl - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

mouse picking in opengl

dev48dev48 Posts: 7Member
Hello!

I want to know if someone knows how to make real time picking in OpenGL!
Indeed i want to make a program where when my mouse move through an objeect this object would be highlighted..
Can someone explain me how to do this?

thanks

Comments

  • gautamgautam Posts: 642Member
    : Hello!
    :
    : I want to know if someone knows how to make real time picking in OpenGL!
    : Indeed i want to make a program where when my mouse move through an objeect this object would be highlighted..
    : Can someone explain me how to do this?
    :
    : thanks
    :

    You can use the picking of opengl, or you can use custom routines to do that or you can push the matrix, draw in orthographic mode and pop the matrix and then use regular WM_MOUSE to do what you want or use direct input to do what you want with the mouse


  • SephirothSephiroth Fayetteville, NC, USAPosts: 1,035Member
    : You can use the picking of opengl, or you can use custom routines to do that or you can push the matrix, draw in orthographic mode and pop the matrix and then use regular WM_MOUSE to do what you want or use direct input to do what you want with the mouse
    :
    :
    :
    I use regular WM_MOUSE and other windows messages to control mouselook in my 3D world, and it works fine. However, I may go to DirectInput later.

    -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]

  • dev48dev48 Posts: 7Member
    Hello!

    My problem is that i work with qt + opengl!
    Of course I can use the equivalent of WM_MOUSE in qt but I think it's going to be hard...
    Can you show me an example of your code?
  • SephirothSephiroth Fayetteville, NC, USAPosts: 1,035Member
    : Hello!
    :
    : My problem is that i work with qt + opengl!
    : Of course I can use the equivalent of WM_MOUSE in qt but I think it's going to be hard...
    : Can you show me an example of your code?
    :
    I don't know how QuickTime deals with GL. I hate Apple and don't deal with any of their products. However, the simlpe way to get mouse stuff working can be done without WM_MOUSE stuff (I upgraded). Here's a basic run-down:

    1) Get the mouse coordinates and store them in a POINT variable
    2) Get the window width and height
    3) Set the mouse coordinates to width divided by two, and height divided by 2
    4) Now you've got what you need! Calculate the distance the mouse had moved from the center of the screen, multiply that by sensitivity, and deal with the results

    This method is used inside my 3D engine and is checked every frame. Very accurate and it doesn'tsuck my CPU dry either. I'll look for the sources of this being implemented on my old project and paste later.

    -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]

  • gautamgautam Posts: 642Member
    Hi,
    err I don;t think qt is quicktime. QT is an API normally used in KDE.

    QT + OpenGL, thats only in the enterprise edition if its QT the API!! You bought the enterprise edition ?? Even in Linux its not free.

    : : Hello!
    : :
    : : My problem is that i work with qt + opengl!
    : : Of course I can use the equivalent of WM_MOUSE in qt but I think it's going to be hard...
    : : Can you show me an example of your code?
    : :
    : I don't know how QuickTime deals with GL. I hate Apple and don't deal with any of their products. However, the simlpe way to get mouse stuff working can be done without WM_MOUSE stuff (I upgraded). Here's a basic run-down:
    :
    : 1) Get the mouse coordinates and store them in a POINT variable
    : 2) Get the window width and height
    : 3) Set the mouse coordinates to width divided by two, and height divided by 2
    : 4) Now you've got what you need! Calculate the distance the mouse had moved from the center of the screen, multiply that by sensitivity, and deal with the results
    :
    : This method is used inside my 3D engine and is checked every frame. Very accurate and it doesn'tsuck my CPU dry either. I'll look for the sources of this being implemented on my old project and paste later.
    :
    : -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]
    :
    :

  • SephirothSephiroth Fayetteville, NC, USAPosts: 1,035Member
    Ah, I don't do the X-Win thing (WHICH IS NOT LINUX!@#). Linux is an OS thatis shell-based like DOS was. X-Win is a pretty GUI put over Linux that issues commands for a user based on pointing and clicking on stuff so that even people who have trouble finding the power switch can say they use Linux, when in reality they're just pointing and clicking with no clue what's really going on. Yeah I go overboard when it comes to X-Win kiddies because I used to code on the Linux kernel, and have been doing Linux forever, and it ticks me off that some people have the audacity to say they can use Linux when, if they were ata shell-prompt, would be crying for their mothers.

    Anyways, were you referring to the KDE thing, or QuickTime. If it's the KDE thing, I can't really offer much help there. If it's QuickTime I can offer advice.

    -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]

Sign In or Register to comment.