本文整理汇总了C++中effect类的典型用法代码示例。如果您正苦于以下问题:C++ effect类的具体用法?C++ effect怎么用?C++ effect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了effect类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: operator
bool operator() (effect &e) {
return e.get_id() == id;
}
开发者ID:Sirbab,项目名称:Cataclysm-DDA,代码行数:3,代码来源:creature.cpp
示例2: load_content
bool load_content() {
// *********************************
// Create frame buffer - use screen width and height
// Create screen quad
// *********************************
// Create plane mesh
meshes["plane"] = mesh(geometry_builder::create_plane());
// Create scene
meshes["box"] = mesh(geometry_builder::create_box());
meshes["tetra"] = mesh(geometry_builder::create_tetrahedron());
meshes["pyramid"] = mesh(geometry_builder::create_pyramid());
meshes["disk"] = mesh(geometry_builder::create_disk(20));
meshes["cylinder"] = mesh(geometry_builder::create_cylinder(20, 20));
meshes["sphere"] = mesh(geometry_builder::create_sphere(20, 20));
meshes["torus"] = mesh(geometry_builder::create_torus(20, 20, 1.0f, 5.0f));
// Transform objects
meshes["box"].get_transform().scale = vec3(5.0f, 5.0f, 5.0f);
meshes["box"].get_transform().translate(vec3(-10.0f, 2.5f, -30.0f));
meshes["tetra"].get_transform().scale = vec3(4.0f, 4.0f, 4.0f);
meshes["tetra"].get_transform().translate(vec3(-30.0f, 10.0f, -10.0f));
meshes["pyramid"].get_transform().scale = vec3(5.0f, 5.0f, 5.0f);
meshes["pyramid"].get_transform().translate(vec3(-10.0f, 7.5f, -30.0f));
meshes["disk"].get_transform().scale = vec3(3.0f, 1.0f, 3.0f);
meshes["disk"].get_transform().translate(vec3(-10.0f, 11.5f, -30.0f));
meshes["disk"].get_transform().rotate(vec3(half_pi<float>(), 0.0f, 0.0f));
meshes["cylinder"].get_transform().scale = vec3(5.0f, 5.0f, 5.0f);
meshes["cylinder"].get_transform().translate(vec3(-25.0f, 2.5f, -25.0f));
meshes["sphere"].get_transform().scale = vec3(2.5f, 2.5f, 2.5f);
meshes["sphere"].get_transform().translate(vec3(-25.0f, 10.0f, -25.0f));
meshes["torus"].get_transform().translate(vec3(-25.0f, 10.0f, -25.0f));
meshes["torus"].get_transform().rotate(vec3(half_pi<float>(), 0.0f, 0.0f));
// Set materials
// Red box
meshes["box"].get_material().set_emissive(vec4(0.0f, 0.0f, 0.0f, 1.0f));
meshes["box"].get_material().set_diffuse(vec4(1.0f, 0.0f, 0.0f, 1.0f));
meshes["box"].get_material().set_specular(vec4(1.0f, 1.0f, 1.0f, 1.0f));
meshes["box"].get_material().set_shininess(25.0f);
// Green tetra
meshes["tetra"].get_material().set_emissive(vec4(0.0f, 0.0f, 0.0f, 1.0f));
meshes["tetra"].get_material().set_diffuse(vec4(0.0f, 1.0f, 0.0f, 1.0f));
meshes["tetra"].get_material().set_specular(vec4(1.0f, 1.0f, 1.0f, 1.0f));
meshes["tetra"].get_material().set_shininess(25.0f);
// Blue pyramid
meshes["pyramid"].get_material().set_emissive(vec4(0.0f, 0.0f, 0.0f, 1.0f));
meshes["pyramid"].get_material().set_diffuse(vec4(0.0f, 0.0f, 1.0f, 1.0f));
meshes["pyramid"].get_material().set_specular(vec4(1.0f, 1.0f, 1.0f, 1.0f));
meshes["pyramid"].get_material().set_shininess(25.0f);
// Yellow disk
meshes["disk"].get_material().set_emissive(vec4(0.0f, 0.0f, 0.0f, 1.0f));
meshes["disk"].get_material().set_diffuse(vec4(1.0f, 1.0f, 0.0f, 1.0f));
meshes["disk"].get_material().set_specular(vec4(1.0f, 1.0f, 1.0f, 1.0f));
meshes["disk"].get_material().set_shininess(25.0f);
// Magenta cylinder
meshes["cylinder"].get_material().set_emissive(vec4(0.0f, 0.0f, 0.0f, 1.0f));
meshes["cylinder"].get_material().set_diffuse(vec4(1.0f, 0.0f, 1.0f, 1.0f));
meshes["cylinder"].get_material().set_specular(vec4(1.0f, 1.0f, 1.0f, 1.0f));
meshes["cylinder"].get_material().set_shininess(25.0f);
// Cyan sphere
meshes["sphere"].get_material().set_emissive(vec4(0.0f, 0.0f, 0.0f, 1.0f));
meshes["sphere"].get_material().set_diffuse(vec4(0.0f, 1.0f, 1.0f, 1.0f));
meshes["sphere"].get_material().set_specular(vec4(1.0f, 1.0f, 1.0f, 1.0f));
meshes["sphere"].get_material().set_shininess(25.0f);
// White torus
meshes["torus"].get_material().set_emissive(vec4(0.0f, 0.0f, 0.0f, 1.0f));
meshes["torus"].get_material().set_diffuse(vec4(1.0f, 1.0f, 1.0f, 1.0f));
meshes["torus"].get_material().set_specular(vec4(1.0f, 1.0f, 1.0f, 1.0f));
meshes["torus"].get_material().set_shininess(25.0f);
// Load texture
tex = texture("textures/checked.gif");
// Set lighting values
light.set_ambient_intensity(vec4(0.3f, 0.3f, 0.3f, 1.0f));
light.set_light_colour(vec4(1.0f, 1.0f, 1.0f, 1.0f));
light.set_direction(vec3(1.0f, 1.0f, -1.0f));
// Load in shaders
eff.add_shader("48_Phong_Shading/phong.vert", GL_VERTEX_SHADER);
eff.add_shader("48_Phong_Shading/phong.frag", GL_FRAGMENT_SHADER);
tex_eff.add_shader("27_Texturing_Shader/simple_texture.vert", GL_VERTEX_SHADER);
tex_eff.add_shader("72_Blur/blur.frag", GL_FRAGMENT_SHADER);
// Build effects
eff.build();
tex_eff.build();
// Set camera properties
cam.set_position(vec3(50.0f, 10.0f, 50.0f));
cam.set_target(vec3(0.0f, 0.0f, 0.0f));
auto aspect = static_cast<float>(renderer::get_screen_width()) / static_cast<float>(renderer::get_screen_height());
//.........这里部分代码省略.........
开发者ID:40167459,项目名称:set08116,代码行数:101,代码来源:72_Blur.cpp
示例3: load_content
bool load_content() {
// Create cube data - eight corners
// Positions
vector<vec3> positions{
// *********************************
// Add the position data for cube corners here (8 total)
vec3(1.0f, -1.0f, 0.0f),
vec3(1.0f, 1.0f, 0.0f),
vec3(-1.0f, 1.0f, 0.0f),
vec3(-1.0f, -1.0f, 0.0f),
vec3(1.0f, -1.0f, -2.0f),
vec3(1.0f, 1.0f, -2.0f),
vec3(-1.0f, 1.0f, -2.0f),
vec3(-1.0f, -1.0f, -2.0f),
// *********************************
};
// Colours
vector<vec4> colours;
for (auto i = 0; i < positions.size(); ++i) {
colours.push_back(vec4((i + 1) % 2, 0.0f, i % 2, 1.0f));
}
// Create the index buffer
vector<GLuint> indices{
// *********************************
// Add index information here - 3 per triangle, 6 per face, 12 triangles
// Front
0,1,2,
0,2,3,
// Back
7,6,5,
7,5,4,
// Right
4,5,1,
4,1,0,
// Left
3,2,6,
3,6,7,
// Top
1,5,6,
1,6,2,
// Bottom
4,0,3,
4,3,7
// *********************************
};
// Add to the geometry
geom.add_buffer(positions, BUFFER_INDEXES::POSITION_BUFFER);
geom.add_buffer(colours, BUFFER_INDEXES::COLOUR_BUFFER);
// ****************************
// Add index buffer to geometry
// ****************************
geom.add_index_buffer(indices);
// Load in shaders
eff.add_shader("shaders/basic.vert", GL_VERTEX_SHADER);
eff.add_shader("shaders/basic.frag", GL_FRAGMENT_SHADER);
// Build effect
eff.build();
// Set camera properties
cam.set_position(vec3(10.0f, 10.0f, 10.0f));
cam.set_target(vec3(0.0f, 0.0f, 0.0f));
auto aspect = static_cast<float>(renderer::get_screen_width()) / static_cast<float>(renderer::get_screen_height());
cam.set_projection(quarter_pi<float>(), aspect, 2.414f, 1000.0f);
return true;
}
开发者ID:Eloh666,项目名称:Computer-Graphics,代码行数:70,代码来源:21_Indexed_Cube.cpp
示例4: initialise
void initialise()
{
srand(time(NULL));
glEnable(GL_DEPTH_TEST);
glEnable(GL_VERTEX_ARRAY);
//glClearColor(0.0f, 1.0f, 1.0f, 1.0f);
// Set the accumulation buffer clearing colour to black at 0,0f alpha
glClearAccum(0.0f, 0.0f, 0.0f, 0.0f);
glEnable(GL_POINT_SMOOTH); // Smooth the points so that they're circular and not square
glPointSize(fw->particleSize);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//IntroCamera
introCam = new target_camera();
introCam->setProjection(glm::degrees(glm::quarter_pi<float>()), screenWidth/screenHeight, 0.1f, 10000.0f);
introCam->setTarget(glm::vec3(0.0f, 0.0f, 0.0f));
introCam->setPositon(glm::vec3(-0.0, 0.0, -3.0));
//Fireworkcam=====================================
fireworkCam = new first_person_camera();
fireworkCam->setProjection(glm::pi<float>() / 4.0f, screenWidth/screenHeight, 0.1f, 10000.0f);
fireworkCam->setPositon(glm::vec3(1.73964, 4.51647, -23.0497));
fireworkCam->rotate(0.0f, 0.0f);
//=============================================================
//Fireworkcam1===================================================
fireworkCam1 = new first_person_camera();
fireworkCam1->setProjection(glm::pi<float>() / 4.0f, screenWidth/screenHeight, 0.1f, 10000.0f);
fireworkCam1->setPositon(glm::vec3(1.73964, 4.51647, -500.0497));
fireworkCam1->rotate(0.0f, 0.0f);
//==================================================================
//Scene2 camera==============================================================
scene2Cam = new first_person_camera();
scene2Cam->setProjection(glm::pi<float>() / 4.0f, screenWidth/screenHeight, 0.1f, 10000.0f);
scene2Cam->setPositon(glm::vec3(-4.23435, 1.73269, -8.24032));
scene2Cam->rotate(0.65f, 0.0f);
//===============================================================================
//Scene2Cam1===========================================================
//Scene2 camera==============================================================
scene2Cam1 = new first_person_camera();
scene2Cam1->setProjection(glm::pi<float>() / 4.0f, screenWidth/screenHeight, 0.1f, 10000.0f);
scene2Cam1->setPositon(glm::vec3(4.23435, 1.73269, 15.24032));
scene2Cam1->rotate(-2.8f, 0.0f);
//===============================================================================
if (!eff.addShader("lit_textured.vert", GL_VERTEX_SHADER))
exit(EXIT_FAILURE);
if (!eff.addShader("lighting.frag", GL_FRAGMENT_SHADER))
exit(EXIT_FAILURE);
if (!eff.addShader("point_light.frag", GL_FRAGMENT_SHADER))
exit(EXIT_FAILURE);
if (!eff.addShader("spot_light.frag", GL_FRAGMENT_SHADER))
exit(EXIT_FAILURE);
if (!eff.addShader("lit_textured.frag", GL_FRAGMENT_SHADER))
exit(EXIT_FAILURE);
if (!eff.create())
exit(EXIT_FAILURE);
effect* post_eff = new effect();
if(!post_eff->addShader("post_process.vert", GL_VERTEX_SHADER))
exit(EXIT_FAILURE);
if(!post_eff->addShader("Sepia.frag", GL_FRAGMENT_SHADER))
exit(EXIT_FAILURE);
if (!post_eff->create())
exit(EXIT_FAILURE);
effect* post_eff1 = new effect();
if(!post_eff1->addShader("post_process.vert", GL_VERTEX_SHADER))
exit(EXIT_FAILURE);
if(!post_eff1->addShader("Greyscale.frag", GL_FRAGMENT_SHADER))
exit(EXIT_FAILURE);
if (!post_eff1->create())
exit(EXIT_FAILURE);
effect* post_eff2 = new effect();
if(!post_eff2->addShader("post_process.vert", GL_VERTEX_SHADER))
exit(EXIT_FAILURE);
if(!post_eff2->addShader("Negative.frag", GL_FRAGMENT_SHADER))
exit(EXIT_FAILURE);
if (!post_eff2->create())
exit(EXIT_FAILURE);
effect* post_eff3 = new effect();
if(!post_eff3->addShader("post_process.vert", GL_VERTEX_SHADER))
exit(EXIT_FAILURE);
if(!post_eff3->addShader("NightPostProc.frag", GL_FRAGMENT_SHADER))
exit(EXIT_FAILURE);
if (!post_eff3->create())
exit(EXIT_FAILURE);
effect* post_eff4 = new effect();
if(!post_eff4->addShader("post_process.vert", GL_VERTEX_SHADER))
exit(EXIT_FAILURE);
if(!post_eff4->addShader("NoPostProc.frag", GL_FRAGMENT_SHADER))
exit(EXIT_FAILURE);
if (!post_eff4->create())
//.........这里部分代码省略.........
开发者ID:craigmcmillan01,项目名称:Graphics-Programming,代码行数:101,代码来源:main.cpp
示例5: render
bool render() {
// *********************************
// Set render target to frame buffer
// Clear frame
// *********************************
// Render meshes
for (auto &e : meshes) {
auto m = e.second;
// Bind effect
renderer::bind(eff);
// Create MVP matrix
auto M = m.get_transform().get_transform_matrix();
auto V = cam.get_view();
auto P = cam.get_projection();
auto MVP = P * V * M;
// Set MVP matrix uniform
glUniformMatrix4fv(eff.get_uniform_location("MVP"), 1, GL_FALSE, value_ptr(MVP));
// Create MV matrix
auto MV = V * M;
// Set MV matrix uniform
glUniformMatrix4fv(eff.get_uniform_location("MV"), 1, GL_FALSE, value_ptr(MV));
// Set M matrix uniform
glUniformMatrix4fv(eff.get_uniform_location("M"), 1, GL_FALSE, value_ptr(M));
// Set N matrix uniform
glUniformMatrix3fv(eff.get_uniform_location("N"), 1, GL_FALSE, value_ptr(m.get_transform().get_normal_matrix()));
// Bind material
renderer::bind(m.get_material(), "mat");
// Bind light
renderer::bind(light, "light");
// Bind texture
renderer::bind(tex, 0);
// Set tex uniform
glUniform1i(eff.get_uniform_location("tex"), 0);
// Set eye position
glUniform3fv(eff.get_uniform_location("eye_pos"), 1, value_ptr(cam.get_position()));
// Render mesh
renderer::render(m);
}
// *********************************
// Set render target back to the screen
// Bind Tex effect
// MVP is now the identity matrix
// Set MVP matrix uniform
// Bind texture from frame buffer
// Set the tex uniform
// Set inverse width Uniform
// Set inverse height Uniform
// Render the screen quad
// *********************************
return true;
}
开发者ID:40167459,项目名称:set08116,代码行数:66,代码来源:72_Blur.cpp
示例6: render
bool render()
{
// Render meshes
for (auto &e : meshes)
{
auto m = e.second;
if (CHECK_GL_ERROR)
{
__debugbreak();
}
// Bind effect
renderer::bind(eff);
if (CHECK_GL_ERROR)
{
__debugbreak();
}
// Create MVP matrix
auto M = m.get_transform().get_transform_matrix();
auto V = cam.get_view();
auto P = cam.get_projection();
auto MVP = P * V * M;
// Set MVP matrix uniform
glUniformMatrix4fv(
eff.get_uniform_location("MVP"), // Location of uniform
1, // Number of values - 1 mat4
GL_FALSE, // Transpose the matrix?
value_ptr(MVP)); // Pointer to matrix data
// ********************
// Set M matrix uniform
// ********************
glUniformMatrix4fv(eff.get_uniform_location("M"), 1, GL_FALSE, value_ptr(M));
// ***********************
// Set N matrix uniform
// - remember - 3x3 matrix
// ***********************
mat3 N = mat3(M);
N = transpose(N);
glUniformMatrix3fv(eff.get_uniform_location("N"), 1, GL_FALSE, value_ptr(N));
// *************
// Bind material
// *************
material mm = m.get_material();
renderer::bind(mm, "mat");
// **********
// Bind light
// **********
//glUniform4fv(eff.get_uniform_location("light.ambient_intensity"), 1, value_ptr(light.get_ambient_intensity));
renderer::bind(light, "light");
// ************
// Bind texture
// ************
renderer::bind(tex, 0);
// ***************
// Set tex uniform
// ***************
glUniform1i(eff.get_uniform_location("tex"), 0);
// *****************************
// Set eye position
// - Get this from active camera
// *****************************
vec3 eyeP = cam.get_position();
glUniform3f(eff.get_uniform_location("eye_pos"), eyeP.x, eyeP.y, eyeP.z);
// Render mesh
renderer::render(m);
}
return true;
}
开发者ID:Zoeoeh,项目名称:Coursework-ComputerGraphics,代码行数:91,代码来源:main.cpp
示例7: load_content
bool load_content()
{
// Create plane mesh
meshes["plane"] = mesh(geometry_builder::create_plane());
// Create scene
meshes["box"] = mesh(geometry_builder::create_box());
meshes["tetra"] = mesh(geometry_builder::create_tetrahedron());
meshes["pyramid"] = mesh(geometry_builder::create_pyramid());
meshes["disk"] = mesh(geometry_builder::create_disk(20));
meshes["cylinder"] = mesh(geometry_builder::create_cylinder(20, 20));
meshes["sphere"] = mesh(geometry_builder::create_sphere(20, 20));
meshes["torus"] = mesh(geometry_builder::create_torus(20, 20, 1.0f, 5.0f));
// Transform objects
meshes["box"].get_transform().scale = vec3(5.0f, 5.0f, 5.0f);
meshes["box"].get_transform().translate(vec3(-10.0f, 2.5f, -30.0f));
meshes["tetra"].get_transform().scale = vec3(4.0f, 4.0f, 4.0f);
meshes["tetra"].get_transform().translate(vec3(-30.0f, 10.0f, -10.0f));
meshes["pyramid"].get_transform().scale = vec3(5.0f, 5.0f, 5.0f);
meshes["pyramid"].get_transform().translate(vec3(-10.0f, 7.5f, -30.0f));
meshes["disk"].get_transform().scale = vec3(3.0f, 1.0f, 3.0f);
meshes["disk"].get_transform().translate(vec3(-10.0f, 11.5f, -30.0f));
meshes["disk"].get_transform().rotate(vec3(half_pi<float>(), 0.0f, 0.0f));
meshes["cylinder"].get_transform().scale = vec3(5.0f, 5.0f, 5.0f);
meshes["cylinder"].get_transform().translate(vec3(-25.0f, 2.5f, -25.0f));
meshes["sphere"].get_transform().scale = vec3(2.5f, 2.5f, 2.5f);
meshes["sphere"].get_transform().translate(vec3(-25.0f, 10.0f, -25.0f));
meshes["torus"].get_transform().translate(vec3(-25.0f, 10.0f, -25.0f));
meshes["torus"].get_transform().rotate(vec3(half_pi<float>(), 0.0f, 0.0f));
// ***********************
// Set materials
// - all emissive is black
// - all specular is white
// - all shininess is 25
// ***********************
//map<string, material>::iterator it = materials.begin(); it!;
for (auto &m : materials)
{
m.second.set_shininess(50);
m.second.set_specular(vec4(1.0, 1.0, 1.0, 1.0));
m.second.set_emissive(vec4(0.0, 0.0, 0.0, 1.0));
}
// Red box
materials["box"].set_diffuse(vec4(1.0, 0.0, 0.0, 1.0));
meshes["box"].set_material(materials["box"]);
// Green tetra
materials["tetra"].set_diffuse(vec4(0.0, 1.0, 0.0, 1.0));
meshes["tetra"].set_material( materials["tetra"]);
// Blue pyramid
materials["pyramid"].set_diffuse(vec4(0.0, 0.0, 1.0, 1.0));
meshes["pyramid"].set_material(materials["pyramid"]);
// Yellow disk
materials["disk"].set_diffuse(vec4(1.0, 1.0, 0.0, 1.0));
meshes["disk"].set_material(materials["disk"]);
// Magenta cylinder
materials["cylinder"].set_diffuse(vec4(0.0, 1.0, 1.0, 1.0));
meshes["cylinder"].set_material(materials["cylinder"]);
// Cyan sphere
materials["sphere"].set_diffuse(vec4(1.0, 0.0, 1.0, 1.0));
meshes["sphere"].set_material(materials["sphere"]);
// White torus
materials["torus"].set_diffuse(vec4(1.0, 1.0, 1.0, 1.0));
meshes["torus"].set_material(materials["torus"]);
// create light source
meshes["light"] = mesh(geometry_builder::create_sphere(20, 20));
meshes["light"].get_transform().position = vec3(1.0f, 1.0f, -1.0f);
// **************************
// Load texture - checked.gif
// **************************
tex = texture("..\\resources\\textures\\checked.gif");
// *******************
// Set lighting values
// *******************
// ambient intensity (0.3, 0.3, 0.3)
light.set_ambient_intensity(vec4(0.3, 0.3, 0.3, 1.0));
// Light colour white
light.set_light_colour(vec4(1.0f, 1.0f, 1.0f, 1.0f));
//.........这里部分代码省略.........
开发者ID:Zoeoeh,项目名称:Coursework-ComputerGraphics,代码行数:101,代码来源:main.cpp
示例8: load_content
bool load_content() {
// Create plane mesh
meshes["plane"] = mesh(geometry_builder::create_plane());
// Create scene
meshes["box"] = mesh(geometry_builder::create_box());
meshes["tetra"] = mesh(geometry_builder::create_tetrahedron());
meshes["pyramid"] = mesh(geometry_builder::create_pyramid());
meshes["disk"] = mesh(geometry_builder::create_disk(20));
meshes["cylinder"] = mesh(geometry_builder::create_cylinder(20, 20));
meshes["sphere"] = mesh(geometry_builder::create_sphere(20, 20));
meshes["torus"] = mesh(geometry_builder::create_torus(20, 20, 1.0f, 5.0f));
// Transform objects
meshes["box"].get_transform().scale = vec3(5.0f, 5.0f, 5.0f);
meshes["box"].get_transform().translate(vec3(-10.0f, 2.5f, -30.0f));
meshes["tetra"].get_transform().scale = vec3(4.0f, 4.0f, 4.0f);
meshes["tetra"].get_transform().translate(vec3(-30.0f, 10.0f, -10.0f));
meshes["pyramid"].get_transform().scale = vec3(5.0f, 5.0f, 5.0f);
meshes["pyramid"].get_transform().translate(vec3(-10.0f, 7.5f, -30.0f));
meshes["disk"].get_transform().scale = vec3(3.0f, 1.0f, 3.0f);
meshes["disk"].get_transform().translate(vec3(-10.0f, 11.5f, -30.0f));
meshes["disk"].get_transform().rotate(vec3(half_pi<float>(), 0.0f, 0.0f));
meshes["cylinder"].get_transform().scale = vec3(5.0f, 5.0f, 5.0f);
meshes["cylinder"].get_transform().translate(vec3(-25.0f, 2.5f, -25.0f));
meshes["sphere"].get_transform().scale = vec3(2.5f, 2.5f, 2.5f);
meshes["sphere"].get_transform().translate(vec3(-25.0f, 10.0f, -25.0f));
meshes["torus"].get_transform().translate(vec3(-25.0f, 10.0f, -25.0f));
meshes["torus"].get_transform().rotate(vec3(half_pi<float>(), 0.0f, 0.0f));
// *********************************
// Set materials
// - all emissive is black
// - all specular is white
// - all shininess is 25
// Red box
meshes["box"].get_material().set_emissive(vec4(0.0f, 0.0f, 0.0f, 1.0f));
meshes["box"].get_material().set_diffuse(vec4(1.0f, 0.0f, 0.0f, 1.0f));
meshes["box"].get_material().set_specular(vec4(1.0f, 1.0f, 1.0f, 1.0f));
meshes["box"].get_material().set_shininess(25.0f);
// Green tetra
meshes["tetra"].get_material().set_emissive(vec4(1.0f, 1.0f, 0.0f, 1.0f));
meshes["tetra"].get_material().set_diffuse(vec4(0.0f, 1.0f, 0.0f, 1.0f));
meshes["tetra"].get_material().set_specular(vec4(1.0f, 1.0f, 1.0f, 1.0f));
meshes["tetra"].get_material().set_shininess(25.0f);
// Blue pyramid
meshes["pyramid"].get_material().set_emissive(vec4(0.0f, 0.0f, 0.0f, 1.0f));
meshes["pyramid"].get_material().set_diffuse(vec4(0.0f, 0.0f, 1.0f, 1.0f));
meshes["pyramid"].get_material().set_specular(vec4(1.0f, 1.0f, 1.0f, 1.0f));
meshes["pyramid"].get_material().set_shininess(25.0f);
// Yellow disk
meshes["disk"].get_material().set_emissive(vec4(0.0f, 0.0f, 0.0f, 1.0f));
meshes["disk"].get_material().set_diffuse(vec4(1.0f, 1.0f, 0.0f, 1.0f));
meshes["disk"].get_material().set_specular(vec4(1.0f, 1.0f, 1.0f, 1.0f));
meshes["disk"].get_material().set_shininess(25.0f);
// Magenta cylinder
meshes["cylinder"].get_material().set_emissive(vec4(0.0f, 0.0f, 0.0f, 1.0f));
meshes["cylinder"].get_material().set_diffuse(vec4(1.0f, 0.0f, 1.0f, 1.0f));
meshes["cylinder"].get_material().set_specular(vec4(1.0f, 1.0f, 1.0f, 1.0f));
meshes["cylinder"].get_material().set_shininess(25.0f);
// Cyan sphere
meshes["sphere"].get_material().set_emissive(vec4(0.0f, 0.0f, 0.0f, 1.0f));
meshes["sphere"].get_material().set_diffuse(vec4(0.0f, 1.0f, 1.0f, 1.0f));
meshes["sphere"].get_material().set_specular(vec4(1.0f, 1.0f, 1.0f, 1.0f));
meshes["sphere"].get_material().set_shininess(25.0f);
// White torus
meshes["torus"].get_material().set_emissive(vec4(0.0f, 0.0f, 0.0f, 1.0f));
meshes["torus"].get_material().set_diffuse(vec4(1.0f, 1.0f, 1.0f, 1.0f));
meshes["torus"].get_material().set_specular(vec4(1.0f, 1.0f, 1.0f, 1.0f));
meshes["torus"].get_material().set_shininess(25.0f);
// *********************************
// Load texture
tex = texture("textures/checker.png");
// *********************************
// Set lighting values, Position (-25, 10, -10)
light.set_position(vec3(-25, 10, -10));
// Light colour white
light.set_light_colour(vec4(1.0f, 1.0f, 1.0f, 1.0f));
// Set range to 20
light.set_range(20);
// Load in shaders
eff.add_shader("49_Point_Light/point.vert", GL_VERTEX_SHADER);
eff.add_shader("49_Point_Light/point.frag", GL_FRAGMENT_SHADER);
// Build effect
eff.build();
// *********************************
// Set camera properties
cam.set_position(vec3(50.0f, 10.0f, 50.0f));
cam.set_target(vec3(0.0f, 0.0f, 0.0f));
cam.set_projection(quarter_pi<float>(), renderer::get_screen_aspect(), 0.1f, 1000.0f);
return true;
}
开发者ID:Damilkybarkid,项目名称:set08116,代码行数:96,代码来源:49_Point_Light.cpp
示例9: load_content
bool load_content() {
// Create plane mesh
meshes["plane"] = mesh(geometry_builder::create_plane());
// Create scene
meshes["box"] = mesh(geometry_builder::create_box());
meshes["tetra"] = mesh(geometry_builder::create_tetrahedron());
meshes["pyramid"] = mesh(geometry_builder::create_pyramid());
meshes["disk"] = mesh(geometry_builder::create_disk(20));
meshes["cylinder"] = mesh(geometry_builder::create_cylinder(20, 20));
meshes["sphere"] = mesh(geometry_builder::create_sphere(20, 20));
meshes["torus"] = mesh(geometry_builder::create_torus(20, 20, 1.0f, 5.0f));
// Transform objects
meshes["box"].get_transform().scale = vec3(5.0f, 5.0f, 5.0f);
meshes["box"].get_transform().translate(vec3(-10.0f, 2.5f, -30.0f));
meshes["tetra"].get_transform().scale = vec3(4.0f, 4.0f, 4.0f);
meshes["tetra"].get_transform().translate(vec3(-30.0f, 10.0f, -10.0f));
meshes["pyramid"].get_transform().scale = vec3(5.0f, 5.0f, 5.0f);
meshes["pyramid"].get_transform().translate(vec3(-10.0f, 7.5f, -30.0f));
meshes["disk"].get_transform().scale = vec3(3.0f, 1.0f, 3.0f);
meshes["disk"].get_transform().translate(vec3(-10.0f, 11.5f, -30.0f));
meshes["disk"].get_transform().rotate(vec3(half_pi<float>(), 0.0f, 0.0f));
meshes["cylinder"].get_transform().scale = vec3(5.0f, 5.0f, 5.0f);
meshes["cylinder"].get_transform().translate(vec3(-25.0f, 2.5f, -25.0f));
meshes["sphere"].get_transform().scale = vec3(2.5f, 2.5f, 2.5f);
meshes["sphere"].get_transform().translate(vec3(-25.0f, 10.0f, -25.0f));
meshes["torus"].get_transform().translate(vec3(-25.0f, 10.0f, -25.0f));
meshes["torus"].get_transform().rotate(vec3(half_pi<float>(), 0.0f, 0.0f));
// *********************************
// Set materials
// - all emissive is black
// - all specular is white
// - all shininess is 25
// Red box
materials["box"].set_emissive(vec4(0.0f, 0.0f, 0.0f, 1.0f));
materials["box"].set_diffuse(vec4(1.0f, 0.0f, 0.0f, 1.0f));
materials["box"].set_specular(vec4(1.0f, 1.0f, 1.0f, 1.0f));
materials["box"].set_shininess(25.0f);
// Green tetra
materials["tetra"].set_emissive(vec4(0.0f, 0.0f, 0.0f, 1.0f));
materials["tetra"].set_diffuse(vec4(0.0f, 1.0f, 0.0f, 1.0f));
materials["tetra"].set_specular(vec4(1.0f, 1.0f, 1.0f, 1.0f));
materials["tetra"].set_shininess(25.0f);
// Blue pyramid
materials["pyramid"].set_emissive(vec4(0.0f, 0.0f, 0.0f, 1.0f));
materials["pyramid"].set_diffuse(vec4(0.0f, 0.0f, 1.0f, 1.0f));
materials["pyramid"].set_specular(vec4(1.0f, 1.0f, 1.0f, 1.0f));
materials["pyramid"].set_shininess(25.0f);
// Yellow disk
materials["disk"].set_emissive(vec4(0.0f, 0.0f, 0.0f, 1.0f));
materials["disk"].set_diffuse(vec4(0.0f, 1.0f, 1.0f, 1.0f));
materials["disk"].set_specular(vec4(1.0f, 1.0f, 1.0f, 1.0f));
materials["disk"].set_shininess(25.0f);
// Magenta cylinder
materials["cylinder"].set_emissive(vec4(0.0f, 0.0f, 0.0f, 1.0f));
materials["cylinder"].set_diffuse(vec4(1.0f, 0.0f, 1.0f, 1.0f));
materials["cylinder"].set_specular(vec4(1.0f, 1.0f, 1.0f, 1.0f));
materials["cylinder"].set_shininess(25.0f);
// Cyan sphere
materials["sphere"].set_emissive(vec4(0.0f, 0.0f, 0.0f, 1.0f));
materials["sphere"].set_diffuse(vec4(0.75f, 1.0f, 1.0f, 1.0f));
materials["sphere"].set_specular(vec4(1.0f, 1.0f, 1.0f, 1.0f));
materials["sphere"].set_shininess(25.0f);
// White torus
materials["torus"].set_emissive(vec4(0.0f, 0.0f, 0.0f, 1.0f));
materials["torus"].set_diffuse(vec4(1.0f, 1.0f, 1.0f, 1.0f));
materials["torus"].set_specular(vec4(1.0f, 1.0f, 1.0f, 1.0f));
materials["torus"].set_shininess(25.0f);
// *********************************
// Load texture
tex = texture("textures/checker2.png");
// Set lighting values
// *********************************
// Point 0, Position (-25, 5, -15)
// Red, 20 range
points[0].set_position(vec3(-25, 5, -15));
points[0].set_light_colour(vec4(1, 0, 0, 1));
//.........这里部分代码省略.........
开发者ID:Eloh666,项目名称:Computer-Graphics,代码行数:101,代码来源:52_Multifile_Shaders.cpp
示例10: render
bool render() {
// Render meshes
for (auto &e : meshes) {
auto m = e.second;
// Bind effect
renderer::bind(eff);
// Create MVP matrix
auto M = m.get_transform().get_transform_matrix();
auto V = cam.get_view();
auto P = cam.get_projection();
auto MVP = P * V * M;
// Set MVP matrix uniform
glUniformMatrix4fv(eff.get_uniform_location("MVP"), // Location of uniform
1, // Number of values - 1 mat4
GL_FALSE, // Transpose the matrix?
value_ptr(MVP)); // Pointer to matrix data
// *********************************
// Set M matrix uniform
glUniformMatrix4fv(eff.get_uniform_location("M"), 1, GL_FALSE, value_ptr(M));
// Set N matrix uniform - remember - 3x3 matrix
auto normal = m.get_transform().get_normal_matrix();
glUniformMatrix3fv(eff.get_uniform_location("N"),
1,
GL_FALSE,
value_ptr(normal));
// Bind material
renderer::bind(materials[e.first], "mat");
renderer::bind(light, "light");
// Bind point lights
renderer::bind(spots, "spots");
// Bind spot lights
renderer::bind(points, "points");
// Bind texture
renderer::bind(tex, 0);
// Set tex uniform
glUniform1i(eff.get_uniform_location("tex"), 0);
// Set eye position - Get this from active camera
glUniform3fv(
eff.get_uniform_location("eye_pos"),
1,
value_ptr(cam.get_position())
);
// Render mesh
renderer::render(m);
// *********************************
// Render mesh
renderer::render(m);
}
return true;
}
开发者ID:Eloh666,项目名称:Computer-Graphics,代码行数:61,代码来源:52_Multifile_Shaders.cpp
示例11: load_content
bool load_content() {
// *********************************
// Create 2 frame buffers - use screen width and height
frames[0] = frame_buffer(renderer::get_screen_width(), renderer::get_screen_height());
frames[1] = frame_buffer(renderer::get_screen_width(), renderer::get_screen_height());
// Create a temp framebuffer
temp_frame = frame_buffer(renderer::get_screen_width(), renderer::get_screen_height());
// Create screen quad
vector<vec3> positions{ vec3(-1.0f, -1.0f, 0.0f), vec3(1.0f, -1.0f, 0.0f), vec3(-1.0f, 1.0f, 0.0f),
vec3(1.0f, 1.0f, 0.0f) };
vector<vec2> tex_coords{ vec2(0.0, 0.0), vec2(1.0f, 0.0f), vec2(0.0f, 1.0f), vec2(1.0f, 1.0f) };
screen_quad.add_buffer(positions, BUFFER_INDEXES::POSITION_BUFFER);
screen_quad.add_buffer(tex_coords, BUFFER_INDEXES::TEXTURE_COORDS_0);
screen_quad.set_type(GL_TRIANGLE_STRIP);
// *********************************
// Create plane mesh
meshes["plane"] = mesh(geometry_builder::create_plane());
// Create scene
meshes["box"] = mesh(geometry_builder::create_box());
meshes["tetra"] = mesh(geometry_builder::create_tetrahedron());
meshes["pyramid"] = mesh(geometry_builder::create_pyramid());
meshes["disk"] = mesh(geometry_builder::create_disk(20));
meshes["cylinder"] = mesh(geometry_builder::create_cylinder(20, 20));
meshes["sphere"] = mesh(geometry_builder::create_sphere(20, 20));
meshes["torus"] = mesh(geometry_builder::create_torus(20, 20, 1.0f, 5.0f));
// Transform objects
meshes["box"].get_transform().scale = vec3(5.0f, 5.0f, 5.0f);
meshes["box"].get_transform().translate(vec3(-10.0f, 2.5f, -30.0f));
meshes["tetra"].get_transform().scale = vec3(4.0f, 4.0f, 4.0f);
meshes["tetra"].get_transform().translate(vec3(-30.0f, 10.0f, -10.0f));
meshes["pyramid"].get_transform().scale = vec3(5.0f, 5.0f, 5.0f);
meshes["pyramid"].get_transform().translate(vec3(-10.0f, 7.5f, -30.0f));
meshes["disk"].get_transform().scale = vec3(3.0f, 1.0f, 3.0f);
meshes["disk"].get_transform().translate(vec3(-10.0f, 11.5f, -30.0f));
meshes["disk"].get_transform().rotate(vec3(half_pi<float>(), 0.0f, 0.0f));
meshes["cylinder"].get_transform().scale = vec3(5.0f, 5.0f, 5.0f);
meshes["cylinder"].get_transform().translate(vec3(-25.0f, 2.5f, -25.0f));
meshes["sphere"].get_transform().scale = vec3(2.5f, 2.5f, 2.5f);
meshes["sphere"].get_transform().translate(vec3(-25.0f, 10.0f, -25.0f));
meshes["torus"].get_transform().translate(vec3(-25.0f, 10.0f, -25.0f));
meshes["torus"].get_transform().rotate(vec3(half_pi<float>(), 0.0f, 0.0f));
// Create mesh to chase
meshes["chaser"] = mesh(geometry_builder::create_box());
meshes["chaser"].get_transform().position = vec3(0.0f, 0.5f, 0.0f);
// Set materials
// Red box
meshes["box"].get_material().set_emissive(vec4(0.0f, 0.0f, 0.0f, 1.0f));
meshes["box"].get_material().set_diffuse(vec4(1.0f, 0.0f, 0.0f, 1.0f));
meshes["box"].get_material().set_specular(vec4(1.0f, 1.0f, 1.0f, 1.0f));
meshes["box"].get_material().set_shininess(25.0f);
// Green tetra
meshes["tetra"].get_material().set_emissive(vec4(0.0f, 0.0f, 0.0f, 1.0f));
meshes["tetra"].get_material().set_diffuse(vec4(0.0f, 1.0f, 0.0f, 1.0f));
meshes["tetra"].get_material().set_specular(vec4(1.0f, 1.0f, 1.0f, 1.0f));
meshes["tetra"].get_material().set_shininess(25.0f);
// Blue pyramid
meshes["pyramid"].get_material().set_emissive(vec4(0.0f, 0.0f, 0.0f, 1.0f));
meshes["pyramid"].get_material().set_diffuse(vec4(0.0f, 0.0f, 1.0f, 1.0f));
meshes["pyramid"].get_material().set_specular(vec4(1.0f, 1.0f, 1.0f, 1.0f));
meshes["pyramid"].get_material().set_shininess(25.0f);
// Yellow disk
meshes["disk"].get_material().set_emissive(vec4(0.0f, 0.0f, 0.0f, 1.0f));
meshes["disk"].get_material().set_diffuse(vec4(1.0f, 1.0f, 0.0f, 1.0f));
meshes["disk"].get_material().set_specular(vec4(1.0f, 1.0f, 1.0f, 1.0f));
meshes["disk"].get_material().set_shininess(25.0f);
// Magenta cylinder
meshes["cylinder"].get_material().set_emissive(vec4(0.0f, 0.0f, 0.0f, 1.0f));
meshes["cylinder"].get_material().set_diffuse(vec4(1.0f, 0.0f, 1.0f, 1.0f));
meshes["cylinder"].get_material().set_specular(vec4(1.0f, 1.0f, 1.0f, 1.0f));
meshes["cylinder"].get_material().set_shininess(25.0f);
// Cyan sphere
meshes["sphere"].get_material().set_emissive(vec4(0.0f, 0.0f, 0.0f, 1.0f));
meshes["sphere"].get_material().set_diffuse(vec4(0.0f, 1.0f, 1.0f, 1.0f));
meshes["sphere"].get_material().set_specular(vec4(1.0f, 1.0f, 1.0f, 1.0f));
meshes["sphere"].get_material().set_shininess(25.0f);
// White torus
meshes["torus"].get_material().set_emissive(vec4(0.0f, 0.0f, 0.0f, 1.0f));
meshes["torus"].get_material().set_diffuse(vec4(1.0f, 1.0f, 1.0f, 1.0f));
meshes["torus"].get_material().set_specular(vec4(1.0f, 1.0f, 1.0f, 1.0f));
meshes["torus"].get_material().set_shininess(25.0f);
// Load texture
tex = texture("textures/checked.gif");
// Set lighting values
light.set_ambient_intensity(vec4(0.3f, 0.3f, 0.3f, 1.0f));
light.set_light_colour(vec4(1.0f, 1.0f, 1.0f, 1.0f));
light.set_direction(vec3(1.0f, 1.0f, -1.0f));
// Load in shaders
eff.add_shader("48_Phong_Shading/phong.vert", GL_VERTEX_SHADER);
eff.add_shader("48_Phong_Shading/phong.frag", GL_FRAGMENT_SHADER);
motion_blur.add_shader("27_Texturing_Shader/simple_texture.vert", GL_VERTEX_SHADER);
motion_blur.add_shader("73_Motion_Blur/motion_blur.frag", GL_FRAGMENT_SHADER);
//.........这里部分代码省略.........
开发者ID:Damilkybarkid,项目名称:set08116,代码行数:101,代码来源:73_Motion_Blur.cpp
示例12: render
bool render() {
// !!!!!!!!!!!!!!! FIRST PASS !!!!!!!!!!!!!!!!
// *********************************
// Set render target to temp frame
renderer::set_render_target(temp_frame);
// Clear frame
renderer::clear();
// *********************************
// Render meshes
for (auto &e : meshes) {
auto m = e.second;
// Bind effect
renderer::bind(eff);
// Create MVP matrix
auto M = m.get_transform().get_transform_matrix();
auto V = cam.get_view();
auto P = cam.get_projection();
auto MVP = P * V * M;
// Set MVP matrix uniform
glUniformMatrix4fv(eff.get_uniform_location("MVP"), 1, GL_FALSE, value_ptr(MVP));
// Create MV matrix
auto MV = V * M;
// Set MV matrix uniform
glUniformMatrix4fv(eff.get_uniform_location("MV"), 1, GL_FALSE, value_ptr(MV));
// Set M matrix uniform
glUniformMatrix4fv(eff.get_uniform_location("M"), 1, GL_FALSE, value_ptr(M));
// Set N matrix uniform
glUniformMatrix3fv(eff.get_uniform_location("N"), 1, GL_FALSE, value_ptr(m.get_transform().get_normal_matrix()));
// Bind material
renderer::bind(m.get_material(), "mat");
// Bind light
renderer::bind(light, "light");
// Bind texture
renderer::bind(tex, 0);
// Set tex uniform
glUniform1i(eff.get_uniform_location("tex"), 0);
// Set eye position
glUniform3fv(eff.get_uniform_location("eye_pos"), 1, value_ptr(cam.get_position()));
// Render mesh
renderer::render(m);
}
// !!!!!!!!!!!!!!! SECOND PASS !!!!!!!!!!!!!!!!
// *********************************
// Set render target to current frame
renderer::set_render_target(frames[(current_frame)]);
// Clear frame
renderer::clear();
// Bind motion blur effect
renderer::bind(motion_blur);
// MVP is now the identity matrix
auto MVP = glm::mat4();
// Set MVP matrix uniform
glUniformMatrix4fv(motion_blur.get_uniform_location("MVP"), 1, GL_FALSE, value_ptr(MVP));
// Bind tempframe to TU 0.
renderer::bind(temp_frame.get_frame(), 0);
// Bind frames[(current_frame + 1) % 2] to TU 1.
renderer::bind(frames[(current_frame + 1) % 2].get_frame(), 1);
// Set tex uniforms
glUniform1i(motion_blur.get_uniform_location("tex"), 0);
glUniform1i(motion_blur.get_uniform_location("previous_frame"), 0);
// Set blend factor (0.9f)
glUniform1i(motion_blur.get_uniform_location("blend_factor"), 0.9f);
// Render screen quad
renderer::render(screen_quad);
// !!!!!!!!!!!!!!! SCREEN PASS !!!!!!!!!!!!!!!!
// Set render target back to the screen
renderer::set_render_target();
renderer::clear();
// Set MVP matrix uniform
glUniformMatrix4fv(tex_eff.get_uniform_location("MVP"), 1, GL_FALSE, value_ptr(MVP));
// Bind texture from frame buffer
renderer::bind(frames[(current_frame)].get_frame(), 0);
// Set the uniform
glUniform1i(tex_eff.get_uniform_location("tex"), 0);
// Render the screen quad
renderer::render(screen_quad);
// *********************************
return true;
}
开发者ID:Damilkybarkid,项目名称:set08116,代码行数:82,代码来源:73_Motion_Blur.cpp
示例13: load_content
bool load_content() {
// *********************************
// Create shadow map- use screen size
// Create plane mesh
// Create "teapot" mesh by loading in models/teapot.obj
// Need to rotate the teapot on x by negative pi/2
// Scale the teapot - (0.1, 0.1, 0.1)
// *********************************
// Load texture
tex = texture("textures/checker.png");
// ***********************
// Set materials
// - all emissive is black
// - all specular is white
// - all shininess is 25
// ***********************
// White plane
meshes["plane"].get_material().set_emissive(vec4(0.0f, 0.0f, 0.0f, 1.0f));
meshes["plane"].get_material().set_diffuse(vec4(1.0f, 1.0f, 1.0f, 1.0f));
meshes["plane"].get_material().set_specular(vec4(1.0f, 1.0f, 1.0f, 1.0f));
meshes["plane"].get_material().set_shininess(25.0f);
// Red teapot
meshes["teapot"].get_material().set_emissive(vec4(0.0f, 0.0f, 0.0f, 1.0f));
meshes["teapot"].get_material().set_diffuse(vec4(1.0f, 1.0f, 1.0f, 1.0f));
meshes["teapot"].get_material().set_specular(vec4(1.0f, 1.0f, 1.0f, 1.0f));
meshes["teapot"].get_material().set_shininess(25.0f);
// *******************
// Set spot properties
// *******************
// Pos (20, 30, 0), White
// Direction (-1, -1, 0) normalized
// 50 range, 10 power
spot.set_position(vec3(30.0f, 20.0f, 0.0f));
spot.set_light_colour(vec4(1.0f, 1.0f, 1.0f, 1.0f));
spot.set_direction(normalize(vec3(-1.0f, -1.0f, 0.0f)));
spot.set_range(500.0f);
spot.set_power(10.0f);
// Load in shaders
main_eff.add_shader("54_Shadowing/shadow.vert", GL_VERTEX_SHADER);
vector<string> frag_shaders{"54_Shadowing/shadow.frag", "shaders/part_spot.frag", "shaders/part_shadow.frag"};
main_eff.add_shader(frag_shaders, GL_FRAGMENT_SHADER);
shadow_eff.add_shader("50_Spot_Light/spot.vert", GL_VERTEX_SHADER);
shadow_eff.add_shader("50_Spot_Light/spot.frag", GL_FRAGMENT_SHADER);
// Build effects
main_eff.build();
shadow_eff.build();
// Set camera properties
cam.set_position(vec3(0.0f, 50.0f, -75.0f));
cam.set_target(vec3(0.0f, 0.0f, 0.0f));
cam.set_projection(quarter_pi<float>(), renderer::get_screen_aspect(), 0.1f, 1000.0f);
return true;
}
开发者ID:DelbyPicnic,项目名称:set08116,代码行数:64,代码来源:54_Shadowing.cpp
示例14: initialise
void initialise()
{
srand(time(NULL));
glEnable(GL_DEPTH_TEST);
glEnable(GL_VERTEX_ARRAY);
//glClearColor(0.0f, 1.0f, 1.0f, 1.0f);
// Set the accumulation buffer clearing colour to black at 0,0f alpha
glClearAccum(0.0f, 0.0f, 0.0f, 0.0f);
glEnable(GL_POINT_SMOOTH); // Smooth the points so that they're circular and not square
glPointSize(fw->particleSize);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//Target Camera
cam1 = new target_camera();
cam1->setProjection(glm::degrees(glm::pi<float>() / 4.0f), screenWidth/screenHeight, 0.1f, 10000.0f);
cam1->setPositon(glm::vec3(10.f, 10.0f, 10.0f));
cam1->setTarget(glm::vec3(0.0f, 0.0f, 0.0f));
//fps cam
cam = new first_person_camera();
cam->setProjection(glm::pi<float>() / 4.0f, screenWidth/screenHeight, 0.1f, 10000.0f);
cam->setPositon(glm::vec3(2.0f, 0.0f, 2.0f));
if (!eff.addShader("lit_textured.vert", GL_VERTEX_SHADER))
exit(EXIT_FAILURE);
/*if (!eff.addShader("tarnished.vert", GL_VERTEX_SHADER))
exit(EXIT_FAILURE);*/
/*if (!eff.addShader("enviroment_map.vert", GL_VERTEX_SHADER))
exit(EXIT_FAILURE);*/
if (!eff.addShader("lighting.frag", GL_FRAGMENT_SHADER))
exit(EXIT_FAILURE);
if (!eff.addShader("point_light.frag", GL_FRAGMENT_SHADER))
exit(EXIT_FAILURE);
if (!eff.addShader("spot_light.frag", GL_FRAGMENT_SHADER))
exit(EXIT_FAILURE);
if (!eff.addShader("lit_textured.frag", GL_FRAGMENT_SHADER))
exit(EXIT_FAILURE);
/*if (!eff.addShader("tarnished.frag", GL_FRAGMENT_SHADER))
exit(EXIT_FAILURE);*/
/*if (!eff.addShader("enviroemtn_map.frag", GL_FRAGMENT_SHADER))
exit(EXIT_FAILURE);*/
if (!eff.create())
exit(EXIT_FAILURE);
scene = loadScene("scene.json");
std::vector<std::string> cubemap_texs;
/*cubemap_texs.push_back("xpos.png");
cubemap_texs.push_back("xneg.png");
cubemap_texs.push_back("ypos.png");
cubemap_texs.push_back("yneg.png");
cubemap_texs.push_back("zpos.png");
cubemap_texs.push_back("zneg.png");*/
cubemap_texs.push_back("posx.jpg");
cubemap_te
|
请发表评论