~mordred/+junk/ofxShowDriver

« back to all changes in this revision

Viewing changes to src/testApp.cpp

  • Committer: Monty Taylor
  • Date: 2010-12-05 01:40:55 UTC
  • Revision ID: mordred@inaugust.com-20101205014055-rhw9f4gie3efp0nb
Drive the other bit remotely.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
#include <iostream>
4
4
 
5
 
static size_t current_image= 0;
6
 
static size_t next_image= 0;
7
 
static size_t current_pos= 0;
8
 
static size_t y_pos= 100;
9
 
 
10
 
static const char *imgs[]= {
11
 
  "images/1.jpg",
12
 
  "images/2.jpg",
13
 
  "images/3.jpg"
14
 
};
15
 
 
16
 
/* 0 = whizArtBang 
17
 
  1 = Satori
18
 
  2 = pictures
19
 
*/
20
 
static int state= 0;
 
5
 
21
6
 
22
7
//--------------------------------------------------------------
23
8
void testApp::setup(){
24
9
 
25
 
  ofSetFullscreen(true);
26
 
  screenW= 1400;
27
 
  screenH= 1050;
28
 
//  screenW= ofGetScreenWidth(); screenH= ofGetScreenHeight();
29
 
 
30
 
  satori.loadImage("images/SatoriLogo.jpg");
31
 
  wab.loadImage("images/whizArtbangLogo.jpg");
32
 
  wab.resize(screenW, screenH-y_pos);
33
 
  std::cout << screenW << ":" << screenH << std::endl;
34
 
 
35
 
  for (size_t x= 0; imgs[x]; ++x)
36
 
  {
37
 
    std::cout << "Loading image " << x << ":" << imgs[x] << std::endl;
38
 
    boost::shared_ptr<ofImage>img(new ofImage);
39
 
    img->loadImage(imgs[x]);
40
 
    img->resize(screenW, screenH-y_pos);
41
 
    images.push_back(img);
42
 
  }
 
10
  ofBackground( 40, 100, 40 );
 
11
 
 
12
  // open an outgoing connection to HOST:PORT
 
13
  sender.setup( "localhost", PORT );
43
14
 
44
15
}
45
16
 
46
17
//--------------------------------------------------------------
47
18
void testApp::update(){
48
 
  if (state == 1) {
49
 
    ofBackground(255,255,255);
50
 
  } else {
51
 
    ofBackground(0,0,0);
52
 
  }
53
19
}
54
20
 
55
21
//--------------------------------------------------------------
56
22
void testApp::draw(){
57
23
 
58
 
  if (state == 0)
59
 
  {
60
 
    wab.draw(0,100);
61
 
  }
62
 
  else if (state == 1)
63
 
  {
64
 
    satori.draw(200,400);
65
 
  }
66
 
  else if (state == 2)
67
 
  {
68
 
    if (current_image == next_image)
69
 
    {
70
 
      current_pos= 0;
71
 
      images[current_image]->draw(current_pos, y_pos);
72
 
    }
73
 
    else
74
 
    {
75
 
      current_pos+=5;
76
 
      images[next_image]->setAnchorPoint(screenW-current_pos, 0);
77
 
      images[current_image]->draw(current_pos, y_pos);
78
 
      images[next_image]->draw(0, y_pos);
79
 
 
80
 
      if (current_pos == screenW)
81
 
      {
82
 
        current_image = next_image;
83
 
        images[current_image]->resetAnchor();
84
 
      }
85
 
    }
86
 
  }
87
24
}
88
25
 
89
26
//--------------------------------------------------------------
90
27
void testApp::keyPressed(int key){
91
28
 
92
29
  if (key == 'w')
93
 
    state= 0;
 
30
  {
 
31
    ofxOscMessage m;
 
32
    m.setAddress( "/wab/wab" );
 
33
    sender.sendMessage(m);
 
34
  }
94
35
  if (key == 's')
95
 
    state= 1;
 
36
  {
 
37
    ofxOscMessage m;
 
38
    m.setAddress( "/wab/satori" );
 
39
    sender.sendMessage(m);
 
40
  }
 
41
 
96
42
  if (key == 'p')
97
 
    state= 2;
98
 
 
99
 
  if (state == 2)
100
 
  {
101
 
    if (key == ' ')
102
 
    {
103
 
      if (current_image == next_image && next_image != images.size()-1)
104
 
      {
105
 
        next_image++;
106
 
      }
107
 
    }
108
 
  }
 
43
  {
 
44
    ofxOscMessage m;
 
45
    m.setAddress( "/wab/pictures" );
 
46
    sender.sendMessage(m);
 
47
  }
 
48
 
 
49
  if (key == ' ')
 
50
  {
 
51
    ofxOscMessage m;
 
52
    m.setAddress( "/wab/advance" );
 
53
    sender.sendMessage(m);
 
54
  }
 
55
 
 
56
  if (key == 'b')
 
57
  {
 
58
    ofxOscMessage m;
 
59
    m.setAddress( "/wab/black" );
 
60
    sender.sendMessage(m);
 
61
  }
 
62
 
109
63
}
110
64
 
111
65
//--------------------------------------------------------------