Archived

This topic is now archived and is closed to further replies.

omegasyphon

mouse input question

Recommended Posts

omegasyphon    100
alright why doesnt this work? if i move the mouse shouldnt it move what i have displayed or am i doing this wrong?

  

void processmousecords(int x,int y)
{
xrot=x;
yrot=y;
}

void renderscene()
{
GLfloat x;

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glRotatef(x,1.0f,0.0f,0.0f);
glRotatef(30.0f,0.0f,0.0f,1.0f);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3,GL_FLOAT,0,cords);
glDrawElements(GL_TRIANGLE_STRIP,1600,GL_UNSIGNED_INT,corners);
glPopMatrix();
glutSwapBuffers();
}


void main()
{
GLfloat x=0.0;
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutCreateWindow("game engine console");
glutReshapeFunc(ChangeSize);
glutDisplayFunc(renderscene);
setuprc();
glutMotionFunc(processmousecords);
glutMainLoop();
}


Share this post


Link to post
Share on other sites
a2k    124
omegasyphon, try adding

glutPostRedisplay();

in your processmouse inputs function. this tells the renderer that the function has made an update.

paulP,

yes there is a way without glut. you use regular Win32 code. the topic goes into the WinProc, which i don''t wanna discuss, but that is where you would put your mouse processing commands.

a2k

Share this post


Link to post
Share on other sites
a2k    124
ShiningKnight, looking forward to it. Are there any tutes out there right now that cover some of that stuff? (maybe i''ll check nehe.) either way, when will your tute come out?

a2k

Share this post


Link to post
Share on other sites
mittens    1323
Hmmm... Whenever I feel like writing the tut (I just wrote a 17 page one on .md2 loading and .ms3d loading that should be up on NeHe''s site pretty soon... So I''m a little burned out on writing). But the code *IS* done, so whenever I feel like writing, I''ll write it.

------------------------------
Trent (ShiningKnight)
E-mail me
OpenGL Game Programming Tutorials

Share this post


Link to post
Share on other sites
PaulP    122
I thought abut DirectInput, but i already know how to use that, i wanted to know if there was any other pratical ways to trap the mouse!!

As for the tut's, looking forward to them, i already know how to use DirectInput, but i always benefit from looking at tutorials, i get to see all the little tricks i missed first time round!!

Will they be based on C or C++??



Edited by - PaulP on July 7, 2001 7:40:58 PM

Share this post


Link to post
Share on other sites
Oluseyi    2103
That''s because the SDK documents are fairly complete. There isn''t too much to mouse input in DI - or keyboard either. Joystick is just a little bit more involved. So, check your SDK docs - the answer lies within.



Or some fantasy-sounding junk like that...

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
http://www.gamedev.net/reference/articles/article539.asp

Share this post


Link to post
Share on other sites
merlin9x9    174
Don''t bother with DirectInput to grab the mouse, unless you need automatic buffering (which you could set up using less code than it takes to initialize DirectInput properly). Use GetCursorPos (and SetCursorPos to set the position) instead.

Share this post


Link to post
Share on other sites
merlin9x9    174
It does?! I've never heard of that happening, even when DirectInput happens to be initialized in the same app, because it's one of those functions that's always safe to call. Are you positive that it's GetCursorPos that's causing the crash?

This is the code I've used to get the mouse position relative to the origin of my game window's client area:

  
// this bit just gets the mouse position in screen coordinates

POINT curr_pos;
GetCursorPos(&curr_pos);

// hwnd is the handle to my game's main window

// this function will transform the screen coordinates of the mouse to window coordinates

ScreenToClient(hwnd, &curr_pos);


That should do it right there, and it should always be safe to do, assuming that your window has been created prior to the call and you give ScreenToClient a valid window handle.

If you're still having problems, perhaps you could post some code?


Edited by - merlin9x9 on July 12, 2001 3:53:13 PM

Share this post


Link to post
Share on other sites