OpenGL ..... Fun or Frustration???

a "Flower Power" community that may be interested in ANY part of aircraft sim creation ..... from creating models all the way to creating code
Post Reply
sydbod
Flight Sergeant
Flight Sergeant
Posts: 1679
Joined: Sat Aug 13, 2005 12:39 pm
Location: Sydney,NSW,Australia

OpenGL ..... Fun or Frustration???

Post by sydbod » Sun Sep 27, 2009 12:48 pm

Time to go on a little journey. The same sort of journey like "Alice in Wonderland". In this case though maybe it may be closer to "Siddy in Funnyland".

OK, what do we know?
OpenGL should be a great rendering system that will allow games to be written for all 3 of the major operating systems. Windows, Apple (OS X), Linux.

How easy it will be to make a program that will run on all 3 platforms is yet to be determined. We .... that is ME ... is starting with virtually no background experience, just some funny vague notions that it should all be possible.
The first thing to have clear is that OpenGL is just the rendering part of a program. (The part that puts the graphics onto the screen, provided there is an OpenGL driver installed on a machine for the operating system for that machine).
So far so good. There are OpenGL drivers available for all 3 ... Windows, Apple (OS X), Linux.
Now for the difficult part. Are there counterpart programs for things like networking, I/O (like mouse, keyboard, etc), sound.
The next most important library would be the one that should allow " I/O (like mouse, keyboard, etc)" part to work.
There is a library called "glut" (GL Utility Toolkit). It is a library that acts as a standard interface library for " I/O (like mouse, keyboard, etc)". Using this library with the OpenGL library will allow us to write code that is generic for putting stuff on the screen, as well as handling input and output operations for the player. It appears that a 3rd library called "GLU" (GL Utility) is a collection of utility functions that is usually also coupled with the above 2 to make things a lot easier, so we will also have to include it with them.
It also appears that there is a sound library called "OpenAL" that should be fine for sound. We will look into it at a later time. No point in burying ourselves with too many tasks in the beginning phase.
As far as a generic networking library is concerned ... well I still don't know. This can also be left for a later date.

This is all starting to look a lot more complex than I had thought. Keeping everything limited to just the Microsoft Windows operating system would be much easier .... heck ... if we are going to challenge ourselves, then lets go the whole hog, and see how far we get in creating truly generic code for as many Operating Systems as possible. After all, the idea is to learn something along the way.

Now we all know how many versions of DirectX there are and how many of these have depreciated functionality, as well as totally different ways of doing things .... HMMM!!! there are a number of revisions/versions of OpenGL/GLU/GLUT out there also.

The next task will be to find a set of these libraries that will work with each other and are as late a revision as practically possible.
We know that the latest release of OpenGL is Ver 3.2, but to maintain compatibility with as much video card hardware as possible, it may be bettter to start with Ver 2.0 or there abouts ... you know, cards that are of the DX9 capability, rather than DX10 capable.

Hopefully next post should have a conclusion of the library revisions that have been decided upon, and a quick trial to see if they work together and produce something on a screen.
Time to do some more serious research on the internet. :getsmashed:
Syddy........Just another breed of COOL CAT

Wudpecker
Member of the Code Committee
Member of the Code Committee
Posts: 2095
Joined: Tue Apr 13, 2004 10:24 pm
Contact:

Post by Wudpecker » Sun Sep 27, 2009 3:39 pm

Hope you have a knack for sorting out these systems, Syd.

For a good 10 years of my working life I hung around programmers (Xenix, a form of Unix at the Santa Cruz Operation and with Telmax, an early developer of telephone line multi-plexing that led to our DSL systems, and even with Seagate and Applied Motion Products, the hard drive folks).
I understood much of what they were doing, but never had a knack myself. They were streaking so far ahead of me that I never expected to catch up. I'm still the slow turtle pulling one foot out of the electronic mud at a time, and falling further behind, not gaining on 'em.

OpenGL as I understand it, had a lot of promise as a "portable" graphics system to run on the 3 big platforms--Windows, Apple, Linux (or Unix).
For some reason, I have not seen that popularity hold up. I don't even know that it is supported and still under development. You have better and later information. Is the new version a big improvement?
Is there a reason it hasn't become more widespread?
Glide seems to run faster and better running EAW in a lot of cases than Direct X. But Direct X is nearly universal in use in the PC world. Or am I wrong here?
Can the Microsoft compiler and C/ C++ function as a base for OpenGL? Is it a matter of downloading the proper libraries?

sydbod
Flight Sergeant
Flight Sergeant
Posts: 1679
Joined: Sat Aug 13, 2005 12:39 pm
Location: Sydney,NSW,Australia

