Thread: Some Qs regarding the nature of OpenGL

  1. #1
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657

    Some Qs regarding the nature of OpenGL

    I've heard that OpenGL is just a specification; its implementation is completely a responsibility of the environment. --- In that case, How does its nature differ from a normal programming language (which afaik is also made in specifications.) ?

    Every tutorial/book I see about OpenGL (for Linux based systems) ..talk about linking to libgl.
    Could I compile the same(as in completely same, not similar) code in Windows ..or anywhere else?

    Is it a better idea to learn the QT based wrapper for OpenGL..(QT GL || QT OpenGL ) to ensure that I can use the same programs everywhere?

  2. #2
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    OpenGL is a standardized API, not a library. If you stick to the standard you should be pretty safe (much like sticking to the standard C library). Using a wrapper around OpenGL isn't a bad thing in itself, but it actually could hurt your portability instead of helping it if you're not careful.

    If you're coding in C++, it's not difficult to write some very helpful higher-level wrappers and routines to make things easier. You could rely on Qt, but then you're relying on a product, not a standard.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  3. #3
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by manasij7479 View Post
    Every tutorial/book I see about OpenGL (for Linux based systems) ..talk about linking to libgl.
    Could I compile the same(as in completely same, not similar) code in Windows ..or anywhere else?
    Yes.

    Is it a better idea to learn the QT based wrapper for OpenGL..(QT GL || QT OpenGL ) to ensure that I can use the same programs everywhere?
    OpenGL has to run inside something which deals with the windowing system. That could be qt, but that would be a strange choice to learn via, especially if it provides C++ wrappers for the core GL functions.
    Most people use glut or SDL. As brewbuck says, if you understand C and C++ it is not a hard thing to come up with your own classes and wrappers which suit what you are doing/how you want to do it.

    In any case, openGL is more portable than qt itself, so doing that will not increase the chance of "ensur[ing] that I can use the same programs everywhere"; it will do the opposite.
    Last edited by MK27; 06-14-2011 at 04:56 AM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  4. #4
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    OpenGL has to run inside something which deals with the windowing system
    That is another point I'm confused about ...
    Why must the windowing system be on a lower level than opengl..?
    How do they(say.. X11..) perform the graphical operations?
    Can't an OpenGl implementation be built so that it is at a comparatively lower level ?
    Is OpenGL(or equivalent) is the lowest portable level in graphics?....
    Last edited by manasij7479; 06-14-2011 at 07:09 AM.

  5. #5
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by manasij7479 View Post
    Why must the windowing system be on a lower level than opengl..?
    I suppose it doesn't have to be, but if you are running a graphical desktop when you launch your OGL application, then it is going to be, and that is usually the case. The windowing system also provides an abstraction layer for events (eg, hardware controls such as the keyboard, mouse, and joystick, which openGL does not deal with in any way). [nb. as brewbuck points out below, this is sort of a misuse of the terms "higher" and "lower", but I think I'm addressing your concern].

    How do they(say.. X11..) perform the graphical operations?
    WRT to OGL, they don't. This is why you need the adapter (qt, or glut, or whatever).

    Can't an OpenGl implementation be built so that it is at a comparatively lower level ?
    Maybe. Maybe there even is one already. However, it is going to be a pretty obscure thing, because very few people will want to bother dropping into terminal mode (presuming your OS can do that) to launch a GL application when there is no real reason to do so, and it is going to have to provide it's own abstraction layer for those hardware control events mentioned above.
    Last edited by MK27; 06-14-2011 at 11:27 AM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  6. #6
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by manasij7479 View Post
    That is another point I'm confused about ...
    Why must the windowing system be on a lower level than opengl..?
    It isn't. The windowing system is a higher level. OpenGL just puts pixels on a particular rectangle on the screen, it has no idea about windows. The windowing system just provides that rectangle where OpenGL will draw its stuff.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  7. #7
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    Then... What would be the difference between the Windowing System displaying a window according to the instructions of say....windows api ...AND... OpenGL borrowing a rectangle and creating the elements of the window from OpenGL code...

    Is the later used much?...if not...why?..It could solve a lot of portability problems..!

  8. #8
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    OpenGL is a 3D rendering API that directs mechanisms implemented in hardware whereas the Windows GDI API is a 2D fixed abstraction.

    The largest difference would be speed.

    Soma

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 09-02-2010, 01:26 PM
  2. OpenGl Help
    By lucien in forum C++ Programming
    Replies: 8
    Last Post: 11-11-2008, 03:12 PM
  3. OpenGL Quesiton: Does Windows XP, Vista still at OpenGL 1.1?
    By indigo0086 in forum Game Programming
    Replies: 8
    Last Post: 05-21-2007, 11:18 AM
  4. Replies: 5
    Last Post: 02-12-2006, 08:42 PM
  5. OpenGL, texturing...and...more OpenGL
    By Sunny in forum Game Programming
    Replies: 2
    Last Post: 07-08-2002, 02:34 PM