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 16

Thread: graphics.h equivqlent under Linux

Hybrid View

  1. #1
    Newbie Newbie
    Join Date
    Jun 2013
    Posts
    2

    graphics.h equivqlent under Linux

    I'am checking the feasibility of introducing gcc compiler for sophomores in undergraduate course instead of TurboC compiler.Kindly advice me if OpenGL can serve as replacement for graphics.h header file in TurboC?

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,213
    I haven't used Borland Turbo Pascal/C for decades, but scanning the graphics.h functions, it looks like basically yes. Drawing points, lines, polygons, etc. The graphics.h functions are more pixel centric though (flood fill ops, fill style, etc.) whereas in OpenGL you'd define the region you want to fill and draw triangles/polygons on it. The one thing that you would have to pull in another library for is text rendering as that's not part of core OpenGL, and there are a number of choices there (such as those built on freetype).

  3. #3
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,128
    What are your specific needs here? What type of applications have you got in mind?

    And please be aware: The stuff Dark Photon is referring to is all legacy OpenGL functions.

  4. #4
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,213
    Quote Originally Posted by thokra View Post
    And please be aware: The stuff Dark Photon is referring to is all legacy OpenGL functions.
    Nah, not all. Drawing triangles is meat and potatoes stuff, whether compatibility profile ("legacy") or core profile. Polygons is relegated to the compatibility profile though. For core, you need to tessellate them yourself.

    There's more helper tools in the compatibility profile (the default), which you can use when getting your graphics legs. Think of them as training wheels, which you can jettison when you know what's going on (and know why there's a benefit to doing so). Or you can be a purest and build all your own furniture from scratch from the get go.

    Like thokra says though, what you want depends on your needs. What are you trying to train your students to do, and what kind of students are they (e.g. CS majors learning GPU rendering, or some other major/specialization aiming toward a different goal)?
    Last edited by Dark Photon; 06-12-2013 at 07:40 PM.

  5. #5
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,128
    Nah, not all. Drawing triangles is meat and potatoes stuff, whether compatibility profile ("legacy") or core profile
    Just to be clear, I wasn't arguing that there isn't a triangle or a line primitive type in core OpenGL - of course there is and of course there are ways to render such primitives. I overreached a little and I think it's because I was thinking of Qt and the rendering functions QPainter offers when writing my comment. I should sleep more.

    But yeah, there's nothing like a drawLine() or fillQuad() OpenGL function which handles everything for you, like many software graphics APIs offer(ed) - including the ancient TurboC stuff layered on top of Xlib if I got it right.
    Last edited by thokra; 06-13-2013 at 03:10 AM.

  6. #6
    Advanced Member Frequent Contributor
    Join Date
    Aug 2004
    Location
    munich, germany
    Posts
    659
    tbh, i don't know turboc at all, but i suppose the graphics.h you mentioned serves for 2D graphics.

    in linux, there are loads of 2D graphics functions, check this page for details: http://tronche.com/gui/x/xlib/
    those functions do not use OpenGL.

    and of course, you can use OpenGL for 2D graphics too.

    so, it's up to you to choose what would be better.

    in Xlib, you would draw line with
    XDrawLine(display, d, gc, x1, y1, x2, y2)

    in OpenGL, it looks like
    glBegin(GL_LINES);

    glVertex2i(x1, y1);
    glVertex2i(x2, y2);
    glEnd()

    in my opinion, the xlib version might be more comprehensive for a beginner.
    and, if you use xlib, you learn more about the linux system than when you use OpenGL.

    but OpenGL is, in my opinion, the better choice. it can be used in linux, unix, windows, and on mobile phones.
    it is usually hardware-accelerated. and while xlib is limited to 2D graphics, you can do 3D stuff with OpenGL using
    *exactly the same commands* a line in 3D would be


    glBegin(GL_LINES);

    glVertex3f(x1, y1, z1);
    glVertex3f(x2, y2, z2);
    glEnd()and, in OpenGL you have full access to all the cool stuff (shaders etc)

Posting Permissions

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