Mercurial > hg > haptic-xypad
view native/OpenHaptics/XYPad/HapticScene.h @ 1:46671fc7d649 tip
fixed "window" message bug and brought the message outside the haptic device monitor
author | Fiore Martin <f.martin@qmul.ac.uk> |
---|---|
date | Fri, 13 Mar 2015 13:02:16 +0000 |
parents | 011caca7515a |
children |
line wrap: on
line source
/* XYPad - a haptic xy-pad that uses the jHapticGUI library Copyright (C) 2015 Queen Mary University of London (http://depic.eecs.qmul.ac.uk/) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "Message.h" namespace jhapticgui { class HapticScene { int mWidth; int mHeight; protected: void (*send) (const Message &m); public: /** * Returns the width of the openGL window where the scene is displayed */ inline int getWidth() { return mWidth; } /** * Returns the height of the openGL window where the scene is displayed */ inline int getHeight() { return mHeight; } /** * The constructor takes as argument a pointer to a function that must * be invoked to send a message to the Java thread from the this haptic * scene. */ HapticScene(void (*messageCallback) (const Message & m) ) : send(messageCallback) {} virtual ~HapticScene(void){} /** * Sets the size of the openGL window where the scene is displayed */ inline virtual void setSize(int w, int h){ mWidth = w; mHeight = h; } /** Try and initializes the haptic device, return false if the initialization fails */ virtual bool initHaptics(void) = 0; /** Initializes the openGL windows after the haptics has been successfully initialized */ virtual void initGL(void) = 0; /** handles an incoming message from the Java thread. * * Returns an update code if the message changes the * scene. The code is passed to drawScene() for updating * the scene accordingly. */ virtual unsigned int processMessage(const Message & m) = 0; /** called at the beginning of each frame */ virtual void beginFrame(void) = 0; /** called at the end of each frame */ virtual void endFrame(void) = 0; /** draws the haptic cursor, namely the haptic device proxy */ virtual void drawCursor(void) = 0; /** * Draws one frame both graphic and haptic. * * messageUpdate and callbacksUpdate are integer codes specifying what * needs to be updated in the haptic and graphic scenes. messageUpdate * is the value returned by processMessage and flags that a message from the * Java thread affects the scene which must therefore be updated. * * callbacksUpdate is the value returned by checkCallbacks * and flags that a haptic event happened that affects the scene, * which must therefore be updated. */ virtual void drawScene(unsigned int messageUpdate, unsigned int callbacksUpdate) = 0; /** Checks for haptic callbacks, namely functions that are called when * a haptic events occurs. Typical haptic events are proxy touching an * object, proxy moving, button pressed etc. * * Returns an update code if any event changes the * scene. The code is passed in the next frame to drawScene(), * for updating the scene accordingly. * */ virtual unsigned int checkCallbacks(void) = 0; }; }