Cube::Cube(vec3 pos, vec3 s) { numVertices = 36; quadIndex = 0; position = pos; scale = s; points = new point4[numVertices]; normals = new vec3[numVertices]; diffuse = color4(0.2, 0.2, 0.6, 1.0); ambient = color4(1.0, 1.0, 1.0, 1.0); specular = color4(1.0, 1.0, 1.0, 1.0); shininess = 100.0; vertices = new point4[8]; vertices[0] = point4( -0.5, -0.5, 0.5, 1.0 ); vertices[1] = point4( -0.5, 0.5, 0.5, 1.0 ); vertices[2] = point4( 0.5, 0.5, 0.5, 1.0 ); vertices[3] = point4( 0.5, -0.5, 0.5, 1.0 ); vertices[4] = point4( -0.5, -0.5, -0.5, 1.0 ); vertices[5] = point4( -0.5, 0.5, -0.5, 1.0 ); vertices[6] = point4( 0.5, 0.5, -0.5, 1.0 ); vertices[7] = point4( 0.5, -0.5, -0.5, 1.0 ); vertex_colors = new point4[8]; vertex_colors[0] = color4( 0.0, 0.0, 0.0, 1.0 ); vertex_colors[1] = color4( 1.0, 0.0, 0.0, 1.0 ); vertex_colors[2] = color4( 1.0, 1.0, 0.0, 1.0 ); vertex_colors[3] = color4( 0.0, 1.0, 0.0 , 1.0 ); vertex_colors[4] = color4( 0.0, 0.0, 1.0, 1.0 ); vertex_colors[5] = color4( 1.0, 0.0, 1.0, 1.0 ); vertex_colors[6] = color4( 1.0, 1.0, 1.0, 1.0 ); vertex_colors[7] = color4( 0.0, 1.0, 1.0, 1.0 ); colorcube(); setUpShader(); }
void initGL(void) { printf("Vendor: %s\n", glGetString(GL_VENDOR)); printf("Renderer: %s\n", glGetString(GL_RENDERER)); printf("Version: %s\n", glGetString(GL_VERSION)); printf("--------------------------------------------------\n"); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glGenTextures(1, &waterTex); glBindTexture(GL_TEXTURE_2D, waterTex); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, RENDER_SAMPLE, RENDER_SAMPLE, 0, GL_RGBA, GL_FLOAT, 0); // glGenTextures(1, &iceTex); glBindTexture(GL_TEXTURE_2D, iceTex); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, RENDER_SAMPLE, RENDER_SAMPLE, 0, GL_RGBA, GL_FLOAT, 0); screenData = new unsigned long[windowWidth * windowHeight]; frameNum = 0; glewInit(); if (!glewIsSupported("GL_VERSION_2_0 GL_VERSION_1_5 GL_ARB_multitexture GL_ARB_vertex_buffer_object")) { fprintf(stderr, "Required OpenGL extensions missing."); exit(-1); } setUpShader(); }