// This function does any needed initialization on the rendering context. static void SetupRC(void) { // Background glClearColor(0.2f, 0.2f, 0.3f, 1.0f ); glEnable(GL_DEPTH_TEST); shaderManager.InitializeStockShaders(); viewFrame.MoveForward(4.0f); // Make the torus gltMakeTorus(torusBatch, .70f, 0.30f, 32, 16); cullingShader = gltLoadShaderTripletWithAttributes("../../Data/Shaders/Chapter11/GSCulling.vs", "../../Data/Shaders/Chapter11/GSCulling.gs", "../../Data/Shaders/Chapter11/GSCulling.fs", 2, GLT_ATTRIBUTE_VERTEX, "vVertex", GLT_ATTRIBUTE_NORMAL, "vNormal"); locMVP = glGetUniformLocation(cullingShader, "mvpMatrix"); locMV = glGetUniformLocation(cullingShader, "mvMatrix"); locNM = glGetUniformLocation(cullingShader, "normalMatrix"); locViewpoint = glGetUniformLocation(cullingShader, "viewpoint"); }
// This function does any needed initialization on the rendering context. void SetupRC(void) { // Background glClearColor(0.2f, 0.2f, 0.3f, 1.0f ); glEnable(GL_DEPTH_TEST); shaderManager.InitializeStockShaders(); viewFrame.MoveForward(4.0f); // Make the torus gltMakeTorus(torusBatch, .70f, 0.10f, 11, 7); explodeProgram = gltLoadShaderTripletWithAttributes("../../Data/Shaders/Chapter11/GSExplode.vs", "../../Data/Shaders/Chapter11/GSExplode.gs", "../../Data/Shaders/Chapter11/GSExplode.fs", 2, GLT_ATTRIBUTE_VERTEX, "vVertex", GLT_ATTRIBUTE_NORMAL, "vNormal"); locMVP = glGetUniformLocation(explodeProgram, "mvpMatrix"); locMV = glGetUniformLocation(explodeProgram, "mvMatrix"); locNM = glGetUniformLocation(explodeProgram, "normalMatrix"); locPushOut = glGetUniformLocation(explodeProgram, "push_out"); }
// This function does any needed initialization on the rendering // context. void SetupRC(void) { // Background glClearColor(0.2f, 0.2f, 0.3f, 1.0f ); glEnable(GL_DEPTH_TEST); shaderManager.InitializeStockShaders(); viewFrame.MoveForward(4.0f); // Make the torus gltMakeTorus(torusBatch, .70f, 0.10f, 11, 7); gltMakeCube(cubeBatch, 1.0f); toonShader = gltLoadShaderTripletWithAttributes("GSTessellate.vs", "GSTessellate.gs", "GSTessellate.fs", 2, GLT_ATTRIBUTE_VERTEX, "vVertex", GLT_ATTRIBUTE_NORMAL, "vNormal"); locMVP = glGetUniformLocation(toonShader, "mvpMatrix"); locMV = glGetUniformLocation(toonShader, "mvMatrix"); locNM = glGetUniformLocation(toonShader, "normalMatrix"); static const GLfloat vertices[] = { -1.0f, -1.0f, -1.0f, // A -1.0f, -1.0f, 1.0f, // B -1.0f, 1.0f, -1.0f, // C -1.0f, 1.0f, 1.0f, // D 1.0f, -1.0f, -1.0f, // E 1.0f, -1.0f, 1.0f, // F 1.0f, 1.0f, -1.0f, // G 1.0f, 1.0f, 1.0f // H }; static const GLshort indices[] = { 0, 1, 2, 3, 2, 1, 1, 5, 3, 7, 3, 5, 5, 4, 7, 6, 7, 4, 4, 0, 6, 2, 6, 0, 4, 5, 0, 1, 0, 5, 3, 7, 2, 6, 2, 7 }; glGenVertexArrays(1, &vao); glBindVertexArray(vao); glGenBuffers(1, &vertex_buffer); glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer); glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, NULL); glEnableVertexAttribArray(0); glGenBuffers(1, &element_buffer); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, element_buffer); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW); GLenum e = glGetError(); }