Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Creating a sphere using GLUT
Index -> Graphics and Design, Graphics -> 3D Graphics
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
102jon




PostPosted: Thu Dec 16, 2010 7:18 pm   Post subject: Creating a sphere using GLUT

I'm working on a three body problem, but i'm having trouble using the glutSolidSphere function. Can anyone give me sample C++ source code that simply renders a single sphere? It would be greatly appreciated.
Sponsor
Sponsor
Sponsor
sponsor
Ultrahex




PostPosted: Fri Dec 17, 2010 9:44 am   Post subject: Re: Creating a sphere using GLUT

There is many examples of this on the web, and this is relatively simple to do... It sounds to me like this is for an assignment, however here is code
that does something very similar to what you want.

c:
#include <iostream>
#include <cstdlib>
#include <GL/glut.h>
using namespace std;

static int win;
void disp(void);

void keyb(unsigned char key, int x, int y);

int main(int argc, char **argv){
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGBA | GLUT_SINGLE);
    glutInitWindowSize(500,500);
    win = glutCreateWindow("Here is a sphere, for some reason");
    glutDisplayFunc(disp);
    glutKeyboardFunc(keyb);
    glClearColor(0.0,0.0,0.0,0.0);
    glutMainLoop();
    return 0;
}


void disp(void){
    glClear(GL_COLOR_BUFFER_BIT);

    glutWireSphere(0.5,100,100);
}

void keyb(unsigned char key, int x, int y){
    if(key == 'q'){
        glutDestroyWindow(win);
        exit(0);
    }
}
Display posts from previous:   
   Index -> Graphics and Design, Graphics -> 3D Graphics
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: