Jump to content

  • Log In with Google      Sign In   
  • Create Account

New to OpenGL, I have a few questions


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
10 replies to this topic

#1 Krankles   Members   -  Reputation: 281

Like
0Likes
Like

Posted 07 February 2013 - 09:14 PM

Hi, I've learned and know the basics of C++ and wanting to know how to get into OpenGL. I know there's multiple threads about this, but it's all very confusing.

 

Where can I download OpenGL? I see in threads that it comes from the video card drivers, and that you have to use something like GLEW. Next, what tutorial should I use to learn OpenGL? Also, I want to focus on the 2D side first, before 3D, so things are a bit easier. I'm programming in Arch Linux, using vim. However, I will also be porting my code to Windows, so on my computer, I will also compile using windows. I see that NeHe tutorials are recommended but his is about an older version of OpenGL and it's in 3D. Is there any other ones that can meet my criteria? I need a tutorial that helps absolute beginners.

 

Thanks.


Edited by Krankles, 07 February 2013 - 09:17 PM.


Sponsor:

#2 __SKYe   Members   -  Reputation: 1041

Like
1Likes
Like

Posted 08 February 2013 - 01:17 AM

Ok, first you should download GLEW.

It allows you to use modern OpenGL, and it's very easy to set up.

Also, if you want to start more easily, you can use GLUT.

 

When you're using OpenGL, you have to render polygons on the screen no matter if you use 2D or 3D.

