sphere::sphere(GLuint numlats, GLuint numlongs, GLfloat ambient, GLfloat shininess) { this->numlats = numlats; // Number of latitudes in our sphere this->numlongs = numlongs; // Number of longitudes in our sphere this->light = new lighting(shininess, ambient); this->transform = new transformation(); makeSphereVBO(); }
/* This function is called before entering the main rendering loop. Use it for all your initialisation stuff */ void init(GLWrapper *glw) { /* Set the object transformation controls to their initial values */ x = 0.05f; y = 0; z = 0; angle_x = angle_z = 0; angle_y = 1; angle_inc_x = angle_inc_y = angle_inc_z = 0; scale = 1.f; aspect_ratio = 1024.f / 768.f; // Initial aspect ratio from window size (variables would be better!) colourmode = 0; numLats = 16; // Number of latitudes in our sphere numLongs = 16; // Number of longitudes in our sphere // Define lighting lightSource.position = glm::vec3(0, 0, 0); lightSource.colour = glm::vec3(1, 1, 1); //white light // Generate index (name) for one vertex array object glGenVertexArrays(1, &vao); // Create the vertex array object and make it current glBindVertexArray(vao); /* create the sphere object */ numSphereVertices = makeSphereVBO(numLats, numLongs); /* Load and build the vertex and fragment shaders */ try { program = glw->LoadShader("lab3start.vert", "lab3start.frag"); } catch (std::exception &e) { std::cout << "Caught exception: " << e.what() << std::endl; std::cin.ignore(); exit(0); } /* Define uniforms to send to vertex shader */ modelID = glGetUniformLocation(program, "model"); colourmodeID = glGetUniformLocation(program, "colourmode"); viewID = glGetUniformLocation(program, "view"); projectionID = glGetUniformLocation(program, "projection"); }