void init(void) { glClearColor(0.0, 0.0, 0.0, 1.0); // Yeah.. so.. we need an global array with all the avaliable textures to be used with keystrokes for texture selection... std::string texture_array[] = {"0.125", "0.5", "2", "8", "32", "128", "512", "2048"}; globals.textures = std::vector<std::string>(texture_array,end(texture_array)); globals.cubemap_0 = loadCubeMap(cubemapDir() + "RomeChurch/prefiltered/"+globals.textures[0]); globals.cubemap_1 = loadCubeMap(cubemapDir() + "RomeChurch/prefiltered/"+globals.textures[1]); globals.cubemap_2 = loadCubeMap(cubemapDir() + "RomeChurch/prefiltered/"+globals.textures[2]); globals.cubemap_3 = loadCubeMap(cubemapDir() + "RomeChurch/prefiltered/"+globals.textures[3]); globals.cubemap_4 = loadCubeMap(cubemapDir() + "RomeChurch/prefiltered/"+globals.textures[4]); globals.cubemap_5 = loadCubeMap(cubemapDir() + "RomeChurch/prefiltered/"+globals.textures[5]); globals.cubemap_6 = loadCubeMap(cubemapDir() + "RomeChurch/prefiltered/"+globals.textures[6]); globals.cubemap_7 = loadCubeMap(cubemapDir() + "RomeChurch/prefiltered/"+globals.textures[7]); globals.cubemap_sky_box = loadCubeMap(cubemapDir() + "RomeChurch"); std::string dir = shaderDir(); loadProgram(shaderDir() + "environment_mapping.vert", shaderDir() + "environment_mapping.frag", &globals.program); loadProgram(shaderDir() + "skybox.vert", shaderDir() + "skybox.frag", &globals.program_sky_box); loadMesh((modelDir() + "gargo.obj"), &globals.mesh); createMeshVAO(globals.mesh, &globals.meshVAO); createBoxVAO(); initializeTrackball(); }
//-------------------------------------------------------------- // constructor Planet::Planet( const mgOptionsFile& options) { // load the planet cubemap texture mgString xminName, xmaxName, yminName, ymaxName, zminName, zmaxName; options.getFileName("planet-xmin", options.m_sourceFileName, "", xminName); options.getFileName("planet-xmax", options.m_sourceFileName, "", xmaxName); options.getFileName("planet-ymin", options.m_sourceFileName, "", yminName); options.getFileName("planet-ymax", options.m_sourceFileName, "", ymaxName); options.getFileName("planet-zmin", options.m_sourceFileName, "", zminName); options.getFileName("planet-zmax", options.m_sourceFileName, "", zmaxName); m_surfaceTexture = loadCubeMap(xminName, xmaxName, yminName, ymaxName, zminName, zmaxName); // load the clouds cubemap texture options.getFileName("clouds-xmin", options.m_sourceFileName, "", xminName); options.getFileName("clouds-xmax", options.m_sourceFileName, "", xmaxName); options.getFileName("clouds-ymin", options.m_sourceFileName, "", yminName); options.getFileName("clouds-ymax", options.m_sourceFileName, "", ymaxName); options.getFileName("clouds-zmin", options.m_sourceFileName, "", zminName); options.getFileName("clouds-zmax", options.m_sourceFileName, "", zmaxName); m_cloudsTexture = loadCubeMap(xminName, xmaxName, yminName, ymaxName, zminName, zmaxName); compileShader(options); // create the vertex buffer glGenVertexArrays(1, &m_vertexArray); glBindVertexArray(m_vertexArray); glGenBuffers(1, &m_vertexBuffer); glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer); glEnableVertexAttribArray(0); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(VertexPlanet), (const GLvoid*) offsetof(VertexPlanet, m_px)); glEnableVertexAttribArray(1); glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(VertexPlanet), (const GLvoid*) offsetof(VertexPlanet, m_mx)); m_eyePt = mgPoint3(3500, 0, 0); m_eyeRotX = 0.0; m_eyeRotY = 90.0; m_eyeMatrix.rotateYDeg(m_eyeRotY); m_eyeMatrix.rotateXDeg(m_eyeRotX); m_specularColor = mgPoint3(0.4, 0.4, 0.4); m_lightColor = mgPoint3(0.6, 0.6, 0.6); m_lightAmbient = mgPoint3(0.2, 0.2, 0.2); m_matColor = mgPoint4(1, 1, 1, 1); }
//-------------------------------------------------------------- // constructor Planet::Planet( const mgOptionsFile& options) { // load the planet cubemap texture mgString xminName, xmaxName, yminName, ymaxName, zminName, zmaxName; options.getFileName("planet-xmin", options.m_sourceFileName, "", xminName); options.getFileName("planet-xmax", options.m_sourceFileName, "", xmaxName); options.getFileName("planet-ymin", options.m_sourceFileName, "", yminName); options.getFileName("planet-ymax", options.m_sourceFileName, "", ymaxName); options.getFileName("planet-zmin", options.m_sourceFileName, "", zminName); options.getFileName("planet-zmax", options.m_sourceFileName, "", zmaxName); m_surfaceTexture = loadCubeMap(xminName, xmaxName, yminName, ymaxName, zminName, zmaxName); // load the clouds cubemap texture options.getFileName("clouds-xmin", options.m_sourceFileName, "", xminName); options.getFileName("clouds-xmax", options.m_sourceFileName, "", xmaxName); options.getFileName("clouds-ymin", options.m_sourceFileName, "", yminName); options.getFileName("clouds-ymax", options.m_sourceFileName, "", ymaxName); options.getFileName("clouds-zmin", options.m_sourceFileName, "", zminName); options.getFileName("clouds-zmax", options.m_sourceFileName, "", zmaxName); m_cloudsTexture = loadCubeMap(xminName, xmaxName, yminName, ymaxName, zminName, zmaxName); compileShader(options); // create the vertex buffer glGenBuffers(1, &m_vertexBuffer); glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer); m_eyePt = mgPoint3(3500, 0, 0); m_eyeRotX = 0.0; m_eyeRotY = 90.0; m_eyeMatrix.rotateYDeg(m_eyeRotY); m_eyeMatrix.rotateXDeg(m_eyeRotX); m_specularColor = mgPoint3(0.4, 0.4, 0.4); m_lightColor = mgPoint3(0.6, 0.6, 0.6); m_lightAmbient = mgPoint3(0.2, 0.2, 0.2); m_matColor = mgPoint4(1, 1, 1, 1); }
std::shared_ptr< Texture > MaterialFactory::createCubeMap( tinyxml2::XMLElement* node ) { std::shared_ptr< Texture > myTexture = std::shared_ptr< Texture > ( new CubeMap() ); GLuint textureId; loadCubeMap( node->Attribute( "front" ) , node->Attribute( "back" ) , node->Attribute( "top" ) , node->Attribute( "bottom" ) , node->Attribute( "left" ) , node->Attribute( "right" ) , &textureId ); myTexture->setTexture( node->Attribute( "name" ) , textureId , m_textureLocation ); printf( " Loaded cubeMap - \n "); printf( " name: %s \n" , node->Attribute( "name" ) ); printf( " textureId: %i \n" , textureId ); printf( " textureLocation: %i \n", m_textureLocation ); m_textureLocation++; return myTexture; }
void View::InitResources() { createShaderPrograms(); m_skybox = ResourceLoader::loadSkybox(); //m_comet = ResourceLoader::loadObjModel("../final/model/planet.OBJ"); //m_comet = ResourceLoader::loadObjModel("/course/cs123/bin/models/xyzrgb_dragon.obj"); loadCubeMap(); m_texID_sun = loadTexture(":/textures/sun.png"); m_texID_earth = loadTexture(":/textures/earthmap1k.jpg"); m_texID_earth_normal = loadTexture(":/textures/earthbump1k_enhance.png"); m_texID_earth_cloud = loadTexture(":/textures/earthcloudmap.jpg"); m_texID_moon = loadTexture(":/textures/moonmap2k.jpg"); m_texID_moon_normal = loadTexture(":/textures/moonmap2k_enhance2.jpg"); m_texID_comet = loadTexture(":/textures/mercurymap.jpg"); m_texID_comet_normal = loadTexture(":/textures/mercurybump_normal.jpg"); m_texID_saturn = loadTexture(":/textures/saturnmap.jpg"); m_texID_andy = loadTexture(":/textures/Andy.jpg"); }
void CG_initialize(void) { cgVertexProfile = cgGLGetLatestProfile(CG_GL_VERTEX); cgFragmentProfile = cgGLGetLatestProfile(CG_GL_FRAGMENT); cgGLSetOptimalOptions(cgVertexProfile); cgGLSetOptimalOptions(cgFragmentProfile); cgContext = cgCreateContext(); cgVertexProgram = cgCreateProgramFromFile(cgContext, CG_SOURCE, "CG_ENVIRO_MAPPING/oglu_per_vertex_reflective_environment_mapping_vs.cg", cgVertexProfile, NULL, NULL); cgGLLoadProgram(cgVertexProgram); enviroCgVertexParam_lightPosition = cgGetNamedParameter(cgVertexProgram, "lightPosition"); enviroCgVertexParam_globalAmbient = cgGetNamedParameter(cgVertexProgram, "globalAmbient"); enviroCgVertexParam_lightColor = cgGetNamedParameter(cgVertexProgram, "lightColor"); //enviroCgVertexParam_Ke = cgGetNamedParameter(cgVertexProgram, "Ke"); enviroCgVertexParam_Ka = cgGetNamedParameter(cgVertexProgram, "Ka"); enviroCgVertexParam_Kd = cgGetNamedParameter(cgVertexProgram, "Kd"); enviroCgVertexParam_Ks = cgGetNamedParameter(cgVertexProgram, "Ks"); enviroCgVertexParam_shininess = cgGetNamedParameter(cgVertexProgram, "shininess"); enviroCgVertexParam_time = cgGetNamedParameter(cgVertexProgram, "time"); cgModelViewProj = cgGetNamedParameter(cgVertexProgram, "ModelViewProj"); cgModelView = cgGetNamedParameter(cgVertexProgram, "ModelView"); cgModelViewI = cgGetNamedParameter(cgVertexProgram, "ModelViewI"); cgModelViewIT = cgGetNamedParameter(cgVertexProgram, "ModelViewIT"); cgPosition = cgGetNamedParameter(cgVertexProgram, "position"); cgNormal = cgGetNamedParameter(cgVertexProgram, "N"); cgTexcoords = cgGetNamedParameter(cgVertexProgram, "texCoord"); cgEyePosition = cgGetNamedParameter(cgVertexProgram, "eyePosition"); cgGLSetParameter3f(cgEyePosition, 0, 0, 0); cgFragmentProgram = cgCreateProgramFromFile(cgContext, CG_SOURCE, "CG_ENVIRO_MAPPING/oglu_per_vertex_reflective_environment_mapping_ps.cg", cgFragmentProfile, NULL, NULL ); cgGLLoadProgram(cgFragmentProgram); cgEnvironmentMap = cgGetNamedParameter(cgFragmentProgram, "environmentMap"); loadCubeMap(); cgGLSetTextureParameter(cgEnvironmentMap, cubemapTexture[0]); }