Mercurial > hg > beaglert
comparison projects/tank_wars/render.cpp @ 14:06f93bef7dd2
Updated remaining examples to new API
author | andrewm |
---|---|
date | Fri, 23 Jan 2015 15:35:10 +0000 |
parents | 49f22e1246b2 |
children | fbfeb5895efd |
comparison
equal
deleted
inserted
replaced
13:6adb088196a7 | 14:06f93bef7dd2 |
---|---|
11 #include "game.h" | 11 #include "game.h" |
12 #include <rtdk.h> | 12 #include <rtdk.h> |
13 #include <cmath> | 13 #include <cmath> |
14 #include <cstdlib> | 14 #include <cstdlib> |
15 #include <time.h> | 15 #include <time.h> |
16 | |
17 float gFrequency; | |
18 float gPhase; | |
19 float gInverseSampleRate; | |
20 int gNumChannels; | |
21 | 16 |
22 int gInputTank1Angle = 0; // Inputs for the cannon angles | 17 int gInputTank1Angle = 0; // Inputs for the cannon angles |
23 int gInputTank2Angle = 1; | 18 int gInputTank2Angle = 1; |
24 int gInputLauncher = 2; // Input for launcher FSR | 19 int gInputLauncher = 2; // Input for launcher FSR |
25 | 20 |
75 // userData holds an opaque pointer to a data structure that was passed | 70 // userData holds an opaque pointer to a data structure that was passed |
76 // in from the call to initAudio(). | 71 // in from the call to initAudio(). |
77 // | 72 // |
78 // Return true on success; returning false halts the program. | 73 // Return true on success; returning false halts the program. |
79 | 74 |
80 bool initialise_render(int numChannels, int numMatrixFramesPerPeriod, | 75 bool initialise_render(int numMatrixChannels, int numAudioChannels, |
81 int numAudioFramesPerPeriod, float matrixSampleRate, | 76 int numMatrixFramesPerPeriod, |
82 float audioSampleRate, void *userData) | 77 int numAudioFramesPerPeriod, |
78 float matrixSampleRate, float audioSampleRate, | |
79 void *userData) | |
83 { | 80 { |
84 srandom(time(NULL)); | 81 srandom(time(NULL)); |
85 | 82 |
86 // Verify we are running with matrix enabled | 83 // Verify we are running with matrix enabled |
87 if(numMatrixFramesPerPeriod*2 != numAudioFramesPerPeriod) { | 84 if(numMatrixFramesPerPeriod == 0 || numMatrixChannels < 4) { |
88 rt_printf("Error: this example needs the matrix enabled, running at half audio rate\n"); | 85 rt_printf("Error: this example needs the matrix enabled with at least 4 channels\n"); |
89 return false; | 86 return false; |
90 } | 87 } |
91 | 88 |
92 // Initialise the screen buffers | 89 // Initialise the screen buffers |
93 gScreenBufferMaxLength = 2 * matrixSampleRate / gScreenFramesPerSecond; | 90 gScreenBufferMaxLength = 2 * matrixSampleRate / gScreenFramesPerSecond; |