new audio buffer display text, cleanup drawText()

This commit is contained in:
Philip Rosedale 2014-02-27 23:17:39 -08:00
parent 5f8c5d36da
commit bae16e24e8
5 changed files with 55 additions and 39 deletions

View file

@ -2469,6 +2469,8 @@ void Application::computeOffAxisFrustum(float& left, float& right, float& bottom
_viewFrustum.computeOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane);
}
const float WHITE_TEXT[] = { 0.93, 0.93, 0.93 };
void Application::displayOverlay() {
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "Application::displayOverlay()");
@ -2539,8 +2541,7 @@ void Application::displayOverlay() {
(Menu::getInstance()->isOptionChecked(MenuOption::Stats) &&
Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth))
? 80 : 20;
drawtext(_glWidget->width() - 100, _glWidget->height() - timerBottom, 0.30f, 0, 1.0f, 0, frameTimer, 0, 0, 0);
drawtext(_glWidget->width() - 102, _glWidget->height() - timerBottom - 2, 0.30f, 0, 1.0f, 0, frameTimer, 1, 1, 1);
drawText(_glWidget->width() - 100, _glWidget->height() - timerBottom, 0.30f, 1.0f, 0, frameTimer, WHITE_TEXT);
}
if (_pieMenu.isDisplayed()) {
@ -2568,6 +2569,7 @@ void Application::displayStatsBackground(unsigned int rgba, int x, int y, int wi
}
// display expanded or contracted stats
void Application::displayStats() {
unsigned int backgroundColor = 0x33333399;
int verticalOffset = 0, horizontalOffset = 0, lines = 0;
@ -2598,22 +2600,22 @@ void Application::displayStats() {
sprintf(framesPerSecond, "Framerate: %3.0f FPS", _fps);
verticalOffset += STATS_PELS_PER_LINE;
drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0f, 2, serverNodes, .93f, .93f, .93f);
drawText(horizontalOffset, verticalOffset, 0.10f, 0, 2, serverNodes, WHITE_TEXT);
verticalOffset += STATS_PELS_PER_LINE;
drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0f, 2, avatarNodes, .93f, .93f, .93f);
drawText(horizontalOffset, verticalOffset, 0.10f, 0, 2, avatarNodes, WHITE_TEXT);
verticalOffset += STATS_PELS_PER_LINE;
drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, framesPerSecond, .93f, .93f, .93f);
drawText(horizontalOffset, verticalOffset, 0.10f, 0, 2, framesPerSecond, WHITE_TEXT);
if (_statsExpanded) {
char packetsPerSecond[30];
sprintf(packetsPerSecond, "Pkts/sec: %d", _packetsPerSecond);
char averageMegabitsPerSecond[30];
sprintf(averageMegabitsPerSecond, "Avg Mbps: %3.2f", (float)_bytesPerSecond * 8.f / 1000000.f);
sprintf(averageMegabitsPerSecond, "Mbps: %3.2f", (float)_bytesPerSecond * 8.f / 1000000.f);
verticalOffset += STATS_PELS_PER_LINE;
drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, packetsPerSecond, .93f, .93f, .93f);
drawText(horizontalOffset, verticalOffset, 0.10f, 0, 2, packetsPerSecond, WHITE_TEXT);
verticalOffset += STATS_PELS_PER_LINE;
drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, averageMegabitsPerSecond, .93f, .93f, .93f);
drawText(horizontalOffset, verticalOffset, 0.10f, 0, 2, averageMegabitsPerSecond, WHITE_TEXT);
}
verticalOffset = 0;
@ -2651,26 +2653,36 @@ void Application::displayStats() {
displayStatsBackground(backgroundColor, horizontalOffset, 0, 175, lines * STATS_PELS_PER_LINE + 10);
horizontalOffset += 5;
char audioJitter[30];
sprintf(audioJitter,
"Buffer msecs %.1f",
(float) (_audio.getNetworkBufferLengthSamplesPerChannel() + (float) _audio.getJitterBufferSamples()) /
(float)_audio.getNetworkSampleRate() * 1000.f);
drawText(30, _glWidget->height() - 22, 0.10f, 0, 2, audioJitter, WHITE_TEXT);
char audioPing[30];
sprintf(audioPing, "Audio ping: %d", pingAudio);
char avatarPing[30];
sprintf(avatarPing, "Avatar ping: %d", pingAvatar);
char voxelAvgPing[30];
sprintf(voxelAvgPing, "Voxel avg ping: %d", pingVoxel);
verticalOffset += STATS_PELS_PER_LINE;
drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, audioPing, .93f, .93f, .93f);
drawText(horizontalOffset, verticalOffset, 0.10f, 0, 2, audioPing, WHITE_TEXT);
verticalOffset += STATS_PELS_PER_LINE;
drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, avatarPing, .93f, .93f, .93f);
drawText(horizontalOffset, verticalOffset, 0.10f, 0, 2, avatarPing, WHITE_TEXT);
verticalOffset += STATS_PELS_PER_LINE;
drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, voxelAvgPing, .93f, .93f, .93f);
drawText(horizontalOffset, verticalOffset, 0.10f, 0, 2, voxelAvgPing, WHITE_TEXT);
if (_statsExpanded) {
char voxelMaxPing[30];
sprintf(voxelMaxPing, "Voxel max ping: %d", pingVoxelMax);
verticalOffset += STATS_PELS_PER_LINE;
drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, voxelMaxPing, .93f, .93f, .93f);
drawText(horizontalOffset, verticalOffset, 0.10f, 0, 2, voxelMaxPing, WHITE_TEXT);
}
verticalOffset = 0;
@ -2689,20 +2701,20 @@ void Application::displayStats() {
sprintf(avatarPosition, "Pos: %.0f,%.0f,%.0f", avatarPos.x, avatarPos.y, avatarPos.z);
} else {
// longhand way
sprintf(avatarPosition, "Position: %.3f, %.3f, %.3f", avatarPos.x, avatarPos.y, avatarPos.z);
sprintf(avatarPosition, "Position: %.1f, %.1f, %.1f", avatarPos.x, avatarPos.y, avatarPos.z);
}
char avatarVelocity[30];
sprintf(avatarVelocity, "Velocity: %.1f", glm::length(_myAvatar->getVelocity()));
char avatarBodyYaw[30];
sprintf(avatarBodyYaw, "Yaw: %.2f", _myAvatar->getBodyYaw());
sprintf(avatarBodyYaw, "Yaw: %.1f", _myAvatar->getBodyYaw());
char avatarMixerStats[200];
verticalOffset += STATS_PELS_PER_LINE;
drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, avatarPosition, .93f, .93f, .93f);
drawText(horizontalOffset, verticalOffset, 0.10f, 0, 2, avatarPosition, WHITE_TEXT);
verticalOffset += STATS_PELS_PER_LINE;
drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, avatarVelocity, .93f, .93f, .93f);
drawText(horizontalOffset, verticalOffset, 0.10f, 0, 2, avatarVelocity, WHITE_TEXT);
verticalOffset += STATS_PELS_PER_LINE;
drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, avatarBodyYaw, .93f, .93f, .93f);
drawText(horizontalOffset, verticalOffset, 0.10f, 0, 2, avatarBodyYaw, WHITE_TEXT);
if (_statsExpanded) {
SharedNodePointer avatarMixer = NodeList::getInstance()->soloNodeOfType(NodeType::AvatarMixer);
@ -2715,7 +2727,7 @@ void Application::displayStats() {
}
verticalOffset += STATS_PELS_PER_LINE;
drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, avatarMixerStats, .93f, .93f, .93f);
drawText(horizontalOffset, verticalOffset, 0.10f, 0, 2, avatarMixerStats, WHITE_TEXT);
}
verticalOffset = 0;
@ -2730,7 +2742,7 @@ void Application::displayStats() {
voxelStats.str("");
voxelStats << "Voxels Memory Nodes: " << VoxelTreeElement::getTotalMemoryUsage() / 1000000.f << "MB";
verticalOffset += STATS_PELS_PER_LINE;
drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, (char*)voxelStats.str().c_str(), .93f, .93f, .93f);
drawText(horizontalOffset, verticalOffset, 0.10f, 0, 2, (char*)voxelStats.str().c_str(), WHITE_TEXT);
voxelStats.str("");
voxelStats <<
@ -2740,14 +2752,14 @@ void Application::displayStats() {
voxelStats << " / GPU: " << _voxels.getVoxelMemoryUsageGPU() / 1000000.f << "MB";
}
verticalOffset += STATS_PELS_PER_LINE;
drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, (char*)voxelStats.str().c_str(), .93f, .93f, .93f);
drawText(horizontalOffset, verticalOffset, 0.10f, 0, 2, (char*)voxelStats.str().c_str(), WHITE_TEXT);
// Voxel Rendering
voxelStats.str("");
voxelStats.precision(4);
voxelStats << "Voxel Rendering Slots Max: " << _voxels.getMaxVoxels() / 1000.f << "K";
verticalOffset += STATS_PELS_PER_LINE;
drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, (char*)voxelStats.str().c_str(), .93f, .93f, .93f);
drawText(horizontalOffset, verticalOffset, 0.10f, 0, 2, (char*)voxelStats.str().c_str(), WHITE_TEXT);
}
voxelStats.str("");
@ -2755,7 +2767,7 @@ void Application::displayStats() {
voxelStats << "Drawn: " << _voxels.getVoxelsWritten() / 1000.f << "K " <<
"Abandoned: " << _voxels.getAbandonedVoxels() / 1000.f << "K ";
verticalOffset += STATS_PELS_PER_LINE;
drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, (char*)voxelStats.str().c_str(), .93f, .93f, .93f);
drawText(horizontalOffset, verticalOffset, 0.10f, 0, 2, (char*)voxelStats.str().c_str(), WHITE_TEXT);
// iterate all the current voxel stats, and list their sending modes, and total voxel counts
std::stringstream sendingMode("");
@ -2799,7 +2811,7 @@ void Application::displayStats() {
sendingMode << " <SCENE STABLE>";
}
verticalOffset += STATS_PELS_PER_LINE;
drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, (char*)sendingMode.str().c_str(), .93f, .93f, .93f);
drawText(horizontalOffset, verticalOffset, 0.10f, 0, 2, (char*)sendingMode.str().c_str(), WHITE_TEXT);
}
// Incoming packets
@ -2811,7 +2823,7 @@ void Application::displayStats() {
voxelStats << "Voxel Packets to Process: " << packetsString.toLocal8Bit().constData()
<< " [Recent Max: " << maxString.toLocal8Bit().constData() << "]";
verticalOffset += STATS_PELS_PER_LINE;
drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, (char*)voxelStats.str().c_str(), .93f, .93f, .93f);
drawText(horizontalOffset, verticalOffset, 0.10f, 0, 2, (char*)voxelStats.str().c_str(), WHITE_TEXT);
}
if (_resetRecentMaxPacketsSoon && voxelPacketsToProcess > 0) {
@ -2834,7 +2846,7 @@ void Application::displayStats() {
voxelStats.str("");
voxelStats << "Server voxels: " << serversTotalString.toLocal8Bit().constData();
verticalOffset += STATS_PELS_PER_LINE;
drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, (char*)voxelStats.str().c_str(), .93f, .93f, .93f);
drawText(horizontalOffset, verticalOffset, 0.10f, 0, 2, (char*)voxelStats.str().c_str(), WHITE_TEXT);
if (_statsExpanded) {
QString serversInternalString = locale.toString((uint)totalInternal);
@ -2845,7 +2857,7 @@ void Application::displayStats() {
"Internal: " << serversInternalString.toLocal8Bit().constData() << " " <<
"Leaves: " << serversLeavesString.toLocal8Bit().constData() << "";
verticalOffset += STATS_PELS_PER_LINE;
drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, (char*)voxelStats.str().c_str(), .93f, .93f, .93f);
drawText(horizontalOffset, verticalOffset, 0.10f, 0, 2, (char*)voxelStats.str().c_str(), WHITE_TEXT);
}
unsigned long localTotal = VoxelTreeElement::getNodeCount();
@ -2855,7 +2867,7 @@ void Application::displayStats() {
voxelStats.str("");
voxelStats << "Local voxels: " << localTotalString.toLocal8Bit().constData();
verticalOffset += STATS_PELS_PER_LINE;
drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, (char*)voxelStats.str().c_str(), .93f, .93f, .93f);
drawText(horizontalOffset, verticalOffset, 0.10f, 0, 2, (char*)voxelStats.str().c_str(), WHITE_TEXT);
if (_statsExpanded) {
unsigned long localInternal = VoxelTreeElement::getInternalNodeCount();
@ -2868,7 +2880,7 @@ void Application::displayStats() {
"Internal: " << localInternalString.toLocal8Bit().constData() << " " <<
"Leaves: " << localLeavesString.toLocal8Bit().constData() << "";
verticalOffset += STATS_PELS_PER_LINE;
drawtext(horizontalOffset, verticalOffset, 0.10f, 0, 1.0, 2, (char*)voxelStats.str().c_str(), .93f, .93f, .93f);
drawText(horizontalOffset, verticalOffset, 0.10f, 0, 2, (char*)voxelStats.str().c_str(), WHITE_TEXT);
}
}

View file

@ -70,6 +70,9 @@ public:
void renderMuteIcon(int x, int y);
int getNetworkSampleRate() { return SAMPLE_RATE; }
int getNetworkBufferLengthSamplesPerChannel() { return NETWORK_BUFFER_LENGTH_SAMPLES_PER_CHANNEL; }
public slots:
void start();
void addReceivedAudioToBuffer(const QByteArray& audioByteArray);

View file

@ -314,24 +314,21 @@ float widthChar(float scale, int mono, char ch) {
return textRenderer(mono)->computeWidth(ch) * (scale / 0.10);
}
void drawtext(int x, int y, float scale, float rotate, float thick, int mono,
char const* string, float r, float g, float b) {
void drawText(int x, int y, float scale, float rotate, int mono,
char const* string, const float* color) {
//
// Draws text on screen as stroked so it can be resized
//
glPushMatrix();
glTranslatef(static_cast<float>(x), static_cast<float>(y), 0.0f);
glColor3f(r,g,b);
glColor3fv(color);
glRotated(rotate,0,0,1);
// glLineWidth(thick);
glScalef(scale / 0.10, scale / 0.10, 1.0);
textRenderer(mono)->draw(0, 0, string);
glPopMatrix();
}
void drawvec3(int x, int y, float scale, float rotate, float thick, int mono, glm::vec3 vec, float r, float g, float b) {
//
// Draws text on screen as stroked so it can be resized

View file

@ -30,8 +30,10 @@ const glm::vec3 randVector();
void renderWorldBox();
int widthText(float scale, int mono, char const* string);
float widthChar(float scale, int mono, char ch);
void drawtext(int x, int y, float scale, float rotate, float thick, int mono,
char const* string, float r=1.0, float g=1.0, float b=1.0);
void drawText(int x, int y, float scale, float rotate, int mono,
char const* string, const float* color);
void drawvec3(int x, int y, float scale, float rotate, float thick, int mono, glm::vec3 vec,
float r=1.0, float g=1.0, float b=1.0);

View file

@ -73,6 +73,8 @@ bool ChatEntry::keyPressEvent(QKeyEvent* event) {
}
}
const float ALL_WHITE[] = { 1.0f, 1.0f, 1.0f };
void ChatEntry::render(int screenWidth, int screenHeight) {
// draw a gray background so that we can actually see what we're typing
int bottom = screenHeight - 150, top = screenHeight - 165;
@ -85,8 +87,8 @@ void ChatEntry::render(int screenWidth, int screenHeight) {
glVertex2f(right + 5, top - 3);
glVertex2f(left - 5, top - 3);
glEnd();
drawtext(left, bottom, 0.10f, 0, 1.0f, 0, _contents.c_str(), 1, 1, 1);
drawText(left, bottom, 0.10f, 0, 2, _contents.c_str(), ALL_WHITE);
float width = 0;
for (string::iterator it = _contents.begin(), end = it + _cursorPos; it != end; it++) {