Originally Posted by
kas2002
I figured it out.
No dice. That is way too long winded, meaning you are covering up some misunderstanding and/or mistake. Here is the entire program I used to create that read and green hydrogen nucleus*:
Code:
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#include <GL/glext.h>
void change (int w, int h);
void init(float R, float G, float B);
void scene();
int main(int argc, char *argv[]) {
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(1200,800);
glutCreateWindow("openGL test");
glutReshapeFunc(change); /* must be AFTER CreateWindow... */
glutDisplayFunc(scene);
init(0.0,0.0,1.0);
glutMainLoop();
}
void change (int w, int h) {
float aspect=(float)w/(float)h;
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(50.0f,aspect,1.0f,500.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void init(float R, float G, float B) {
glEnable(GL_DEPTH_TEST);
glClearColor(R,G,B,1.0f);
}
void scene() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor4f(1.0f,0.0f,0.0f,0.6f);
glutSolidSphere(1.0f, 10, 10);
glTranslatef(1.0f,0.5f,0.0f);
glColor4f(0.0f,1.0f,0.0f,0.6f);
glutSolidSphere(1.0f, 10, 10);
gluLookAt(0.0f,0.0f,50.0f,0.0f,0.0f,0.0f,0.0f,1.0f,0.0f);
glutSwapBuffers();
}
Even that could get trimmed slightly, but close enough. Notice no glMaterial call at all; I don't think you need that unless you are using lighting with normals and/or textures. I would recommend you start small like this and build up from there rather than trying something more complicated without having much of a practical, applied understanding of OGL to work with.
I'm also sure that creating transparency is not just as simple as using the alpha values. This is going to take you some time and research...
*at least that's what it looks like to me