本文整理汇总了C++中GLTexture::loadAndCreateTexture方法的典型用法代码示例。如果您正苦于以下问题:C++ GLTexture::loadAndCreateTexture方法的具体用法?C++ GLTexture::loadAndCreateTexture怎么用?C++ GLTexture::loadAndCreateTexture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GLTexture
的用法示例。
在下文中一共展示了GLTexture::loadAndCreateTexture方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, const char * argv[])
{
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//// Init glfw, create a window, and init glew
// Init the GLFW Window
window = initWindow();
// Init the glew api
initGlew();
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//// Create some models
// coordinate system
CoordSystem* cs = new CoordSystem(40.0);
// create an apperance object.
GLAppearance* apperance_0 = new GLAppearance("../../data/shaders/spherical_mapping.vs", "../../data/shaders/spherical_mapping.fs");
GLDirectLightSource light_source;
light_source._lightPos = glm::vec4(00.0,20.0,20.0, 0.0);
light_source._ambient_intensity = 0.2;
light_source._specular_intensity = 1.2;
light_source._diffuse_intensity = 5.0;
light_source._attenuation_coeff = 0.0;
// add the light to this apperance object
apperance_0->addLightSource(light_source);
GLSpotLightSource spotlight_source;
spotlight_source._lightPos = glm::vec4(0.0,00.0,50.0, 1.0);
spotlight_source._ambient_intensity = 0.0;
spotlight_source._specular_intensity = 1.8;
spotlight_source._diffuse_intensity = 2.0;
spotlight_source._attenuation_coeff = 0.0002;
spotlight_source._cone_direction = glm::vec3(0.0, 0.0,-1.0);
spotlight_source._cone_angle = 10.0;
apperance_0->addLightSource(spotlight_source);
// Create a material object
GLMaterial material_0;
material_0._diffuse_material = glm::vec3(0.6, 0.0, 0.0);
material_0._ambient_material = glm::vec3(0.6, 0.0, 0.0);
material_0._specular_material = glm::vec3(1.0, 1.0, 1.0);
material_0._shininess = 2.0;
material_0._transparency = 1.0;
// Add the material to the apperance object
apperance_0->setMaterial(material_0);
//************************************************************************************************
// Add a texture
GLTexture* texture = new GLTexture();
texture->loadAndCreateTexture("../../data/textures/reflactance_map1.bmp");
apperance_0->setTexture(texture);
//************************************************************************************************
// Finalize the appearance object
apperance_0->finalize();
// create the sphere geometry
GLSphere3D* sphere_0 = new GLSphere3D(0.0,0.0,0.0, 10.0, 50, 50);
sphere_0->setApperance(*apperance_0);
sphere_0->init();
// If you want to change appearance parameters after you init the object, call the update function
apperance_0->updateLightSources();
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//// Main render loop
// Set up our green background color
static const GLfloat clear_color[] = { 0.0f, 0.0f, 0.0f, 1.0f };
static const GLfloat clear_depth[] = { 1.0f, 1.0f, 1.0f, 1.0f };
// This sets the camera to a new location
// the first parameter is the eye position, the second the center location, and the third the up vector.
SetViewAsLookAt(glm::vec3(12.0f, 12.0f, 65.5f), glm::vec3(1.0f, 0.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f));
SetCameraManipulator(CAMERA_MANIPULATOR);
// Enable depth test
// ignore this line, it allows us to keep the distance value after we proejct each object to a 2d canvas.
glEnable(GL_DEPTH_TEST);
//.........这里部分代码省略.........