PDA

View Full Version : GLUT or general OpenGL program?



Bitwize
12-30-2010, 05:00 PM
I'm trying to decide between using the GLUT IDE or creating a general OpenGL program, and I can't figure out which would be better for the project I am supposed to do.

Quite simply, I am supposed to make a model of the solar system (in 3d of course), and it looks as though a general OpenGL program would be easier to do algorithmically - however - it also appears that the GLUT has built in functions for drawing spheres and doing background processing.

What would be my best bet?
Would really appreciate a hasty response; no time to waste.

Thanks in advance to all who answer,
~Bitwize

Dark Photon
12-30-2010, 05:30 PM
I would start with GLUT just to get going, and if you ever need something that is incompatible with GLUT, then at that time you can convert. You may not. And it's not like you'll have to rewrite your application. You just pop in a different init (a more complex one) and register your callbacks differently.

Nice thing about using GLUT is that it is cross-platform by default.

Bitwize
12-30-2010, 08:44 PM
I'm currently getting an incredibly annoying issue with a GLUT enabled program, claiming:
The procedure entry point _glutCreateWindowWithExit could not be located in the dynamic link library glut32.dll

I linked in the appropriate libraries to use GLUT, and so I can't entirely understand why it's giving me an issue.
I don't suppose you may know how to solve that issue? I could post the code I'm using if I have to

mobeen
12-30-2010, 09:06 PM
Are u using freeglut or glut?

Bitwize
12-30-2010, 10:49 PM
Are u using freeglut or glut?
Using GLUT, but I found the error. Somehow the glut32.dll file that I had was from 1998 (I have no idea how that even happened (._.') )

General question, if anyone is still reading this thread; I have the coordinates being calculated for it's x, y, z positions - and I was wondering how I would place spheres in this considering it's in polar coordinates?

And better yet, what the function is. Do I use a move function, or just redraw the screen? I'm reading the documentation as best I can, but there is so much that it's hard to pinpoint precisely where I should look.

EDIT:
I just wanted to add that I'm using the glutSolidSphere function for creating spheres, and it only has parameters for it's radius, slices, and stacks.
I found a small piece of code online that does virtually that same thing for drawing spheres


void drawSphere(double r, int lats, int longs)
{
int i, j;
for(i = 0; i <= lats; i++)
{
double lat0 = PI * (-0.5 + (double) (i - 1) / lats);
double z0 = sin(lat0);
double zr0 = cos(lat0);

double lat1 = PI * (-0.5 + (double) i / lats);
double z1 = sin(lat1);
double zr1 = cos(lat1);

glBegin(GL_QUAD_STRIP);
for(j = 0; j <= longs; j++)
{
double lng = 2 * PI * (double) (j - 1) / longs;
double x = cos(lng);
double y = sin(lng);

glNormal3f(x * zr0, y * zr0, z0);
glVertex3f(x * zr0, y * zr0, z0);
glNormal3f(x * zr1, y * zr1, z1);
glVertex3f(x * zr1, y * zr1, z1);
}
glEnd();
}
}

but even that I don't entirely see how I could modify it to take x,y,z coordinates (I lack any knowledge of how to use polar)

mobeen
12-30-2010, 11:09 PM
All of the object drawing functions (like glutSolidSphere etc.) draw the object at origin. To place the object u need to apply the transformation matrix to the current modelview matrix.

Bitwize
12-31-2010, 01:02 AM
Sweet, I think I got everything now.
Unless I have a misunderstanding of how they work, this:


glPushMatrix();
glTranslatef(x, y, z);
glutSolidSphere(radius, slices,stacks);
glPopMatrix();

seems to do exactly what I'm looking for.

Of course, I have tested with a few objects and it seems to do exactly that, so I am hoping it is correct.

mobeen
12-31-2010, 02:00 AM
yep, a pre opengl 3.0 version. In 3.0 and above the fixd function pipeline (initially deprecated in v3.0)and now has been removed completely 3.3 and abovein the core profile though they are available in the compatability profile). You should opt for shaders now and use them instead of the old fashion way.

Regards,
Mobeen