Post by sydbod » Mon Sep 28, 2009 2:27 am

Hi Woody,

Its great to have a kindred spirit that has some interest in this to talk with.

YES, OpenGL is just another graphical interface similar to the graphical part of DirectX.

OpenGL has had many upgrades (revisions), just the same as has happened with the various versions of DirectX. The step up from the later OpenGL 2.x versions to the OpenGL 3.0 version was a bit of a disappointment as the steering committee did not include all of the added functionality that many programmers wanted. Also its ratification was very late in coming .... some of the committee were siting on their hands with too much infighting. I believe the latest OpenGL 3.2 is very similar to the DX10 DX11 capability, and is very good.

We may see a small resurgence of OpenGL again because of Microsofts policy of not supporting DX10 and DX11 on WinXP, where as all the versions of OpenGL will function on all the versions of windows provided the video card in the machine will also support the features .

At the moment I am having a good look around to see if there is a particular version of OpenGL/GLU/GLUT that has some sort of sweet spot within the industry .... things like maximum support ... minimum problems ... etc.

The thing that started me on this quest was a group of video clips that I came across, dealing with OpenGL programing. You may find them interesting also.
http://www.videotutorialsrock.com/

The bottom left blue text are the links to all the tutorials. It is well worth the look and see.

Can the Microsoft compiler and C/ C++ function as a base for OpenGL? Is it a matter of downloading the proper libraries?

A BIG YES on that :)

Regards Syddy.
Syddy........Just another breed of COOL CAT

Wudpecker
Member of the Code Committee
Member of the Code Committee
Posts: 2095
Joined: Tue Apr 13, 2004 10:24 pm
Contact:

Post by Wudpecker » Mon Sep 28, 2009 10:38 am

Since Glide wrappers seem to help our FPS on older machines (and possibly many newer machines and video cards), this may be a fruitful effort on your part.

Spent some time on the OpenGL tutorial. Will get back to some questions when I have more time, such as the transforms. It has a practical application such as creating a moving "row" of exhaust smokes on inline engine starts. Ralf's current code does not seem to work well on this (to my eyes).

sydbod
Flight Sergeant
Flight Sergeant
Posts: 1679
Joined: Sat Aug 13, 2005 12:39 pm
Location: Sydney,NSW,Australia

Post by sydbod » Mon Sep 28, 2009 3:19 pm

OpenGL ..... Fun or Frustration???


I have been having a lot of "Frustration" up till now .... when will the "Fun" begin?

OK ... what has been discovered.

It appears that all the the VisualC++ express versions of the compiler do come preconfigured to compile for "OpenGL 1.1". All the header files and library files are alreadu in the SDK, and Windows already has the required DLL files within its system files.

To get OpenGL 1.1 to work as we want it, all that we will have to do is to add and configure "GLUT" in with it.

It appears that we have to get the Nvidia SDK or a similar ATI/AMD version to get access to the later functionality of OpenGL 2.0 or higher. The required *.H,*.Lib and the DLLs should be in there (from what I have been told).
It may be worthwhile to start of with OpenGL 1.1 to confirm that we know what we are doing and then at some later time bring in the additional files to up the version, should we require it.

Time to look at where all the sources are and configure up a working system as the next step.
Syddy........Just another breed of COOL CAT

sydbod
Flight Sergeant
Flight Sergeant
Posts: 1679
Joined: Sat Aug 13, 2005 12:39 pm
Location: Sydney,NSW,Australia

Post by sydbod » Tue Sep 29, 2009 12:13 pm

So, what has been the progress ????

We downloaded glut3.7.6 as it is the latest version.
Remember, we want to use GLUT because it acts as a uniform interface for all 3 operating systems (Windows, OS X, Linux).

It was only necessary to copy the "glut.h" into the Windows SDK "GL" folder. Copy the "glut32.lib" into "LIB" folder of the Windows SDK. Place the "glut32.dll" into the Windows System folder.

That is it ... all now works for compiling OpenGL programs up to OpenGL 1.1 level.

One of the first things we wanted to try, was to confirm that AA can be made to work from within GLUT. We want to do Forward rendering, rather than deferred rendering, so AA is possible and desirable.


GLUT requires the project to be a console application.
Here is the test program that was used:

Code: Select all

/* File for "Lighting" lesson of the OpenGL tutorial on
 * www.videotutorialsrock.com
 */



#include <iostream>
#include <stdlib.h>
#include <GL/glut.h>

using namespace std;

//Called when a key is pressed
void handleKeypress(unsigned char key, int x, int y)
{
   switch (key)
   {
      case 27: //Escape key
         exit(0);
   }
}

