本文整理汇总了C++中CL_GraphicContext::mult_rotate方法的典型用法代码示例。如果您正苦于以下问题:C++ CL_GraphicContext::mult_rotate方法的具体用法?C++ CL_GraphicContext::mult_rotate怎么用?C++ CL_GraphicContext::mult_rotate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CL_GraphicContext
的用法示例。
在下文中一共展示了CL_GraphicContext::mult_rotate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw_text
void ExampleText::draw_text(CL_GraphicContext &gc, CL_Texture &texture, CL_Angle angle)
{
gc.set_texture(0, texture);
gc.push_modelview();
gc.mult_translate(gc.get_width()/2.0f, gc.get_height()/2.0f);
gc.mult_rotate(angle, 0.0f, 0.0f, 1.0f);
CL_Draw::texture(gc, CL_Rectf(-300.0f, -300.0f, 300.0f, 300.0f), CL_Colorf(1.0f, 1.0f, 1.0f, 0.7f));
gc.pop_modelview();
gc.reset_texture(0);
}
示例2: start
//.........这里部分代码省略.........
cl1Enable(GL_NORMALIZE);
#endif
#ifdef USE_OPENGL_2
Shader shader(gc);
#endif
// Create the objects
aiSetImportPropertyFloat(AI_CONFIG_PP_GSN_MAX_SMOOTHING_ANGLE,89.53f);
const struct aiScene* scene_teapot = aiImportFile("../Clan3D/Resources/teapot.dae",aiProcessPreset_TargetRealtime_MaxQuality);
if (!scene_teapot)
throw CL_Exception("Cannot load the teapot model");
const struct aiScene* scene_clanlib = aiImportFile("../Clan3D/Resources/clanlib.dae",aiProcessPreset_TargetRealtime_MaxQuality);
if (!scene_clanlib)
throw CL_Exception("Cannot load the clanlib model");
const struct aiScene* scene_tuxball = aiImportFile("../Clan3D/Resources/tux_ball.dae",aiProcessPreset_TargetRealtime_MaxQuality | aiProcess_FlipUVs);
if (!scene_tuxball)
throw CL_Exception("Cannot load the tux ball model");
// Load the texture
CL_Texture tux(gc, "../Clan3D/Resources/tux.png");
float angle = 0.0f;
// Run until someone presses escape
while (!quit)
{
CL_Mat4f perp = CL_Mat4f::perspective(45.0f, ((float) gc.get_width()) / ((float) gc.get_height()), 0.1f, 1000.0f);
gc.set_projection(perp);
gc.clear(CL_Colorf::black);
gc.clear_depth(1.0f);
angle += 1.0f;
if (angle >= 360.0f)
angle -= 360.0f;
#ifdef USE_OPENGL_2
shader.Set(gc);
shader.Use(gc);
#else
gc.set_program_object(cl_program_color_only);
#endif
CL_PrimitivesArray prim_array(gc);
gc.set_modelview(CL_Mat4f::identity());
gc.mult_scale(1.0f,1.0f, -1.0f); // So +'ve Z goes into the screen
gc.mult_translate(0.0f, 0.0f, 2.0f);
gc.mult_rotate(CL_Angle(angle, cl_degrees), 0.0f, 1.0f, 0.0f, false);
gc.push_modelview();
recursive_render(gc, scene_teapot, scene_teapot->mRootNode, false);
gc.pop_modelview();
gc.push_modelview();
gc.mult_scale(0.5f, 0.5f, 0.5f);
gc.mult_translate(0.0f, -0.5f, 0.0f);
recursive_render(gc, scene_clanlib, scene_clanlib->mRootNode, false);
gc.pop_modelview();
#ifdef USE_OPENGL_2
shader.Set(gc, 0);
shader.Use(gc);
#else
gc.set_program_object(cl_program_single_texture);
#endif
gc.set_texture(0, tux);
gc.set_modelview(CL_Mat4f::identity());
gc.mult_scale(1.0f,1.0f, -1.0f); // So +'ve Z goes into the screen
gc.mult_translate(0.7f, 0.5f, 2.0f);
gc.mult_scale(0.05f, 0.05f, 0.05f);
gc.mult_rotate(CL_Angle(angle * 4.0f, cl_degrees), 0.0f, 1.0f, 0.0f, false);
recursive_render(gc, scene_tuxball, scene_tuxball->mRootNode, true);
gc.reset_texture(0);
gc.reset_program_object();
// Flip the display, showing on the screen what we have drawed
// since last call to flip()
window.flip(1);
// This call processes user input and other events
CL_KeepAlive::process();
}
aiReleaseImport(scene_tuxball);
aiReleaseImport(scene_clanlib);
aiReleaseImport(scene_teapot);
aiDetachAllLogStreams();
return 0;
}
示例3: start
//.........这里部分代码省略.........
std::vector<CL_Vec3f> object_normals;
std::vector<CL_Vec4f> object_material_ambient;
const int num_cubes = 20000;
object_positions.reserve(num_cubes * 6 * 6); // 6 faces, and 6 vertices per face
object_normals.reserve(num_cubes * 6 * 6);
object_material_ambient.reserve(num_cubes * 6 * 6);
for (int cnt=0; cnt < num_cubes; cnt++)
{
create_cube(object_positions, object_normals, object_material_ambient);
}
CL_VertexArrayBuffer vb_positions(gc, &object_positions[0], sizeof(CL_Vec3f) * object_positions.size());
CL_VertexArrayBuffer vb_normals(gc, &object_normals[0], sizeof(CL_Vec3f) * object_normals.size());
CL_VertexArrayBuffer vb_material_ambient(gc, &object_material_ambient[0], sizeof(CL_Vec4f) * object_material_ambient.size());
// ** Note, at this point "object_positions, object_normals and object_material_ambient"
// ** can be destroyed. But for the purpose of this example, is it kept
CL_Font fps_font(gc, "tahoma", 20);
FramerateCounter frameratecounter;
unsigned int time_last = CL_System::get_time();
float angle = 0.0f;
is_vertex_buffer_on = true;
while (!quit)
{
unsigned int time_now = CL_System::get_time();
float time_diff = (float) (time_now - time_last);
time_last = time_now;
gc.clear(CL_Colorf(0.0f, 0.0f, 0.0f, 1.0f));
gc.clear_depth(1.0f);
gc.set_map_mode(cl_map_2d_upper_left);
CL_String fps = cl_format("%1 fps", frameratecounter.get_framerate());
fps_font.draw_text(gc, gc.get_width() - 100, 30, fps);
CL_String info = cl_format("%1 vertices", (int) object_positions.size());
fps_font.draw_text(gc, 30, 30, info);
fps_font.draw_text(gc, 30, gc.get_height() - 8, "Press any key to toggle the Vertex Buffer option");
if (is_vertex_buffer_on)
{
fps_font.draw_text(gc, 200, 30, "Vertex Buffer = ON");
}
else
{
fps_font.draw_text(gc, 200, 30, "Vertex Buffer = OFF");
}
gc.set_map_mode(cl_user_projection);
CL_Mat4f perp = CL_Mat4f::perspective(45.0f, ((float) gc.get_width()) / ((float) gc.get_height()), 0.1f, 100000.0f);
gc.set_projection(perp);
angle += time_diff / 20.0f;
if (angle >= 360.0f)
angle -= 360.0f;
gc.push_modelview();
gc.set_modelview(CL_Mat4f::identity());
gc.mult_scale(1.0f,1.0f, -1.0f); // So +'ve Z goes into the screen
gc.mult_translate(0.0f, 0.0f, 800.0f);
gc.mult_rotate(CL_Angle(angle*2.0f, cl_degrees), 0.0f, 1.0f, 0.0f, false);
gc.mult_rotate(CL_Angle(angle, cl_degrees), 1.0f, 0.0f, 0.0f, false);
shader.Set(gc);
shader.Use(gc);
CL_PrimitivesArray prim_array(gc);
if (is_vertex_buffer_on)
{
prim_array.set_attributes(0, vb_positions, 3, cl_type_float, (void *) 0);
prim_array.set_attributes(1, vb_normals, 3, cl_type_float, (void *) 0);
prim_array.set_attributes(2, vb_material_ambient, 4, cl_type_float, (void *) 0);
}
else
{
prim_array.set_attributes(0, &object_positions[0]);
prim_array.set_attributes(1, &object_normals[0]);
prim_array.set_attributes(2, &object_material_ambient[0]);
}
gc.draw_primitives(cl_triangles, object_positions.size(), prim_array);
gc.pop_modelview();
gc.reset_program_object();
window.flip(0);
frameratecounter.frame_shown();
CL_KeepAlive::process();
}
return 0;
}