For example, while you may use many polygons to draw a 3D model, you also have to draw some polygons to draw a 2D image on the screen (for 2D, if you wanted an image (texture) on the screen, you'd usually texture map a quad or 2 triangles).

The difference comes in the type of projection you use (normally a perspective projection in 3D, and an orthogonal projection in 2D, which usually is set to match the coordinates of the screen in pixels).

 

For tutorials, NeHe tutorials are indeed about the older, fixed function, OpenGL, although they still present very useful material.

You can also go to http://www.arcsynthesis.org/gltut/index.html, that has very good tutorials about modern OpenGL.

 

Hope it helps.



#3 Krankles   Members   -  Reputation: 281

Like
0Likes
Like

Posted 08 February 2013 - 07:44 AM

Thank you! This is EXACTLY what I needed. I hope this helps other newcomers to OpenGL like me!

EDIT: Apparently the tutorial uses GLUT? Will there be any differences if I use GLEW?

EDIT2: Also, the tutorial doesn't explain how I can include the header files.


Edited by Krankles, 08 February 2013 - 08:13 AM.


#4 wintertime   Members   -  Reputation: 1714

Like
1Likes
Like

Posted 08 February 2013 - 08:45 AM

Its something completely different.

Librarys like GLUT(old and takes away control over the game loop -> dont use),FreeGLUT(newer rewrite of GLUT for if you really want it),GLFW(slim but allows modern contexts),SDL(bloated but widely used, I wonder how long it takes for the new version), SFML(got some extras and is nice to use) are for helping you getting a Window and a Context to draw in and provide means to poll the OS event queue for events like resizing, mouse and keyboard input. Some also have other extras.

Then theres librarys like Glee(older, but should still work, possibly get latest SVN version from sourceforge), GLEW(more recently updated -> better use this) that, after you (with native OS calls) or one of the first group of librarys got a OpenGL context, loads function pointers for you so you can use newer OpenGL functions.



#5 Krankles   Members   -  Reputation: 281

Like
0Likes
Like

Posted 08 February 2013 - 08:53 AM

I see, so this tutorial wouldn't be greatly applicable to me since it uses freeGLUT. I do like the way it explains stuff though, however, it just doesn't seem to give me the code that allows me to use the opengl functions via GLEW.

 

Is there any other tutorial that I can learn from that uses GLEW and possibly teaches the programmable pipeline instead of fixed? Or would I have to install and use freeGLUT?

EDIT: I noticed that this tutorial lets you check out their source code which is fine, but it still uses freeGLUT which I am more interested in using GLEW instead. So if there's any alternatives please tell me.

EDIT2: After some further research, I think GLEW and FreeGLUT goes together? This is what I mean, it's just so confusing. Can someone confirm that GLEW and FreeGLUT are different things and that they go together?

EDIT3: I'm learning OpenGL so I can create some nice 2D/3D games with hardware acceleration instead of using the old blitting technique. I just want a nice nudge in the right direction.

 

Thanks.


Edited by Krankles, 08 February 2013 - 09:03 AM.


#6 Krankles   Members   -  Reputation: 281

Like
0Likes
Like

Posted 08 February 2013 - 11:36 AM

One last question, (and sorry for double post) what library should I use in conjunction with GLEW? Out of the three should I use SFML? SDL? or FreeGLUT? I've used SFML in the past, but I've read that you don't really use any of the drawing from SFML. All you're using it for is the creation of window and inputs. OpenGL does the rendering for you. So I was thinking of something more lightweight like FreeGLUT but again, I'm new to this so please lead me in the right direction.

 

 

Thanks.


Edited by Krankles, 08 February 2013 - 12:22 PM.


#7 wintertime   Members   -  Reputation: 1714

Like
1Likes
Like

Posted 08 February 2013 - 03:16 PM

For something lightweight I would try GLFW, but if you liked SFML you can just use it again (get the 2.0 version) as you already know it a bit (if you dont need more its fine to just use the system and window part) and you can probably use a bit of the graphics part of it for texture loading+binding and loading some font and drawing some text on a texture(text output with a premade font is not fun to program yourself) which you can then use in OpenGL.

If you are only doing a simple 2D game you could maybe even get away with just using SFML-graphics and not do OpenGL calls yourself, as sadly you can only give it x and y coordinates and even for sorting some sprites on screen it would be nice to be able to use a z coordinate to take advantage of the depth buffer too. Also there is the audio part for having some sound later or the network part which abstracts the sockets a tiny bit, but you can decide yourself if you want to use some other library for this later.

 

But dont worry too much about choosing a window library, you will see just a bit of initialization thats different for each and some loop where you get input from it and 1 call to swap the front and backbuffer, then it gets invisible and you can just use OpenGL for drawing if you dont explicitly decide on using some extra features of the library. That also means you dont need to use the same library as some tutorial you read, its maybe just first lesson where the window does get setup(this you can also read on the example at the website of your favorite library) and then its just the same OpenGL that gets added onto it.

Btw., if you go the modern way GLM will do any matrix calculations for you.

 

There are some more tutorials:

http://duriansoftware.com/joe/An-intro-to-modern-OpenGL.-Table-of-Contents.html

http://arcsynthesis.org/gltut/

http://www.swiftless.com/opengltuts/opengl4tuts.html

http://www.opengl-tutorial.org/

http://ogldev.atspace.co.uk/



#8 Serapth   Crossbones+   -  Reputation: 5470

Like
0Likes
Like

Posted 08 February 2013 - 03:58 PM

I see, so this tutorial wouldn't be greatly applicable to me since it uses freeGLUT. I do like the way it explains stuff though, however, it just doesn't seem to give me the code that allows me to use the opengl functions via GLEW.

 

Is there any other tutorial that I can learn from that uses GLEW and possibly teaches the programmable pipeline instead of fixed? Or would I have to install and use freeGLUT?

EDIT: I noticed that this tutorial lets you check out their source code which is fine, but it still uses freeGLUT which I am more interested in using GLEW instead. So if there's any alternatives please tell me.

EDIT2: After some further research, I think GLEW and FreeGLUT goes together? This is what I mean, it's just so confusing. Can someone confirm that GLEW and FreeGLUT are different things and that they go together?

EDIT3: I'm learning OpenGL so I can create some nice 2D/3D games with hardware acceleration instead of using the old blitting technique. I just want a nice nudge in the right direction.

 

Thanks.

 

 

This tutorial series uses GLEW.  It wont teach you how to include files or set up your environment, but does come with a number of preconfigured projects on github.



#9 Krankles   Members   -  Reputation: 281

Like
0Likes
Like

Posted 08 February 2013 - 07:53 PM

Thanks, after skimming through these tutorials I think I can learn opengl. But I don't get how I can make 2D games using opengl? All these tutorials are about 3D, I was hoping I could benefit from opengl, the performance boost and that when I start getting into 3D I already know basically the syntax and stuff.

 

EDIT: I'm sort of interested in GLFW. Would it be wise to use GLFW for actual games? For sound I could go ahead and learn OpenAL, etc. Also, I really am interested in trying to make a few drawings in 2D. An example would be nice if possible, or maybe a tutorial?

 

EDIT2: Can someone please help me distinguish between GLFW and GLEW? I see that they can work together but I'm having a hard time distinguishing.


Edited by Krankles, 08 February 2013 - 08:38 PM.


#10 wintertime   Members   -  Reputation: 1714

Like
0Likes
Like

Posted 09 February 2013 - 09:27 AM

For 3D you use a perspective projection, which makes further away objects smaller. For 2D you just set an orthographic(=parallel) projection instead and everything becomes the same size, also you can pretty much ignore the z coordinate(set it to 0 or just use it for things like having the sprites appear above the background). Thats all.

 

GLFW - if you like it just use it and dont worry too much about it.

 

GLFW vs. GLEW - perhaps reread my first posting in this thread. Window librarys like GLFW are for making a window, contex and getting input, so that OpenGL knows where to it should draw. Extension loaders like GLEW just do the tedious task of calling a special OpenGL function which gives function pointers to all other OpenGL functions for you; you just include glew.h instead of gl.h, call its glewInit function after a context is active and the pretty much forget about its existence.



#11 Krankles   Members   -  Reputation: 281

Like
0Likes
Like

Posted 09 February 2013 - 10:55 AM

For 3D you use a perspective projection, which makes further away objects smaller. For 2D you just set an orthographic(=parallel) projection instead and everything becomes the same size, also you can pretty much ignore the z coordinate(set it to 0 or just use it for things like having the sprites appear above the background). Thats all.

 

GLFW - if you like it just use it and dont worry too much about it.

 

GLFW vs. GLEW - perhaps reread my first posting in this thread. Window librarys like GLFW are for making a window, contex and getting input, so that OpenGL knows where to it should draw. Extension loaders like GLEW just do the tedious task of calling a special OpenGL function which gives function pointers to all other OpenGL functions for you; you just include glew.h instead of gl.h, call its glewInit function after a context is active and the pretty much forget about its existence.

 

Thank you for the explanation! I'll be on my way to learning OpenGL.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS