Mouse Input Implementation
Can some one direct me in the best way to implement mouse input into the OpenGL tuts that Nehe has set up here... I can''t get a point to be drawn through the use of the mouse messages in win32 programming... I used the following
WM_LBUTTONDOWN:
SetCapture(hwnd);
int cx = LOWORD(lParam);
int cy = HIWORD(lParam);
//Class defined to hide mouse input
CMouse mouse;
//Sets the x and y values for the location of a Dot to draw
mouse.GetPoint(cx,cy);
break;
WM_LBUTTONUP:
ReleaseCapture();
///....///
void CMouse::GetPoint(int x, int y)
{
m_PosX = x;
m_PosY = y;
}
void CMouse::DrawPoint()
{
glBegin(GL_POINTS);
glVertex2i(m_PosX, m_PosY);
glEnd();
}
////
Render fucntion then just calls the DrawPoint ()
glPushMatrix();
DrawPoint();
glPopMatrix();
but for some reason this doesn''t get any thing to appear on the screen
euro (TIA)
----Eurosprt1--Pilot Extrodinaire
are u using the right projection matrix
http://members.xoom.com/myBollux
http://members.xoom.com/myBollux
I have been using the projection set up in the tutorials... is this wrong?
euro
euro
----Eurosprt1--Pilot Extrodinaire
well im not sure what that is
but try someit like this
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(90, winWidth/winHeight, 1, 100);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
draw 3d stuff
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glViewport(0,0,winWidth,winHeight);
glOrtho(0,winWidth,0,winHeight,-100.0,100.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
now everything u draw will map to window coords (0,0) bottomleft,
(winWidth,winHeight) top right
glBegin(GL_POINTS);
glVertex2i(m_PosX, m_PosY);
glEnd();
http://members.xoom.com/myBollux
but try someit like this
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(90, winWidth/winHeight, 1, 100);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
draw 3d stuff
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glViewport(0,0,winWidth,winHeight);
glOrtho(0,winWidth,0,winHeight,-100.0,100.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
now everything u draw will map to window coords (0,0) bottomleft,
(winWidth,winHeight) top right
glBegin(GL_POINTS);
glVertex2i(m_PosX, m_PosY);
glEnd();
http://members.xoom.com/myBollux
ZedZeek,
I will let you know what happens thanx for the input... I appreciate it greatly.. Now I just have to throw a program together in 72 hours to turn in on Monday
euro
Edited by - eurosprt1 on November 4, 2000 8:32:47 PM
I will let you know what happens thanx for the input... I appreciate it greatly.. Now I just have to throw a program together in 72 hours to turn in on Monday
euro
Edited by - eurosprt1 on November 4, 2000 8:32:47 PM
----Eurosprt1--Pilot Extrodinaire
ZedZeek...
It seems I am having troulbe trying to get the program to map correctly even with what you sent me for a window initialization and projection... I found that I was passing 0''s for x and y... Shoot self in foot... (thnx Zack Smith for logfile class).. Or I wouldn''t have ever found that problem...
I keep getting a conversion problem with accuracy of the location of the click of the button and the actual location of the dot drawn....
eg... I click in a particular point and the point shows up 3 to 4 units to the right or left of the location and 3 to 4 points up or down... this is a ruf estimate but I am taking the
LOWORD(lParam) and sending it to a function that sets the coordinates for the draw function... In the mutator function/set function I manipulate the points so that they conform to the OPENGL screen setup by dividing by 100
so it will come out with a whole number like 1, 2, 3, 4, etc...
euro
It seems I am having troulbe trying to get the program to map correctly even with what you sent me for a window initialization and projection... I found that I was passing 0''s for x and y... Shoot self in foot... (thnx Zack Smith for logfile class).. Or I wouldn''t have ever found that problem...
I keep getting a conversion problem with accuracy of the location of the click of the button and the actual location of the dot drawn....
eg... I click in a particular point and the point shows up 3 to 4 units to the right or left of the location and 3 to 4 points up or down... this is a ruf estimate but I am taking the
LOWORD(lParam) and sending it to a function that sets the coordinates for the draw function... In the mutator function/set function I manipulate the points so that they conform to the OPENGL screen setup by dividing by 100
so it will come out with a whole number like 1, 2, 3, 4, etc...
euro
----Eurosprt1--Pilot Extrodinaire
windoze maps (0,0) to the top left gl is (0,0) bottom left so be aware of that.
the 3,4 pixels soulds very much like the windows borders are coming into play. use GetDeviceMetrics(..) (i think thats the correct api function) to find out howwide the borders r on the computer and alter your coords accordanly, u could always of course make a window with out a border
http://members.xoom.com/myBollux
the 3,4 pixels soulds very much like the windows borders are coming into play. use GetDeviceMetrics(..) (i think thats the correct api function) to find out howwide the borders r on the computer and alter your coords accordanly, u could always of course make a window with out a border
http://members.xoom.com/myBollux
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement