summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2012-01-02 14:16:48 +0000
committerTim Redfern <tim@eclectronics.org>2012-01-02 14:16:48 +0000
commitbd80808793bcadebc303409b316a7d50c8fc2eb5 (patch)
treeb4cdd1f9aaaf500cd349a4155233ba2c8e3900cc /src
parent8b005ba4cebd9909496e0d032770efe9844b5675 (diff)
orbiting with light
Diffstat (limited to 'src')
-rw-r--r--src/keyVar.cpp8
-rw-r--r--src/main.cpp21
-rw-r--r--src/testApp.cpp1
-rw-r--r--src/testApp.h2
-rw-r--r--src/viewpoint.cpp22
5 files changed, 39 insertions, 15 deletions
diff --git a/src/keyVar.cpp b/src/keyVar.cpp
index ea8b9ff..8a5ce9a 100644
--- a/src/keyVar.cpp
+++ b/src/keyVar.cpp
@@ -23,22 +23,22 @@ void keyVar::keyPressed(char _key){
if (_key==keyInc&&state!=1) {
state=1;
timePressed=timeCalc=ofGetElapsedTimef();
- if (DEBUG) printf("pressed %i\n",_key);
+ if (DEBUG) printf("pressed %i:%i\n",_key,ofGetElapsedTimeMillis());
}
if (_key==keyDec&&state!=-1) {
state=-1;
timePressed=timeCalc=ofGetElapsedTimef();
- if (DEBUG) printf("pressed %i\n",_key);
+ if (DEBUG) printf("pressed %i:%i\n",_key,ofGetElapsedTimeMillis());
}
}
void keyVar::keyReleased(char _key){
if (_key==keyInc&&state==1) {
state=0;
- if (DEBUG) printf("released %i\n",_key);
+ if (DEBUG) printf("released %i:%i\n",_key,ofGetElapsedTimeMillis());
}
if (_key==keyDec&&state==-1) {
state=0;
- if (DEBUG) printf("released %i\n",_key);
+ if (DEBUG) printf("released %i:%i\n",_key,ofGetElapsedTimeMillis());
}
}
float keyVar::getVal(){
diff --git a/src/main.cpp b/src/main.cpp
index 3df2e96..1ed640d 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -2,12 +2,29 @@
#include "testApp.h"
#include "ofAppGlutWindow.h"
+// Includes for Mac OSX
+
+#include <GLUT/glut.h>
+#include <OpenGL/gl.h>
+#include <OpenGL/glu.h>
+
+/*
+ //Includes for Windows
+
+ #include <GL/glew.h>
+ #include <GL/glut.h>
+ #include <GL/freeglut.h>
+ #include <iostream>
+ */
+
//========================================================================
int main( ){
ofAppGlutWindow window;
- ofSetupOpenGL(&window, 1024,600, OF_FULLSCREEN); // <-------- setup the GL context
-
+ ofSetupOpenGL(&window, 512,512, OF_WINDOW); // <-------- setup the GL context
+ glutIgnoreKeyRepeat(1);
+ glutSetKeyRepeat(GLUT_KEY_REPEAT_OFF); //these don't work!!!
+ printf("key repeat ignore: %i\n",glutDeviceGet(GLUT_DEVICE_IGNORE_KEY_REPEAT));
// this kicks off the running of my app
// can be OF_WINDOW or OF_FULLSCREEN
// pass in width and height too:
diff --git a/src/testApp.cpp b/src/testApp.cpp
index 0d42e85..089e677 100644
--- a/src/testApp.cpp
+++ b/src/testApp.cpp
@@ -34,6 +34,7 @@ void testApp::setup(){
views[0].setup(GL_LIGHT0,ofGetWidth(),ofGetHeight(),0,0);
activeView=0;
+
}
diff --git a/src/testApp.h b/src/testApp.h
index 14fc09d..e2138a0 100644
--- a/src/testApp.h
+++ b/src/testApp.h
@@ -29,6 +29,8 @@ have to track how many frames each key has been pressed for
#include "mapUtils.h"
#include "viewpoint.h"
+
+
class testApp : public ofBaseApp{
public:
diff --git a/src/viewpoint.cpp b/src/viewpoint.cpp
index 0c7fe8a..39e8d32 100644
--- a/src/viewpoint.cpp
+++ b/src/viewpoint.cpp
@@ -13,20 +13,20 @@ void viewpoint::setup(int ln,float w, float h, float x, float y) {
near=1;
far=20;
- camera.setParent(target);
+ //camera.setParent(target);
vars=new keyVar[8];
//void set(char _keyInc,char _keyDec,float _val,float _speed,float _accel,float accelTime);
vars[0].set('w','s',17.25,0.5,2.0,3.0);
- vars[1].set('g','d',0.0,10,3.0,3.0);
- vars[2].set('r','v',112,10,3.0,3.0);
- vars[3].set('t','c',0.0,10,3.0,3.0);
+ vars[1].set('g','d',0.0,100,3.0,3.0);
+ vars[2].set('r','v',112,100,3.0,3.0);
+ vars[3].set('t','c',0.0,100,3.0,3.0);
vars[4].set('u','n',0.0,1.0,3.0,3.0);
vars[5].set('j','h',0.0,1.0,3.0,3.0);
- vars[6].set('o','l',1000.0,10,3.0,3.0);
+ vars[6].set('o','l',1000.0,200,3.0,3.0);
vars[7].set('q','a',0,0.0001,2.0,3.0);
- camera.setPosition(0,0,vars[6].getVal());
+ //camera.setPosition(0,0,vars[6].getVal());
}
//--------------------------------------------------------------
void viewpoint::setLight(){
@@ -37,10 +37,10 @@ void viewpoint::setLight(){
camera.setPosition(0,0,vars[6].getVal());
*/
- camera.orbit(vars[4].getVal(), vars[5].getVal(), vars[6].getVal(), target);
-
+ camera.orbit(vars[5].getVal(), vars[4].getVal(), vars[6].getVal(), target);
+ camera.lookAt(target,ofVec3f(0,1,0));
ofVec3f lp=camera.getGlobalPosition();
- GLfloat lightPosition[] = {lp.x, lp.y, lp.z};
+ GLfloat lightPosition[] = {lp.x, lp.y, lp.z,1};
GLfloat lightColour[] = {0.99, 0.99, 0.99, 0.5};
glLightfv(lightNum, GL_POSITION, lightPosition);
glLightfv(lightNum, GL_DIFFUSE, lightColour);
@@ -107,6 +107,10 @@ void viewpoint::end(){
unbindTexture(renderFBO);
ofPopMatrix();
+
+ //ofSetHexColor(0xFFFFFF);
+ //ofDrawBitmapString("camera: "+ofToString(camera.getX(), 2)+","+ofToString(camera.getY(), 2)+","+ofToString(camera.getZ(), 2), 10, ofGetHeight()-30);
+ //ofDrawBitmapString("light: "+ofToString(camera.getX(), 2)+","+ofToString(camera.getY(), 2)+","+ofToString(camera.getZ(), 2), 10, ofGetHeight()-30);
}
//--------------------------------------------------------------