我是靠谱客的博主 简单大雁,最近开发中收集的这篇文章主要介绍Mouse Input,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

Introduction

mouse inputIn many of your programs you will need the option of accepting pointer input. This tutorial will explain how to capture messages sent by using a pointing device on the window.

If you are using GLUT|ES, please consult the GLUT on how to capture input from the mouse. The code is almost exactly the same for the stylus. Also make sure that you download the source code at the bottom of this page.

Contents of main.cpp :


The first step is to create a function that will process all pointer input. This function must accept certain parameters.

The first parameter must accept a UGWindow variable.

The second parameter must be an integer. This specifies what button has been pressed. The possible values can be either UG_BUT_LEFTUG_BUT_MIDDLE or UG_BUT_RIGHT.

The third parameter must also be an integer. This specifies what state the button was in. The two states areUG_BUT_DOWN and UG_BUT_UP signalling when the pointing device has been pressed and when it has been lifted.

The fourth and fifth parameters must also both be integers. These specify the x and y value of the pointing device when the key was pressed.

void pointer(UGWindow uwin, int button, int state, int x, int y)
{

We simply exit the program if the pointing device is pressed.

	exit(0);
}

The window needs to know what function we are using for processing pointer presses. We therefore place a call to the ugPointerFunc function along with the ugDisplayFunc function. This function takes the handle to the OpenGL window as its first parameter and the pointer function as its second.

	ugPointerFunc(uwin, pointer);

You should now be able to process pointer messages. If you run this program, you will still not see any graphics occur, but you can quit the program by either clicking on the screen with your pointing device or by pressing theq or up arrow keys.

Please let me know of any comments you may have : Contact Me

最后

以上就是简单大雁为你收集整理的Mouse Input的全部内容,希望文章能够帮你解决Mouse Input所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(48)

评论列表共有 0 条评论

立即
投稿
返回
顶部