Results 1 to 9 of 9

Thread: glDrawPixels y-flip and speed

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2001
    Location
    Göteborg, Sweden
    Posts
    13

    glDrawPixels y-flip and speed

    I need to do dialog windows in OpenGL.

    I have been experimenting with mapping the dialog surface as a texture to a polygon but it was dead slow. I need some speed here since I have scrollbars and users expect them to be fast.

    Now, I began to use glDrawPixels() instead but I don't know how fast it is yet. Does anyone know it it is slow?

    Another thing is that glDrawPixels() expects the image's pixel data to begin with the lower left corner of the image. I really want this to be the upper left corner instead to avoid rewriting the dialog system. I can't seem to do that. Is it possible?

    Is there any other (faster) way of getting 2d-images to the OpenGL window?

    /Jonas

  2. #2
    Senior Member Frequent Contributor
    Join Date
    Feb 2000
    Location
    San Diego, CA, USA
    Posts
    604

    Re: glDrawPixels y-flip and speed

    If drawing one texturemapped polygon is "dead slow", then either:

    1. You are not doing it right
    2. Your hardware is REALLY old
    3. Rendering is going to software for some reason

    That is the fastest way to draw 2d scenes.

    You would have to post a bit of the important code to tell what was really going on, as well as mention what hardware you're using.

    -- Zeno

  3. #3
    Junior Member Newbie
    Join Date
    Apr 2001
    Location
    Göteborg, Sweden
    Posts
    13

    Re: glDrawPixels y-flip and speed

    It is "dead slow" because I need to update the texture that can be 400x500 pixels for example often. It is not enough fast for a dialog system.

    /Jonas

  4. #4
    Senior Member Frequent Contributor
    Join Date
    Jan 2001
    Location
    NVIDIA, Austin, TX
    Posts
    555

    Re: glDrawPixels y-flip and speed

    Are you using glTexImage2D or gluBuild2DMipmaps to update the new texture?

    A faster way to do it would be to use glTexImage2D the first time you use the texture object and then use glTexSubImage2D to update the texture every frame.

    If you are creating mipmapped textures using gluBuild2DMipmaps then I would suggest looking into the GL_SGIS_generate_mipmap extension (supported by GeForce hardware) to significantly speed up this process.

    Jason A.
    DelphiGL (http://delphigl.cfxweb.net)

    [This message has been edited by jra101 (edited 06-13-2001).]

  5. #5
    Junior Member Newbie
    Join Date
    Apr 2001
    Location
    Göteborg, Sweden
    Posts
    13

    Re: glDrawPixels y-flip and speed

    Originally posted by Zeno:
    If drawing one texturemapped polygon is "dead slow", then either:


    1. You are not doing it right
    2. Your hardware is REALLY old
    3. Rendering is going to software for some reason

    That is the fastest way to draw 2d scenes.
    Is it really faster than glDrawPixels?

    You have a point there (rather three). I have to add that I want a game to run at the same time, which makes the speed more important than if I just have the dialog in itself.

    /Jonte

  6. #6
    Senior Member OpenGL Guru
    Join Date
    Mar 2001
    Posts
    2,411

    Re: glDrawPixels y-flip and speed

    > It is "dead slow" because I need to update
    > the texture that can be 400x500 pixels for
    > example often. It is not enough fast for a
    > dialog system.

    So? Uploading a 400x500 pixel texture shouldn't take a substantial part of your frame render time (though it's slower than not uploading, of course

    If you're drawing the 2D UI in a pixel-for-pixel mapping to the screen, you should NOT spend time building MIP maps. You should also draw in GL_NEAREST interpolation mode, as filtering will make the 2D UI less crisp.
    "If you can't afford to do something right,
    you'd better make sure you can afford to do it wrong!"

  7. #7
    Senior Member OpenGL Pro
    Join Date
    Feb 2001
    Location
    Switzerland
    Posts
    1,594

    Re: glDrawPixels y-flip and speed

    why repainting on texture?

    your button is:
    a quad, with 2 possible stages.. not clicking, clicking => 2 textures ( or one, and changing texcoors

    your scrollbar is:
    three buttons, two with arrows on, one not
    a background quad

    your textbox is:
    a rect where you can print text in

    your text is:
    quads with part of a font-texture ( nehe texture-font tutorial )

    and your window is:
    a quad for title bar, with a textline in, some buttons for closing, minimizeing,maximizeing, and the left menubutton ( suppose you want a windows-windows system.. )
    and a quad with all those objects in..

    => drawing bout 10 - 20 quads for the whole window, text not countet..

    fps: 300/400
    enough?
    http://davepermen.net - if i could stay true to my heart, i would feel totally free

  8. #8
    Junior Member Newbie
    Join Date
    Apr 2001
    Location
    Göteborg, Sweden
    Posts
    13

    Re: glDrawPixels y-flip and speed

    Originally posted by jra101:
    Are you using glTexImage2D or gluBuild2DMipmaps to update the new texture?
    I'm using glTexImage2D.

    A faster way to do it would be to use glTexImage2D the first time you use the texture object and then use glTexSubImage2D to update the texture every frame.
    A good idea. The image objects I'm using supports dirty rectangles so that would be easy to add.

    /Jonas

  9. #9
    Junior Member Newbie
    Join Date
    Apr 2001
    Location
    Göteborg, Sweden
    Posts
    13

    Re: glDrawPixels y-flip and speed

    Ok, the existing dialog system generates an image with the entire layout, it has been used for pure 2d rendering also. That's why I want to stick to one polygon and not to split it into several.

    I think I get the point, however. Uploading a new texture per update shouldn't take so much time compared to the rest of a game. I thought that texture uploading was a bottleneck. I will measure it of course.

    /Jonte

Similar Threads

  1. flip object with glutReshapeFunc
    By pchopra in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 11-27-2012, 02:01 AM
  2. flip pdf pages
    By humbert in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 04-17-2004, 01:34 PM
  3. Flip normals?
    By vofka in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 05-04-2002, 05:36 AM
  4. glDrawPixels help; glDrawPixels vs. Texture Mapping for bitmaps
    By vorbisus in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 06-11-2001, 10:07 AM
  5. Page Flip
    By Humus in forum OpenGL: Advanced Coding
    Replies: 6
    Last Post: 04-04-2001, 09:30 PM

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