//Initializes 3D rendering
void initRendering()
{
   glEnable(GL_DEPTH_TEST);
   glEnable(GL_COLOR_MATERIAL);
   glEnable(GL_LIGHTING); //Enable lighting
   glEnable(GL_LIGHT0); //Enable light #0
   glEnable(GL_LIGHT1); //Enable light #1
   glEnable(GL_NORMALIZE); //Automatically normalize normals
   //glShadeModel(GL_SMOOTH); //Enable smooth shading
}

//Called when the window is resized
void handleResize(int w, int h)
{
   glViewport(0, 0, w, h);
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
   gluPerspective(45.0, (double)w / (double)h, 1.0, 200.0);
}

float _angle = -70.0f;

//Draws the 3D scene
void drawScene()
{
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   
   glMatrixMode(GL_MODELVIEW);
   glLoadIdentity();
   
   glTranslatef(0.0f, 0.0f, -8.0f);
   
   //Add ambient light
   GLfloat ambientColor[] = {0.2f, 0.2f, 0.2f, 1.0f}; //Color (0.2, 0.2, 0.2)
   glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambientColor);
   
   //Add positioned light
   GLfloat lightColor0[] = {0.5f, 0.5f, 0.5f, 1.0f}; //Color (0.5, 0.5, 0.5)
   GLfloat lightPos0[] = {4.0f, 0.0f, 8.0f, 1.0f}; //Positioned at (4, 0, 8)
   glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColor0);
   glLightfv(GL_LIGHT0, GL_POSITION, lightPos0);
   
   //Add directed light
   GLfloat lightColor1[] = {0.5f, 0.2f, 0.2f, 1.0f}; //Color (0.5, 0.2, 0.2)
   //Coming from the direction (-1, 0.5, 0.5)
   GLfloat lightPos1[] = {-1.0f, 0.5f, 0.5f, 0.0f};
   glLightfv(GL_LIGHT1, GL_DIFFUSE, lightColor1);
   glLightfv(GL_LIGHT1, GL_POSITION, lightPos1);
   
   glRotatef(_angle, 0.0f, 1.0f, 0.0f);
   glColor3f(1.0f, 1.0f, 0.0f);
   glBegin(GL_QUADS);
   
   //Front
   glNormal3f(0.0f, 0.0f, 1.0f);
   //glNormal3f(-1.0f, 0.0f, 1.0f);
   glVertex3f(-1.5f, -1.0f, 1.5f);
   //glNormal3f(1.0f, 0.0f, 1.0f);
   glVertex3f(1.5f, -1.0f, 1.5f);
   //glNormal3f(1.0f, 0.0f, 1.0f);
   glVertex3f(1.5f, 1.0f, 1.5f);
   //glNormal3f(-1.0f, 0.0f, 1.0f);
   glVertex3f(-1.5f, 1.0f, 1.5f);
   
   //Right
   glNormal3f(1.0f, 0.0f, 0.0f);
   //glNormal3f(1.0f, 0.0f, -1.0f);
   glVertex3f(1.5f, -1.0f, -1.5f);
   //glNormal3f(1.0f, 0.0f, -1.0f);
   glVertex3f(1.5f, 1.0f, -1.5f);
   //glNormal3f(1.0f, 0.0f, 1.0f);
   glVertex3f(1.5f, 1.0f, 1.5f);
   //glNormal3f(1.0f, 0.0f, 1.0f);
   glVertex3f(1.5f, -1.0f, 1.5f);
   
   //Back
   glNormal3f(0.0f, 0.0f, -1.0f);
   //glNormal3f(-1.0f, 0.0f, -1.0f);
   glVertex3f(-1.5f, -1.0f, -1.5f);
   //glNormal3f(-1.0f, 0.0f, -1.0f);
   glVertex3f(-1.5f, 1.0f, -1.5f);
   //glNormal3f(1.0f, 0.0f, -1.0f);
   glVertex3f(1.5f, 1.0f, -1.5f);
   //glNormal3f(1.0f, 0.0f, -1.0f);
   glVertex3f(1.5f, -1.0f, -1.5f);
   
   //Left
   glNormal3f(-1.0f, 0.0f, 0.0f);
   //glNormal3f(-1.0f, 0.0f, -1.0f);
   glVertex3f(-1.5f, -1.0f, -1.5f);
   //glNormal3f(-1.0f, 0.0f, 1.0f);
   glVertex3f(-1.5f, -1.0f, 1.5f);
   //glNormal3f(-1.0f, 0.0f, 1.0f);
   glVertex3f(-1.5f, 1.0f, 1.5f);
   //glNormal3f(-1.0f, 0.0f, -1.0f);
   glVertex3f(-1.5f, 1.0f, -1.5f);
   
   glEnd();
   
   glutSwapBuffers();
}

