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 10 of 10

Thread: hardware cursor using OpenGL

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2004
    Posts
    11

    hardware cursor using OpenGL

    Hi, is it possible to enable hardware cursor in opengl like D3D does?

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Mar 2001
    Posts
    3,768

    Re: hardware cursor using OpenGL

    OpenGL has no concept of a "hardware cursor".

    Further, on a more personal note, I would suggest trying to avoid such things. After all, rendering the cursor yourself gives you control over it.

  3. #3
    Junior Member Newbie
    Join Date
    Aug 2004
    Posts
    11

    Re: hardware cursor using OpenGL

    Ok, I'm now using a software cursor in my project when OpenGL renderer has been selected. I found it is useful to have a smoothly mouse cursor movement when the FPS is low. I'll try using a true-color windows cursor instead.

    Thanks~

  4. #4
    Senior Member OpenGL Pro sqrt[-1]'s Avatar
    Join Date
    Jun 2002
    Location
    Australia
    Posts
    1,006

    Re: hardware cursor using OpenGL

    It is possible to have a hardware cursor with OpenGL. Many previous projects of mine used this - however I don't have access to the code that does this (win32 stuff) so I can't help you further.

  5. #5
    Intern Contributor
    Join Date
    Jan 2003
    Posts
    86

    Re: hardware cursor using OpenGL

    sqrt[-1]: You mean some OpenGL hack or just using the standard win32 built-in cursor routines?

  6. #6
    Junior Member Regular Contributor songho's Avatar
    Join Date
    May 2003
    Location
    Canada
    Posts
    247

    Re: hardware cursor using OpenGL

    I am confused.
    Should the cursor be always visible, unless you force to hide it explicitly?

    And, I think that the hardware cursor means flicker-free. (A video card draws the cursor onto the frame right before the frame is rendered.) If we use double buffer and draw own cursor image, then it should not be flickered.

  7. #7
    Senior Member OpenGL Pro sqrt[-1]'s Avatar
    Join Date
    Jun 2002
    Location
    Australia
    Posts
    1,006

    Re: hardware cursor using OpenGL

    I did not do the code myself, so I cannot say for sure. But I am reasonably certain it was just win32 calls. (just showcursor calls? perhaps it was the initial screen creation - perhaps they created a full screen boarderless window?)

  8. #8
    Super Moderator OpenGL Guru dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    4,388

    Re: hardware cursor using OpenGL

    The HW cursor works with OpenGL, and should be flicker free, you have to explicitly disable it to hide it (you can specify this in the window creation structure I think). You can also draw your own cursor of course but you need to make sure you disable the HW cursor if you do that.

    I think you need to post more details.

  9. #9
    Member Regular Contributor
    Join Date
    Mar 2005
    Posts
    302

    Re: hardware cursor using OpenGL

    If we're talking about the mouse cursor, and fullscreen, I just wanted to share a little something I encountered porting a D3D game to OpenGL.

    Profiling the app told me that drawing the cursor was a horrible performance hog. I fixed in just a few lines of code (though the same fix applies to D3D too).

    After the UI (2D, though using 3D primitives) was rendered, the code did a color-key "blit". Imagine the pipeline stalls and (lack of) readback speed on slower busses. I did the only obvious thing; I uploaded the mouse cursor image to a texture and after the rest of the UI was rendered I slapped it onto a quad (in ortho mode). I'm not exaggerating when I say that this single change increased UI performance more than 5 times of the whole UI drawing (it has since improved a little more, from 15-30 fps to >2000 fps before adding sanity-Sleep()'ing).

    I think this displays it can be better to first try to solve the "problem" within the environment (OpenGL) when possible, not to mention the performance benefits can be... large.

  10. #10
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,421

    Re: hardware cursor using OpenGL

    Originally posted by tamlin:
    I'm not exaggerating when I say that this single change increased UI performance more than 5 times of the whole UI drawing (it has since improved a little more, from 15-30 fps to >2000 fps before adding sanity-Sleep()'ing).
    5 times the speed sounds ridiculous to me. You mean you hid the standard mouse with ShowCursor?
    So 30 * 5 = 150 FPS

    You added Sleep sometime afterwards and your FPS went to 2000? Again, sounds weird.

    What graphics card is this and what driver, what OS?
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

Posting Permissions

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