![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
![]() |

|
| Programming Error ! Programming error messages |
![]() |
|
Capture Mouse Position
|
LinkBack | Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Fixed Error!
Posts: 4,202
Join Date: Mar 2007
Rep Power: 6
IM:
|
It simply draws a grid where the user can move, the user simply presses up/down/right/left to move 1 place in the respected direction. How could I capture a click from a user, and then convert the position of the click to a 'cell' of my grid. My Grid is : void drawWorld(void) { glColor3f(1.0f,0.0f,0.0f); DrawBox(-0.5f,-0.5f,0.0f,24.0f,24.0f); //24x24 grid } void DrawBox(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height) { glBegin(GL_QUADS); glVertex3f(x,y,z); glVertex3f(x+width,y,z); glVertex3f(x+width,y+height,z); glVertex3f(x,y+height,z); glEnd(); } Is just a 24.0f by 24.0f sqare. We are using a camera, using gluLookAt to view this square so that it looks like a floor. So how would be be able to change the click of the user on the grid, to actual grid positions. (ie. 3.4f,5.5f) ,so that we could the user to that place. (btw, we have already made code for the movements) |
|
|
|
|
|
|
|
|
#2 (permalink) |
|
Fixed Error!
Posts: 4,202
Join Date: Mar 2007
Rep Power: 6
IM:
|
BOOL GetCursorPos( LPPOINT lpPoint // address of structure for cursor position ); Parameters lpPoint Points to a POINT structure that receives the screen coordinates of the cursor. Return Values If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call GetLastError. Remarks The cursor position is always given in screen coordinates and is not affected by the mapping mode of the window that contains the cursor. The calling process must have WINSTA_READATTRIBUTES access to the window station. --------- The POINT structure defines the x- and y- coordinates of a point. typedef struct tagPOINT { // pt LONG x; LONG y; } POINT; Members x Specifies the x-coordinate of the point. y Specifies the y-coordinate of the point. ------ And here is an example POINT yourMousePos; if (GetCursorPos(&yourMousePos) == 0) MessageBox(0, "Mousepos could not be grabbed!", "Error", MB_ICONSTOP | MB_OK); |
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|