void update(int value)
{
   _angle += 0.5f;
   if (_angle > 360)
      _angle -= 360;   
   glutPostRedisplay();
   glutTimerFunc(25, update, 0);
}

int main(int argc, char** argv)
{
   //Initialize GLUT
   glutInit(&argc, argv);
   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_MULTISAMPLE); // does AA work ?????

   /****************************
   *      FOR A WINDOW      *
   ****************************/
   glutInitWindowSize(800, 600);
   glutCreateWindow("Lighting of cube");

   /****************************
   *      FOR FULL SCREEN      *
   ****************************/
   //glutGameModeString( "800x6000:32@60" ); //the settings for fullscreen mode
   //glutEnterGameMode(); //set glut to fullscreen using the settings in the line above
   
   initRendering();
   
   //Set handler functions
   glutDisplayFunc(drawScene);
   glutKeyboardFunc(handleKeypress);
   glutReshapeFunc(handleResize);
   
   glutTimerFunc(25, update, 0); //Add a timer
   
   glutMainLoop();
   return 0;
}


The results were:
Image

If one looks at the top and bottom edges of the cube one can see that the AA mode is not working when in window mode.
The exact same results happen when using full screen mode.

After doing an extensive search on the internet it appears that this problem is very common when using GLUT.

By not being able to use GLUT, there is no way to keep easy code compatability across all 3 targeted operating systems.
Without this capability, one has to ask if one wants to stay with OpenGL. If one has to create dedicated code for all 3 systems, then one may as well stay with just one system (Windows) and use DirectX as its documentation and support is more easily available.

This is something that will require a few days to think about.
YEP we are still on the "FRUSTRATION" part of this topic.
Last edited by sydbod on Wed Sep 30, 2009 3:41 pm, edited 1 time in total.
Syddy........Just another breed of COOL CAT

sydbod
Flight Sergeant
Flight Sergeant
Posts: 1679
Joined: Sat Aug 13, 2005 12:39 pm
Location: Sydney,NSW,Australia

Post by sydbod » Wed Sep 30, 2009 3:39 pm

Just to consolidate a bit more information before I forget it ... it may be useful to others at some later time.

The following is only applicable for Windows .... I did not test other operating systems.

GLUT : AA can not be enabled under ATI/AMD video cards. I do not know the status for Nvidia video cards.

Open Glut: Forget it for Windows and FULL screen mode. HUGE chunks of functions for full screen code is missing, although AA did work in windowed mode.

How does one ADD later versions of functionality to OpenGL 1.1 that exists on windows,
http://www.elf-stone.com/glee.php
Glee: It simply and cleanly adds the extensions to your source code in your compiler:"To use GLee, include GLee.h, then simply link to GLee.lib or alternatively add GLee.c to your project. "
Current version "Glee5.4" brings you to OpenGL 3.0 level.

The research continues. :?
Syddy........Just another breed of COOL CAT

sydbod
Flight Sergeant
Flight Sergeant
Posts: 1679
Joined: Sat Aug 13, 2005 12:39 pm
Location: Sydney,NSW,Australia

Post by sydbod » Sat Mar 20, 2010 12:55 pm

What is the bet you all thought that this thread was dead :)

WELL !!!!! it has one more post in it.

After finding some more free time while babysitting my sick mother in law for 3 days every week, and finally letting the moths out of my wallet and purchasing a laptop, I have spent some more time trying to work around the limitations of GLUT and the non working AA.

YES there are other frameworks I could use ... like SDL, but they all appeared to be a bit too complex for a novice to use them and I am hoping that some of these posts may be of value to novices and provide some inspiration for them to try out OpenGL and maybe even some other operating systems like Linux, for game development.

I have accidently come across another framework that is as easy to use as GLUT, and works on all the major computer platforms and operating systems.
It is called "OpenGL framework" or "GLFW" for short.
Yes I have tested it out and it does support all the things that GLUT supported .... AND ... AA also works on the ATI video cards. It is also as easy to use as GLUT was. :)

It also has some nice support for easy multithreading code. This is an extra bonus that should be worth playing with further down the line.

This thread is now closed and a new discovery thread will be started in the next few days that will be dealing with "GLFW". All the experimental code will be based on it, and will be compiled using "VC++ 2010 express beta 2" , until the official release of "VC++ 2010 express" happens in around a months time.

We may even try and create some routines to import 3D models from a flightsim called EAW, just to see how different data formats may be handled, and how these data formats may be used with OpenGL.

Till next time
Syddy :)
Syddy........Just another breed of COOL CAT

Post Reply