Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: graphics.h equivqlent under Linux

  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,183
    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,183
    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)

  7. #7
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,128
    Quote Originally Posted by RigidBody
    but OpenGL is, in my opinion, the better choice. it can be used in linux, unix, windows, and on mobile phones.
    It depends. OpenGL is a better choice if you opt for high performance applications that need a lot of computational power. If you're fine with drawing some primitives (and honestly, the TurboC stuff isnÄt good for anything else), something like Qt is much more suitable. You get cross-platform, convenience window system abstraction which is reasonably fast in a lot of cases on the desktop and mobile platforms.

  8. #8
    Advanced Member Frequent Contributor
    Join Date
    Aug 2004
    Location
    munich, germany
    Posts
    659
    qt is basically a widget library which requires good understanding of c++, including inheritance, virtual functions and all that stuff.
    i would not recommend making students learn how to use it if you just want to make them draw something.

    qt is a great lib which makes programming GUIs pretty easy (if you know how it works), but i wouldn't use
    it for an application that does not have a GUI with at least one button.

  9. #9
    Newbie Newbie
    Join Date
    Jun 2013
    Posts
    2
    Looks like OpenGL and Xlib are good alternatives for graphics.h!!!

  10. #10
    Advanced Member Frequent Contributor
    Join Date
    Aug 2004
    Location
    munich, germany
    Posts
    659
    have you tried the example from the wiki?
    http://www.opengl.org/wiki/Programmi...:_GLX_and_Xlib

Posting Permissions

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