at75
asked on
zoom in/out
i'm doing somehting on openGL.
i try to zoom in and out my object(let say a cube).
when i press the "+" key ,the object is suppose to scale up 0.1
then the zoom up object will be display.
when i press the "-" key ,the object is suppose to scale down by -0.1.
However, when i press the "+" key ,then the "-" key,i will need to key in "-" twice to see the scale down effect.this applies also when i key in "-" then "+".
why is it so?
my code:
void CDhView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
switch(nChar) {
case VK_ADD:
if (scale <= 5.0f)
scale+=0.1f;
cameramode = PLUS;
break;
case VK_SUBTRACT:
if (scale > 0.0f)
scale-=0.1f;
cameramode = SUBTRACT;
break;
}
void CDhView::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
{
switch(nChar) {
case VK_ADD :
cameramode = STOP;
break;
case VK_SUBTRACT:
cameramode = STOP;
break;
}
}
void CDhView::OnDraw(CDC* pDC)
//Zooming
if (cameramode == PLUS)
glScalef(scale,scale,scale );
if (cameramode == SUBTRACT )
glScalef(scale,scale,scale );
thanks.
i try to zoom in and out my object(let say a cube).
when i press the "+" key ,the object is suppose to scale up 0.1
then the zoom up object will be display.
when i press the "-" key ,the object is suppose to scale down by -0.1.
However, when i press the "+" key ,then the "-" key,i will need to key in "-" twice to see the scale down effect.this applies also when i key in "-" then "+".
why is it so?
my code:
void CDhView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
switch(nChar) {
case VK_ADD:
if (scale <= 5.0f)
scale+=0.1f;
cameramode = PLUS;
break;
case VK_SUBTRACT:
if (scale > 0.0f)
scale-=0.1f;
cameramode = SUBTRACT;
break;
}
void CDhView::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
{
switch(nChar) {
case VK_ADD :
cameramode = STOP;
break;
case VK_SUBTRACT:
cameramode = STOP;
break;
}
}
void CDhView::OnDraw(CDC* pDC)
//Zooming
if (cameramode == PLUS)
glScalef(scale,scale,scale
if (cameramode == SUBTRACT )
glScalef(scale,scale,scale
thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
where have you put the CDhView.Refresh() (or other grapics updating)
ASKER
thanks