我设置一个按钮,在按钮里能给出x,y,这是画图必须要的两个数据,我有一个画图函数well(double x,double y) 是用opengl写的,需要在OnDraw()里执行
我的问题就是 如何点击按钮 然后将这两个数据赋给well(double x,double y) ,一按按钮,就给值,然后就画出来了
13 个解决方案
#1
谁来帮我解决以下阿
#2
先要设置像数格式
#3
视场什么的都画好了
#4
x,y是坐标吧,将x,y设置成全局变量,这样任何地方都可以修改x,y,然后在点击按键事件中调用well(double x,double y)就可以了
#5
我就是想用这个按钮控制这个opengl图形显示 ,如何做啊
#6
well函数画的是opengl的图形 必须得在OnDraw()执行阿 不是么
#7
设置一个全局变量bool bo
OnDraw()
{
if(bo)
{
well(double x,double y);
}
}
OnDraw()
{
if(bo)
{
well(double x,double y);
}
}
#8
我是这样设置的,在按钮里赋wellflag=TRUE;
可是按按钮的时候已经不走OnDraw()了阿
可是按按钮的时候已经不走OnDraw()了阿
#9
代码
#10
OnDraw()
void CThreeDWnd::OnDraw(CDC* pDC)
{
CDocument* pDoc = GetDocument();
// TODO: add draw code here
static BOOL bBusy = FALSE;
if(bBusy) return;
bBusy = TRUE;
// glClearColor(0.2f,0.2f,0.5f,1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
mydraw();
glFinish();
SwapBuffers(wglGetCurrentDC());
bBusy = FALSE;
////////////////////////////////////////
}
mydraw()
void CThreeDWnd::mydraw()
{
glTranslatef(0.0f,0.0f,-8.0f);
glTranslatef(m_fMoveX,m_fMoveY,m_fMoveZ);
glRotatef(m_fRotateX,1.0f,0.0f,0.0f);
glRotatef(m_fRotateY,0.0f,1.0f,0.0f);
glEnable(GL_LINE_STIPPLE);
glEnable(GL_POINT_SMOOTH);
glEnable(GL_LINE_SMOOTH);
if (wellflag==TRUE)
{
rect();
MessageBox("1");
}
// if (pwellflag==TRUE)
// {
// pwell(m1.xposition,m1.yposition);
// MessageBox("11");
// }
glDisable(GL_LINE_SMOOTH);
glDisable(GL_POINT_SMOOTH);
glDisable(GL_LINE_STIPPLE);
}
/////////////////////////////
void CThreeDWnd::OnButton32784()
{
wellflag=TRUE;
draw3dwell();
// wellflag=FALSE;
}
void CThreeDWnd::OnDraw(CDC* pDC)
{
CDocument* pDoc = GetDocument();
// TODO: add draw code here
static BOOL bBusy = FALSE;
if(bBusy) return;
bBusy = TRUE;
// glClearColor(0.2f,0.2f,0.5f,1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
mydraw();
glFinish();
SwapBuffers(wglGetCurrentDC());
bBusy = FALSE;
////////////////////////////////////////
}
mydraw()
void CThreeDWnd::mydraw()
{
glTranslatef(0.0f,0.0f,-8.0f);
glTranslatef(m_fMoveX,m_fMoveY,m_fMoveZ);
glRotatef(m_fRotateX,1.0f,0.0f,0.0f);
glRotatef(m_fRotateY,0.0f,1.0f,0.0f);
glEnable(GL_LINE_STIPPLE);
glEnable(GL_POINT_SMOOTH);
glEnable(GL_LINE_SMOOTH);
if (wellflag==TRUE)
{
rect();
MessageBox("1");
}
// if (pwellflag==TRUE)
// {
// pwell(m1.xposition,m1.yposition);
// MessageBox("11");
// }
glDisable(GL_LINE_SMOOTH);
glDisable(GL_POINT_SMOOTH);
glDisable(GL_LINE_STIPPLE);
}
/////////////////////////////
void CThreeDWnd::OnButton32784()
{
wellflag=TRUE;
draw3dwell();
// wellflag=FALSE;
}
#11
我现在就是先用按钮能控制rect()这个画矩形的话,那个也就能实现了
#12
你设断点跟踪了吗?按完按键后会否执行OnDraw函数?如果没有执行,那就用Invalidate();//更新屏幕
#13
3q,谢谢
#1
谁来帮我解决以下阿
#2
先要设置像数格式
#3
视场什么的都画好了
#4
x,y是坐标吧,将x,y设置成全局变量,这样任何地方都可以修改x,y,然后在点击按键事件中调用well(double x,double y)就可以了
#5
我就是想用这个按钮控制这个opengl图形显示 ,如何做啊
#6
well函数画的是opengl的图形 必须得在OnDraw()执行阿 不是么
#7
设置一个全局变量bool bo
OnDraw()
{
if(bo)
{
well(double x,double y);
}
}
OnDraw()
{
if(bo)
{
well(double x,double y);
}
}
#8
我是这样设置的,在按钮里赋wellflag=TRUE;
可是按按钮的时候已经不走OnDraw()了阿
可是按按钮的时候已经不走OnDraw()了阿
#9
代码
#10
OnDraw()
void CThreeDWnd::OnDraw(CDC* pDC)
{
CDocument* pDoc = GetDocument();
// TODO: add draw code here
static BOOL bBusy = FALSE;
if(bBusy) return;
bBusy = TRUE;
// glClearColor(0.2f,0.2f,0.5f,1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
mydraw();
glFinish();
SwapBuffers(wglGetCurrentDC());
bBusy = FALSE;
////////////////////////////////////////
}
mydraw()
void CThreeDWnd::mydraw()
{
glTranslatef(0.0f,0.0f,-8.0f);
glTranslatef(m_fMoveX,m_fMoveY,m_fMoveZ);
glRotatef(m_fRotateX,1.0f,0.0f,0.0f);
glRotatef(m_fRotateY,0.0f,1.0f,0.0f);
glEnable(GL_LINE_STIPPLE);
glEnable(GL_POINT_SMOOTH);
glEnable(GL_LINE_SMOOTH);
if (wellflag==TRUE)
{
rect();
MessageBox("1");
}
// if (pwellflag==TRUE)
// {
// pwell(m1.xposition,m1.yposition);
// MessageBox("11");
// }
glDisable(GL_LINE_SMOOTH);
glDisable(GL_POINT_SMOOTH);
glDisable(GL_LINE_STIPPLE);
}
/////////////////////////////
void CThreeDWnd::OnButton32784()
{
wellflag=TRUE;
draw3dwell();
// wellflag=FALSE;
}
void CThreeDWnd::OnDraw(CDC* pDC)
{
CDocument* pDoc = GetDocument();
// TODO: add draw code here
static BOOL bBusy = FALSE;
if(bBusy) return;
bBusy = TRUE;
// glClearColor(0.2f,0.2f,0.5f,1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
mydraw();
glFinish();
SwapBuffers(wglGetCurrentDC());
bBusy = FALSE;
////////////////////////////////////////
}
mydraw()
void CThreeDWnd::mydraw()
{
glTranslatef(0.0f,0.0f,-8.0f);
glTranslatef(m_fMoveX,m_fMoveY,m_fMoveZ);
glRotatef(m_fRotateX,1.0f,0.0f,0.0f);
glRotatef(m_fRotateY,0.0f,1.0f,0.0f);
glEnable(GL_LINE_STIPPLE);
glEnable(GL_POINT_SMOOTH);
glEnable(GL_LINE_SMOOTH);
if (wellflag==TRUE)
{
rect();
MessageBox("1");
}
// if (pwellflag==TRUE)
// {
// pwell(m1.xposition,m1.yposition);
// MessageBox("11");
// }
glDisable(GL_LINE_SMOOTH);
glDisable(GL_POINT_SMOOTH);
glDisable(GL_LINE_STIPPLE);
}
/////////////////////////////
void CThreeDWnd::OnButton32784()
{
wellflag=TRUE;
draw3dwell();
// wellflag=FALSE;
}
#11
我现在就是先用按钮能控制rect()这个画矩形的话,那个也就能实现了
#12
你设断点跟踪了吗?按完按键后会否执行OnDraw函数?如果没有执行,那就用Invalidate();//更新屏幕
#13
3q,谢谢