本文整理汇总了C++中i2fl函数的典型用法代码示例。如果您正苦于以下问题:C++ i2fl函数的具体用法?C++ i2fl怎么用?C++ i2fl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了i2fl函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gr_set_2d_matrix
// set a view and projection matrix for a 2D element
// TODO: this probably needs to accept values
void gr_set_2d_matrix(/*int x, int y, int w, int h*/)
{
// don't bother with this if we aren't even going to need it
if (!gr_htl_projection_matrix_set) {
return;
}
Assert( htl_2d_matrix_set == 0 );
Assert( htl_2d_matrix_depth == 0 );
// the viewport needs to be the full screen size since glOrtho() is relative to it
gr_set_viewport(0, 0, gr_screen.max_w, gr_screen.max_h);
gr_last_projection_matrix = gr_projection_matrix;
// the top and bottom positions are reversed on purpose, but RTT needs them the other way
if (gr_screen.rendering_to_texture != -1) {
create_orthographic_projection_matrix(&gr_projection_matrix, 0, i2fl(gr_screen.max_w), 0, i2fl(gr_screen.max_h), -1, 1);
} else {
create_orthographic_projection_matrix(&gr_projection_matrix, 0, i2fl(gr_screen.max_w), i2fl(gr_screen.max_h), 0, -1, 1);
}
matrix4 identity_mat;
vm_matrix4_set_identity(&identity_mat);
gr_model_matrix_stack.push_and_replace(identity_mat);
gr_last_view_matrix = gr_view_matrix;
gr_view_matrix = identity_mat;
vm_matrix4_x_matrix4(&gr_model_view_matrix, &gr_view_matrix, &identity_mat);
htl_2d_matrix_set = true;
htl_2d_matrix_depth++;
}
示例2: profile_dump_output
/**
* Builds the output text.
*/
void profile_dump_output()
{
if (Cmdline_frame_profile) {
end_profile_time = timer_get_microseconds();
if (Cmdline_profile_write_file)
{
profiling_file << end_profile_time << ";" << (end_profile_time - start_profile_time) << std::endl;
}
profile_output.clear();
profile_output += " Avg : Min : Max : # : Profile Name\n";
profile_output += "----------------------------------------\n";
for(int i = 0; i < (int)samples.size(); i++) {
uint64_t sample_time;
float percent_time, avg_time, min_time, max_time;
uint64_t avg_micro_seconds, min_micro_seconds, max_micro_seconds;
Assert(samples[i].open_profiles == 0);
sample_time = samples[i].accumulator - samples[i].children_sample_time;
if (end_profile_time == start_profile_time) {
percent_time = 0.0f;
} else {
percent_time = (i2fl(sample_time) / i2fl(end_profile_time - start_profile_time)) *100.0f;
}
avg_micro_seconds = min_micro_seconds = max_micro_seconds = sample_time;
avg_time = min_time = max_time = percent_time;
// add new measurement into the history and get avg, min, and max
store_profile_in_history(samples[i].name, percent_time, sample_time);
get_profile_from_history(samples[i].name, &avg_time, &min_time, &max_time, &avg_micro_seconds, &min_micro_seconds, &max_micro_seconds);
// format the data
char avg[64], min[64], max[64], num[64];
sprintf(avg, "%3.1f%% (%3.1fms)", avg_time, i2fl(avg_micro_seconds)*0.001f);
sprintf(min, "%3.1f%% (%3.1fms)", min_time, i2fl(min_micro_seconds)*0.001f);
sprintf(max, "%3.1f%% (%3.1fms)", max_time, i2fl(max_micro_seconds)*0.001f);
sprintf(num, "%3d", samples[i].profile_instances);
SCP_string indented_name(samples[i].name);
for(uint indent = 0; indent < samples[i].num_parents; indent++) {
indented_name = ">" + indented_name;
}
char line[256];
sprintf(line, "%5s : %5s : %5s : %3s : ", avg, min, max, num);
profile_output += line + indented_name + "\n";
}
samples.clear();
start_profile_time = timer_get_microseconds();
}
}
示例3: setClip
void HudGaugeRadarDradis::setupViewHtl()
{
setClip(position[0], position[1], Radar_radius[0], Radar_radius[1]);
gr_set_proj_matrix(.625f * PI_2, i2fl(Radar_radius[0])/i2fl(Radar_radius[1]), 0.001f, 5.0f);
gr_set_view_matrix(&Orb_eye_position, &vmd_identity_matrix);
gr_zbuffer_set(GR_ZBUFF_NONE);
}
示例4: gr_opengl_set_ambient_light
void gr_opengl_set_ambient_light(int red, int green, int blue)
{
GL_light_ambient[0] = i2fl(red)/255.0f;
GL_light_ambient[1] = i2fl(green)/255.0f;
GL_light_ambient[2] = i2fl(blue)/255.0f;
GL_light_ambient[3] = 1.0f;
opengl_calculate_ambient_factor();
}
示例5: gr_opengl_scene_texture_begin
void gr_opengl_scene_texture_begin()
{
if ( !Scene_texture_initialized ) {
return;
}
if ( Scene_framebuffer_in_frame ) {
return;
}
GR_DEBUG_SCOPE("Begin scene texture");
TRACE_SCOPE(tracing::SceneTextureBegin);
GL_state.PushFramebufferState();
GL_state.BindFrameBuffer(Scene_framebuffer);
//glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, Scene_depth_texture, 0);
if (GL_rendering_to_texture)
{
Scene_texture_u_scale = i2fl(gr_screen.max_w) / i2fl(Scene_texture_width);
Scene_texture_v_scale = i2fl(gr_screen.max_h) / i2fl(Scene_texture_height);
CLAMP(Scene_texture_u_scale, 0.0f, 1.0f);
CLAMP(Scene_texture_v_scale, 0.0f, 1.0f);
}
else
{
Scene_texture_u_scale = 1.0f;
Scene_texture_v_scale = 1.0f;
}
if ( Cmdline_no_deferred_lighting ) {
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
} else {
GLenum buffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT3, GL_COLOR_ATTACHMENT4 };
glDrawBuffers(5, buffers);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
opengl_clear_deferred_buffers();
glDrawBuffer(GL_COLOR_ATTACHMENT0);
}
Scene_framebuffer_in_frame = true;
if ( Gr_post_processing_enabled && !PostProcessing_override ) {
High_dynamic_range = true;
}
}
示例6: gr_end_proj_matrix
void gr_end_proj_matrix() {
gr_set_viewport(0, 0, gr_screen.max_w, gr_screen.max_h);
gr_last_projection_matrix = gr_projection_matrix;
// the top and bottom positions are reversed on purpose, but RTT needs them the other way
if (gr_screen.rendering_to_texture != -1) {
create_orthographic_projection_matrix(&gr_projection_matrix, 0.0f, i2fl(gr_screen.max_w), 0.0f, i2fl(gr_screen.max_h), -1.0f, 1.0f);
} else {
create_orthographic_projection_matrix(&gr_projection_matrix, 0.0f, i2fl(gr_screen.max_w), i2fl(gr_screen.max_h), 0.0f, -1.0f, 1.0f);
}
gr_htl_projection_matrix_set = false;
}
示例7: gr_opengl_zbias
void gr_opengl_zbias(int bias)
{
if (bias) {
GL_state.PolygonOffsetFill(GL_TRUE);
if(bias < 0) {
GL_state.SetPolygonOffset(1.0, -i2fl(bias));
}
else {
GL_state.SetPolygonOffset(0.0, -i2fl(bias));
}
} else {
GL_state.PolygonOffsetFill(GL_FALSE);
}
}
示例8: setGaugeColor
/**
* Renders everything for a head animation
* Also checks for when new head ani's need to start playing
*/
void HudGaugeTalkingHead::render(float frametime)
{
if ( Head_frame.first_frame == -1 ) {
return;
}
if(msg_id != -1 && head_anim != NULL) {
if(!head_anim->done_playing) {
// draw frame
// hud_set_default_color();
setGaugeColor();
// clear
setClip(position[0] + Anim_offsets[0], position[1] + Anim_offsets[1], Anim_size[0], Anim_size[1]);
gr_clear();
resetClip();
renderBitmap(Head_frame.first_frame, position[0], position[1]); // head ani border
float scale_x = i2fl(Anim_size[0]) / i2fl(head_anim->width);
float scale_y = i2fl(Anim_size[1]) / i2fl(head_anim->height);
gr_set_screen_scale(fl2ir(base_w / scale_x), fl2ir(base_h / scale_y));
setGaugeColor();
generic_anim_render(head_anim,frametime, fl2ir((position[0] + Anim_offsets[0] + HUD_offset_x) / scale_x), fl2ir((position[1] + Anim_offsets[1] + HUD_offset_y) / scale_y));
// draw title
gr_set_screen_scale(base_w, base_h);
renderString(position[0] + Header_offsets[0], position[1] + Header_offsets[1], XSTR("message", 217));
} else {
for (int j = 0; j < Num_messages_playing; ++j) {
if (Playing_messages[j].id == msg_id) {
Playing_messages[j].play_anim = false;
break; // only one head ani plays at a time
}
}
msg_id = -1; // allow repeated messages to display a new head ani
head_anim = NULL; // Nothing to see here anymore, move along
}
}
// check playing messages to see if we have any messages with talking animations that need to be created.
for (int i = 0; i < Num_messages_playing; i++ ) {
if(Playing_messages[i].play_anim && Playing_messages[i].id != msg_id ) {
msg_id = Playing_messages[i].id;
if (Playing_messages[i].anim_data)
head_anim = Playing_messages[i].anim_data;
else
head_anim = NULL;
return;
}
}
}
示例9: hud_lock_reset
// Reset data used for player lock indicator
void hud_lock_reset(float lock_time_scale)
{
weapon_info *wip;
ship_weapon *swp;
swp = &Player_ship->weapons;
wip = &Weapon_info[swp->secondary_bank_weapons[swp->current_secondary_bank]];
Player_ai->current_target_is_locked = 0;
Players[Player_num].lock_indicator_visible = 0;
Player->target_in_lock_cone = 0;
Player->lock_time_to_target = i2fl(wip->min_lock_time*lock_time_scale);
Player->current_target_sx = -1;
Player->current_target_sy = -1;
Player->locking_subsys=NULL;
Player->locking_on_center=0;
Player->locking_subsys_parent=-1;
hud_stop_looped_locking_sounds();
Lock_gauge_draw_stamp = -1;
Lock_gauge_draw = 0;
// reset the lock anim time elapsed
Lock_anim.time_elapsed = 0.0f;
}
示例10: joy_down_time
float joy_down_time(int btn)
{
float rval;
unsigned int now;
joy_button_info *bi;
if ( joy_num_sticks < 1 ) return 0.0f;
if ( (btn < 0) || (btn >= JOY_TOTAL_BUTTONS)) return 0.0f;
bi = &joy_buttons[btn];
now = timer_get_milliseconds();
if ( bi->down_time == 0 && joy_down(btn) ) {
bi->down_time += joy_pollrate;
}
if ( (now - bi->last_down_check) > 0)
rval = i2fl(bi->down_time) / (now - bi->last_down_check);
else
rval = 0.0f;
bi->down_time = 0;
bi->last_down_check = now;
if (rval < 0)
rval = 0.0f;
if (rval > 1)
rval = 1.0f;
return rval;
}
示例11: hud_lock_reset
// Reset data used for player lock indicator
void hud_lock_reset(float lock_time_scale)
{
weapon_info *wip;
ship_weapon *swp;
swp = &Player_ship->weapons;
if ((swp->current_secondary_bank >= 0) && (swp->secondary_bank_weapons[swp->current_secondary_bank] >= 0)) {
Assert(swp->current_secondary_bank < MAX_SHIP_SECONDARY_BANKS);
Assert(swp->secondary_bank_weapons[swp->current_secondary_bank] < MAX_WEAPON_TYPES);
wip = &Weapon_info[swp->secondary_bank_weapons[swp->current_secondary_bank]];
Player->lock_time_to_target = i2fl(wip->min_lock_time*lock_time_scale);
} else {
Player->lock_time_to_target = 0.0f;
}
Player_ai->current_target_is_locked = 0;
Players[Player_num].lock_indicator_visible = 0;
Player->target_in_lock_cone = 0;
Player->current_target_sx = -1;
Player->current_target_sy = -1;
Player->locking_subsys=NULL;
Player->locking_on_center=0;
Player->locking_subsys_parent=-1;
hud_stop_looped_locking_sounds();
}
示例12: i2fl
/**
* Create a new head animation object
*/
anim_instance* HudGaugeTalkingHead::createAnim(int anim_start_frame, anim* anim_data)
{
anim_play_struct aps;
float scale_x = i2fl(Anim_size[0]) / i2fl(anim_data->width);
float scale_y = i2fl(Anim_size[1]) / i2fl(anim_data->height);
anim_play_init(&aps, anim_data, fl2ir((position[0] + Anim_offsets[0] + HUD_offset_x) / scale_x), fl2ir((position[1] + Anim_offsets[1] + HUD_offset_y) / scale_y), base_w, base_h);
aps.start_at = anim_start_frame;
// aps.color = &HUD_color_defaults[HUD_color_alpha];
aps.color = &HUD_config.clr[HUD_TALKING_HEAD];
// I'd much rather use gr_init_color and retrieve the colors from this object but no, aps.color just happens to be a pointer.
// So, just give it the address from the player's HUD configuration. You win, aps.color. I'll take care of you next time. (Swifty)
return anim_play(&aps);
}
示例13: gr_setup_viewport
void gr_setup_viewport() {
if (Gr_inited) {
// This may be called by FRED before the gr system is actually initialized so we need to make sure that
// this function call is actually valid at this point.
gr_set_viewport(0, 0, gr_screen.max_w, gr_screen.max_h);
}
gr_last_projection_matrix = gr_projection_matrix;
// the top and bottom positions are reversed on purpose, but RTT needs them the other way
if (gr_screen.rendering_to_texture != -1) {
create_orthographic_projection_matrix(&gr_projection_matrix, 0, i2fl(gr_screen.max_w), 0, i2fl(gr_screen.max_h), -1, 1);
} else {
create_orthographic_projection_matrix(&gr_projection_matrix, 0, i2fl(gr_screen.max_w), i2fl(gr_screen.max_h), 0, -1, 1);
}
}
示例14: Assert
void FrameProfiler::dump_output(SCP_stringstream& out,
uint64_t /*start_profile_time*/,
uint64_t /*end_profile_time*/,
SCP_vector<profile_sample>& samples) {
out << " Avg : Min : Max : # : Profile Name\n";
out << "----------------------------------------\n";
for (int i = 0; i < (int) samples.size(); i++) {
uint64_t sample_time;
uint64_t avg_micro_seconds, min_micro_seconds, max_micro_seconds;
Assert(samples[i].open_profiles == 0);
sample_time = samples[i].accumulator - samples[i].children_sample_time;
avg_micro_seconds = min_micro_seconds = max_micro_seconds = sample_time;
// add new measurement into the history and get avg, min, and max
store_profile_in_history(samples[i].name, sample_time);
get_profile_from_history(samples[i].name,
&avg_micro_seconds,
&min_micro_seconds,
&max_micro_seconds);
// format the data
char avg[64], min[64], max[64], num[64];
sprintf(avg, "%3.1fms", i2fl(avg_micro_seconds) * 0.000001f);
sprintf(min, "%3.1fms", i2fl(min_micro_seconds) * 0.000001f);
sprintf(max, "%3.1fms", i2fl(max_micro_seconds) * 0.000001f);
sprintf(num, "%3d", samples[i].profile_instances);
SCP_string indented_name;
for (uint indent = 0; indent < samples[i].num_parents; indent++) {
indented_name += ">";
}
indented_name += samples[i].name;
char line[256];
sprintf_safe(line, "%5s : %5s : %5s : %3s : ", avg, min, max, num);
out << line + indented_name + "\n";
}
}
示例15: radar_frame_init
void radar_frame_init()
{
radar_null_nblips();
radx = i2fl(Radar_radius[gr_screen.res][0])/2.0f;
rady = i2fl(Radar_radius[gr_screen.res][1])/2.0f;
int w,h;
gr_set_font(FONT1);
Small_blip_string[0] = ubyte(SMALL_BLIP_CHAR);
Small_blip_string[1] = 0;
gr_get_string_size( &w, &h, Small_blip_string );
Small_blip_offset_x = -w/2;
Small_blip_offset_y = -h/2;
Large_blip_string[0] = ubyte(LARGE_BLIP_CHAR);
Large_blip_string[1] = 0;
gr_get_string_size( &w, &h, Large_blip_string );
Large_blip_offset_x = -w/2;
Large_blip_offset_y = -h/2;
}