천천히 "채워지는"순환 진행 표시기를 그리는 응용 프로그램에서 작업 중이므로 여기서 a couple of images을 볼 수 있습니다. 중간 모드를 사용하고 있으며 각 프레임 업데이트에서 꼭지점을 그려서이 원형 모양을 그리는 것입니다 (아래 코드 참조). 원이 채워지면 흰색과 회색 사이의 경계선이 약간 깜박이며 어떻게하면 더 부드럽게 만들 수 있는지 궁금합니다.OpenGL을 사용하여 매우 부드러운 움직이는 물체를 얻는 방법
이것은 구체적인 예입니다. 그러나 일반적으로 매우 단순한 라인 에어 보간을 사용할 때도 가장 매끄러운 동작을 얻는 방법에 대해 궁금합니다. 내가 내 아이폰의 페이지 사이를 뒤집을 때 모션을 볼 때 그것은 내 (빠른) Mac에서 어떻게 이것을 달성 할 수 있을지 궁금하게 만드는 너무 극단적으로 부드럽습니까? flickery, 앨리어싱, 부드러운 움직임이나 유물을 그리기 -
감사
Roxlu는
PhotoBoothCountdown::PhotoBoothCountdown(float fMillisDuration)
:duration(fMillisDuration)
,start_time(0)
{
setActionCommand("take_picture");
}
void PhotoBoothCountdown::update() {
if(start_time != 0) {
float cur = ofGetElapsedTimeMillis();
perc = (cur-start_time)/duration;
}
}
void PhotoBoothCountdown::draw() {
float resolution = 150;
int parts_filled = resolution * perc;
int parts_unfilled = (resolution - parts_filled);
float part_angle = TWO_PI/resolution;
//printf("filled: %i/%i/%i\n", parts_filled, parts_unfilled, (parts_filled+parts_unfilled));
float radius = 300.0f;
float width = 100;
float radius_inner = radius-width;
float center_x = ofGetWidth()/2;
float center_y = ofGetHeight()/2;
float angle = 0;
glBegin(GL_TRIANGLE_STRIP);
glColor4f(0.2f, 0.2f, 0.2f,0.9f);
for(int i = 0; i <= parts_filled; ++i) {
float cosa = cos(angle);
float sina = sin(angle);
glVertex2f(center_x + cosa * radius,center_y + sina * radius);
glVertex2f(center_x + cosa * radius_inner,center_y + sina * radius_inner);
angle += part_angle;
}
glEnd();
glBegin(GL_TRIANGLE_STRIP);
glColor4f(1.0f, 1.0f, 1.0f,0.9f);
angle -= part_angle;
for(int i = 0; i <= parts_unfilled; ++i) {
float cosa = cos(angle);
float sina = sin(angle);
glVertex2f(center_x + cosa * radius,center_y + sina * radius);
glVertex2f(center_x + cosa * radius_inner,center_y + sina * radius_inner);
angle += part_angle;
}
glEnd();
if(perc >= 1) {
printf("should fire");
fireEvent();
reset();
}
}
void PhotoBoothCountdown::start() {
start_time = ofGetElapsedTimeMillis();
end_time = start_time + duration;
}
void PhotoBoothCountdown::reset() {
start_time = 0;
end_time = 0;
perc = 0;
}
OpenGL은 기본적으로 더블 버퍼링됩니다. – doc
@doc : OpenGL은 단일 vs 이중 버퍼에 대해 잘 모릅니다. 이는 wgl 또는 glx와 같은 윈도우 시스템 인터페이스의 작업입니다.이것이 전형적으로'glutSwapBuffers'를 호출하는 이유입니다. 예를 들어, 신화적인'glSwapBuffers'가 아닌 –
@doc : 그렇지 않습니다. 당신이 그것을 초기화하는 방식에 달려 있습니다. @ 에릭 : +1 – Calvin1602