Results 1 to 4 of 4

Thread: Rendering 2D image to the screen

  1. #1
    Newbie Newbie
    Join Date
    Aug 2014
    Posts
    1

    Rendering 2D image to the screen

    I've started learning OpenGL not a while ago, and now I wanted to draw a 2D Image (such as a "player") onto the screen..

    From a google search, I've seen the whole area is quite complicated, and I've seen I can "combine" OpenGL and another library (such as SFML or soil) to make it easier.
    Can you recomend me a library to combine with OpenGL, to draw 2D images into the screen?

    Or maybe it is not that hard, to draw 2D Image with OpenGL itself?

    (If you're giving an example of a good library to combine with OpenGL, I'd appreciate to see a "tutorial" for showing an image into the screen).

    Thanks!

  2. #2
    Senior Member Regular Contributor Agent D's Avatar
    Join Date
    Sep 2011
    Location
    Innsbruck, Austria
    Posts
    281
    Drawing an image onto the screen is as simple as drawing a rectangle (=2 triangles) with a texture mapped on it.

    Here is a tutorial chapter on texturing

  3. #3
    Newbie Newbie
    Join Date
    Oct 2014
    Posts
    1
    Quote Originally Posted by Agent D View Post
    Drawing an image onto the screen is as simple as drawing a rectangle (=2 triangles) with a texture mapped on it.
    Just so that you know... "as simple as" != "drawing a rectangle (=2 triangles) with a texture mapped on it"

  4. #4
    Senior Member Regular Contributor Agent D's Avatar
    Join Date
    Sep 2011
    Location
    Innsbruck, Austria
    Posts
    281
    Quote Originally Posted by chrisyeshi View Post
    "as simple as" != "drawing a rectangle (=2 triangles) with a texture mapped on it"
    What is that supposed to mean? Is it hard to draw a textured rectangle? Or do you have an alternative solution?

    In case you are going to suggest the deprecated glDrawPixels, I tried that once with 10ish images and it got really, really slow (~5 FPS on a GTX285, without anything rendered yet, just the images).

    In case drawing a rectangle is "hard": it is drawn the exact same way as anything else in OpenGL(R). In an application using deprecatd functions, the vertex data could come from glVertex* calls, in
    a GL 3.1+ core profile application, the data comes from a VBO (which might contain other usefull primitives, not juse a rect). In both scenarios, you set up your transformation and projection
    matrices propperly to make it 2D (when using the deprecated matrix stack, projection=identity, modelview=some 2D scaling of your choice; otherwise, you have to send the propper matrices to the
    shader). Texturecoordinates are in the range [0,1] on both axes and texturing is done the same way as anything else.

    If you can drawn something, drawing a rectangle is a matter of getting the vertices right. If you can texture something, texturing a rectangle is trivial. In fact, texturing a rectangle might
    be the best starting point to experiment with texturing. If you managed to turn depth test on for your 3D scene, you already know how to turn it off, so your 2D overlay rectangle does not
    interact with the 3D scene.

Similar Threads

  1. White screen Flicker for rendering image
    By thilegl in forum OpenGL: Linux
    Replies: 0
    Last Post: 01-19-2019, 01:31 AM
  2. Replies: 1
    Last Post: 12-04-2014, 06:50 AM
  3. Replies: 5
    Last Post: 06-17-2004, 11:51 AM
  4. Rendering to a image (Screen Dump)
    By Tronix in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 07-11-2002, 12:39 PM
  5. Rendering An Image OFF Screen
    By King Fuzzy in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 09-20-2001, 10:43 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