mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-07 10:52:37 +02:00
Fixed test target dependencies (which were not getting added into the *-tests build targets)
This commit is contained in:
parent
0cc940d433
commit
d75f3b1398
17 changed files with 50 additions and 1290 deletions
|
@ -133,6 +133,9 @@ if (APPLE)
|
|||
set(CMAKE_OSX_SYSROOT ${_OSX_DESIRED_SDK_PATH}/MacOSX10.9.sdk)
|
||||
endif ()
|
||||
|
||||
# Hide automoc folders (for IDEs)
|
||||
set(AUTOGEN_TARGETS_FOLDER "hidden/generated") # Apparently this doesn't work... -.-
|
||||
|
||||
# Find includes in corresponding build directories
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
# Instruct CMake to run moc automatically when needed.
|
||||
|
|
|
@ -1,10 +1,30 @@
|
|||
|
||||
# Turn on testing (so that add_test works)
|
||||
enable_testing()
|
||||
|
||||
# add the test directories
|
||||
file(GLOB TEST_SUBDIRS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/*")
|
||||
list(REMOVE_ITEM TEST_SUBDIRS "CMakeFiles")
|
||||
foreach(DIR ${TEST_SUBDIRS})
|
||||
if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${DIR}")
|
||||
set(TEST_PROJ_NAME ${DIR})
|
||||
message(STATUS "Adding " ${DIR})
|
||||
add_subdirectory(${DIR})
|
||||
endif()
|
||||
endforeach()
|
||||
add_subdirectory(${DIR}) # link in the subdir (this reinvokes cmake on the cmakelists.txt file, with its
|
||||
endif() # own variable scope copied from this scope (the parent scope)).
|
||||
endforeach()
|
||||
|
||||
# Create the all-tests build target.
|
||||
# The dependency list (ALL_TEST_TARGETS) is generated from setup_hifi_testcase invocations in the CMakeLists.txt
|
||||
# files in the test subdirs. Since variables normally do *not* persist into parent scope, we use a hack:
|
||||
#
|
||||
# list(APPEND ALL_TEST_TARGETS ${targets_to_add...}) # appends to a local list var (copied from parent scope)
|
||||
# set (ALL_TEST_TARGETS "${ALL_TEST_TARGETS}" PARENT_SCOPE) # copies this back to parent scope
|
||||
#
|
||||
add_custom_target("all-tests" ALL
|
||||
COMMAND ctest .
|
||||
SOURCES ""
|
||||
DEPENDS "${ALL_TEST_TARGETS}")
|
||||
set_target_properties("all-tests" PROPERTIES FOLDER "hidden/test-targets")
|
||||
|
||||
# Note: we also do some funky stuff with macros (SETUP_TESTCASE_DEPENDENCIES is redefined in *each* CMakeLists.txt
|
||||
# file, and then invoked in SetupHifiTestCase.cmake) -- which is necessary since the dependencies must be re-linked
|
||||
# for each target (instead of just one)
|
|
@ -1,4 +1,4 @@
|
|||
//
|
||||
//
|
||||
// AudioRingBufferTests.cpp
|
||||
// tests/audio/src
|
||||
//
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
//
|
||||
// main.cpp
|
||||
// tests/audio/src
|
||||
//
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include "AudioRingBufferTests.h"
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
AudioRingBufferTests::runAllTests();
|
||||
printf("all tests passed. press enter to exit\n");
|
||||
getchar();
|
||||
return 0;
|
||||
}
|
|
@ -1,377 +0,0 @@
|
|||
//
|
||||
// main.cpp
|
||||
// JitterTester
|
||||
//
|
||||
// Created by Philip on 8/1/14.
|
||||
// Copyright (c) 2014 High Fidelity, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
#ifdef _WINDOWS
|
||||
#include <WS2tcpip.h>
|
||||
#else
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
#include <cerrno>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <NumericalConstants.h>
|
||||
#include <MovingMinMaxAvg.h>
|
||||
#include <SequenceNumberStats.h>
|
||||
#include <SharedUtil.h> // for usecTimestampNow
|
||||
#include <SimpleMovingAverage.h>
|
||||
#include <StDev.h>
|
||||
|
||||
const quint64 MSEC_TO_USEC = 1000;
|
||||
const quint64 LARGE_STATS_TIME = 500; // we don't expect stats calculation to take more than this many usecs
|
||||
|
||||
void runSend(const char* addressOption, int port, int gap, int size, int report);
|
||||
void runReceive(const char* addressOption, int port, int gap, int size, int report);
|
||||
|
||||
int main(int argc, const char * argv[]) {
|
||||
if (argc != 7) {
|
||||
printf("usage: jitter-tests <--send|--receive> <address> <port> <gap in usecs> <packet size> <report interval in msecs>\n");
|
||||
exit(1);
|
||||
}
|
||||
const char* typeOption = argv[1];
|
||||
const char* addressOption = argv[2];
|
||||
const char* portOption = argv[3];
|
||||
const char* gapOption = argv[4];
|
||||
const char* sizeOption = argv[5];
|
||||
const char* reportOption = argv[6];
|
||||
int port = atoi(portOption);
|
||||
int gap = atoi(gapOption);
|
||||
int size = atoi(sizeOption);
|
||||
int report = atoi(reportOption);
|
||||
|
||||
std::cout << "type:" << typeOption << "\n";
|
||||
std::cout << "address:" << addressOption << "\n";
|
||||
std::cout << "port:" << port << "\n";
|
||||
std::cout << "gap:" << gap << "\n";
|
||||
std::cout << "size:" << size << "\n";
|
||||
|
||||
if (strcmp(typeOption, "--send") == 0) {
|
||||
runSend(addressOption, port, gap, size, report);
|
||||
} else if (strcmp(typeOption, "--receive") == 0) {
|
||||
runReceive(addressOption, port, gap, size, report);
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void runSend(const char* addressOption, int port, int gap, int size, int report) {
|
||||
std::cout << "runSend...\n";
|
||||
|
||||
#ifdef _WIN32
|
||||
WSADATA wsaData;
|
||||
if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) {
|
||||
printf("WSAStartup failed with error %d\n", WSAGetLastError());
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
int sockfd;
|
||||
struct sockaddr_in servaddr;
|
||||
|
||||
sockfd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
|
||||
memset(&servaddr, 0, sizeof(servaddr));
|
||||
servaddr.sin_family = AF_INET;
|
||||
inet_pton(AF_INET, addressOption, &servaddr.sin_addr);
|
||||
servaddr.sin_port = htons(port);
|
||||
|
||||
const int SAMPLES_FOR_SECOND = 1000000 / gap;
|
||||
std::cout << "SAMPLES_FOR_SECOND:" << SAMPLES_FOR_SECOND << "\n";
|
||||
const int INTERVALS_PER_30_SECONDS = 30;
|
||||
std::cout << "INTERVALS_PER_30_SECONDS:" << INTERVALS_PER_30_SECONDS << "\n";
|
||||
const int SAMPLES_FOR_30_SECONDS = 30 * SAMPLES_FOR_SECOND;
|
||||
std::cout << "SAMPLES_FOR_30_SECONDS:" << SAMPLES_FOR_30_SECONDS << "\n";
|
||||
const int REPORTS_FOR_30_SECONDS = 30 * MSECS_PER_SECOND / report;
|
||||
std::cout << "REPORTS_FOR_30_SECONDS:" << REPORTS_FOR_30_SECONDS << "\n";
|
||||
|
||||
int intervalsPerReport = report / MSEC_TO_USEC;
|
||||
if (intervalsPerReport < 1) {
|
||||
intervalsPerReport = 1;
|
||||
}
|
||||
std::cout << "intervalsPerReport:" << intervalsPerReport << "\n";
|
||||
MovingMinMaxAvg<int> timeGaps(SAMPLES_FOR_SECOND, INTERVALS_PER_30_SECONDS);
|
||||
MovingMinMaxAvg<int> timeGapsPerReport(SAMPLES_FOR_SECOND, intervalsPerReport);
|
||||
|
||||
char* outputBuffer = new char[size];
|
||||
memset(outputBuffer, 0, size);
|
||||
|
||||
quint16 outgoingSequenceNumber = 0;
|
||||
|
||||
|
||||
StDev stDevReportInterval;
|
||||
StDev stDev30s;
|
||||
StDev stDev;
|
||||
|
||||
SimpleMovingAverage averageNetworkTime(SAMPLES_FOR_30_SECONDS);
|
||||
SimpleMovingAverage averageStatsCalcultionTime(SAMPLES_FOR_30_SECONDS);
|
||||
float lastStatsCalculationTime = 0.0f; // we add out stats calculation time in the next calculation window
|
||||
bool hasStatsCalculationTime = false;
|
||||
|
||||
quint64 last = usecTimestampNow();
|
||||
quint64 lastReport = 0;
|
||||
|
||||
while (true) {
|
||||
|
||||
quint64 now = usecTimestampNow();
|
||||
int actualGap = now - last;
|
||||
|
||||
|
||||
if (actualGap >= gap) {
|
||||
|
||||
// pack seq num
|
||||
memcpy(outputBuffer, &outgoingSequenceNumber, sizeof(quint16));
|
||||
|
||||
quint64 networkStart = usecTimestampNow();
|
||||
int n = sendto(sockfd, outputBuffer, size, 0, (struct sockaddr *)&servaddr, sizeof(servaddr));
|
||||
quint64 networkEnd = usecTimestampNow();
|
||||
float networkElapsed = (float)(networkEnd - networkStart);
|
||||
|
||||
if (n < 0) {
|
||||
std::cout << "Send error: " << strerror(errno) << "\n";
|
||||
}
|
||||
outgoingSequenceNumber++;
|
||||
|
||||
quint64 statsCalcultionStart = usecTimestampNow();
|
||||
|
||||
int gapDifferece = actualGap - gap;
|
||||
|
||||
timeGaps.update(gapDifferece);
|
||||
timeGapsPerReport.update(gapDifferece);
|
||||
stDev.addValue(gapDifferece);
|
||||
stDev30s.addValue(gapDifferece);
|
||||
stDevReportInterval.addValue(gapDifferece);
|
||||
last = now;
|
||||
|
||||
// track out network time and stats calculation times
|
||||
averageNetworkTime.updateAverage(networkElapsed);
|
||||
|
||||
// for our stats calculation time, we actually delay the updating by one sample.
|
||||
// we do this so that the calculation of the average timing for the stats calculation
|
||||
// happen inside of the calculation processing. This ensures that tracking stats on
|
||||
// stats calculation doesn't side effect the remaining running time.
|
||||
if (hasStatsCalculationTime) {
|
||||
averageStatsCalcultionTime.updateAverage(lastStatsCalculationTime);
|
||||
}
|
||||
|
||||
if (now - lastReport >= (report * MSEC_TO_USEC)) {
|
||||
|
||||
std::cout << "\n"
|
||||
<< "SEND gap Difference From Expected\n"
|
||||
<< "Overall:\n"
|
||||
<< "min: " << timeGaps.getMin() << " usecs, "
|
||||
<< "max: " << timeGaps.getMax() << " usecs, "
|
||||
<< "avg: " << timeGaps.getAverage() << " usecs, "
|
||||
<< "stdev: " << stDev.getStDev() << " usecs\n"
|
||||
<< "Last 30s:\n"
|
||||
<< "min: " << timeGaps.getWindowMin() << " usecs, "
|
||||
<< "max: " << timeGaps.getWindowMax() << " usecs, "
|
||||
<< "avg: " << timeGaps.getWindowAverage() << " usecs, "
|
||||
<< "stdev: " << stDev30s.getStDev() << " usecs\n"
|
||||
<< "Last report interval:\n"
|
||||
<< "min: " << timeGapsPerReport.getWindowMin() << " usecs, "
|
||||
<< "max: " << timeGapsPerReport.getWindowMax() << " usecs, "
|
||||
<< "avg: " << timeGapsPerReport.getWindowAverage() << " usecs, "
|
||||
<< "stdev: " << stDevReportInterval.getStDev() << " usecs\n"
|
||||
<< "Average Execution Times Last 30s:\n"
|
||||
<< " network: " << averageNetworkTime.getAverage() << " usecs average\n"
|
||||
<< " stats: " << averageStatsCalcultionTime.getAverage() << " usecs average"
|
||||
<< "\n";
|
||||
|
||||
stDevReportInterval.reset();
|
||||
if (stDev30s.getSamples() > SAMPLES_FOR_30_SECONDS) {
|
||||
stDev30s.reset();
|
||||
}
|
||||
|
||||
lastReport = now;
|
||||
}
|
||||
|
||||
quint64 statsCalcultionEnd = usecTimestampNow();
|
||||
lastStatsCalculationTime = (float)(statsCalcultionEnd - statsCalcultionStart);
|
||||
if (lastStatsCalculationTime > LARGE_STATS_TIME) {
|
||||
qDebug() << "WARNING -- unexpectedly large lastStatsCalculationTime=" << lastStatsCalculationTime;
|
||||
}
|
||||
hasStatsCalculationTime = true;
|
||||
|
||||
}
|
||||
}
|
||||
delete[] outputBuffer;
|
||||
|
||||
#ifdef _WIN32
|
||||
WSACleanup();
|
||||
#endif
|
||||
}
|
||||
|
||||
void runReceive(const char* addressOption, int port, int gap, int size, int report) {
|
||||
std::cout << "runReceive...\n";
|
||||
|
||||
#ifdef _WIN32
|
||||
WSADATA wsaData;
|
||||
if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) {
|
||||
printf("WSAStartup failed with error %d\n", WSAGetLastError());
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
int sockfd, n;
|
||||
struct sockaddr_in myaddr;
|
||||
|
||||
sockfd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
|
||||
memset(&myaddr, 0, sizeof(myaddr));
|
||||
myaddr.sin_family = AF_INET;
|
||||
myaddr.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
myaddr.sin_port = htons(port);
|
||||
|
||||
|
||||
const int SAMPLES_FOR_SECOND = 1000000 / gap;
|
||||
std::cout << "SAMPLES_FOR_SECOND:" << SAMPLES_FOR_SECOND << "\n";
|
||||
const int INTERVALS_PER_30_SECONDS = 30;
|
||||
std::cout << "INTERVALS_PER_30_SECONDS:" << INTERVALS_PER_30_SECONDS << "\n";
|
||||
const int SAMPLES_FOR_30_SECONDS = 30 * SAMPLES_FOR_SECOND;
|
||||
std::cout << "SAMPLES_FOR_30_SECONDS:" << SAMPLES_FOR_30_SECONDS << "\n";
|
||||
const int REPORTS_FOR_30_SECONDS = 30 * MSECS_PER_SECOND / report;
|
||||
std::cout << "REPORTS_FOR_30_SECONDS:" << REPORTS_FOR_30_SECONDS << "\n";
|
||||
|
||||
int intervalsPerReport = report / MSEC_TO_USEC;
|
||||
if (intervalsPerReport < 1) {
|
||||
intervalsPerReport = 1;
|
||||
}
|
||||
std::cout << "intervalsPerReport:" << intervalsPerReport << "\n";
|
||||
MovingMinMaxAvg<int> timeGaps(SAMPLES_FOR_SECOND, INTERVALS_PER_30_SECONDS);
|
||||
MovingMinMaxAvg<int> timeGapsPerReport(SAMPLES_FOR_SECOND, intervalsPerReport);
|
||||
|
||||
char* inputBuffer = new char[size];
|
||||
memset(inputBuffer, 0, size);
|
||||
|
||||
|
||||
SequenceNumberStats seqStats(REPORTS_FOR_30_SECONDS);
|
||||
|
||||
StDev stDevReportInterval;
|
||||
StDev stDev30s;
|
||||
StDev stDev;
|
||||
|
||||
SimpleMovingAverage averageNetworkTime(SAMPLES_FOR_30_SECONDS);
|
||||
SimpleMovingAverage averageStatsCalcultionTime(SAMPLES_FOR_30_SECONDS);
|
||||
float lastStatsCalculationTime = 0.0f; // we add out stats calculation time in the next calculation window
|
||||
bool hasStatsCalculationTime = false;
|
||||
|
||||
if (bind(sockfd, (struct sockaddr *)&myaddr, sizeof(myaddr)) < 0) {
|
||||
std::cout << "bind failed\n";
|
||||
return;
|
||||
}
|
||||
|
||||
quint64 last = 0; // first case
|
||||
quint64 lastReport = 0;
|
||||
|
||||
while (true) {
|
||||
|
||||
quint64 networkStart = usecTimestampNow();
|
||||
n = recvfrom(sockfd, inputBuffer, size, 0, NULL, NULL); // we don't care about where it came from
|
||||
|
||||
quint64 networkEnd = usecTimestampNow();
|
||||
float networkElapsed = (float)(networkEnd - networkStart);
|
||||
|
||||
if (n < 0) {
|
||||
std::cout << "Receive error: " << strerror(errno) << "\n";
|
||||
}
|
||||
|
||||
// parse seq num
|
||||
quint16 incomingSequenceNumber = *(reinterpret_cast<quint16*>(inputBuffer));
|
||||
seqStats.sequenceNumberReceived(incomingSequenceNumber);
|
||||
|
||||
if (last == 0) {
|
||||
last = usecTimestampNow();
|
||||
std::cout << "first packet received\n";
|
||||
} else {
|
||||
|
||||
quint64 statsCalcultionStart = usecTimestampNow();
|
||||
quint64 now = usecTimestampNow();
|
||||
int actualGap = now - last;
|
||||
|
||||
int gapDifferece = actualGap - gap;
|
||||
timeGaps.update(gapDifferece);
|
||||
timeGapsPerReport.update(gapDifferece);
|
||||
stDev.addValue(gapDifferece);
|
||||
stDev30s.addValue(gapDifferece);
|
||||
stDevReportInterval.addValue(gapDifferece);
|
||||
last = now;
|
||||
|
||||
// track out network time and stats calculation times
|
||||
averageNetworkTime.updateAverage(networkElapsed);
|
||||
|
||||
// for our stats calculation time, we actually delay the updating by one sample.
|
||||
// we do this so that the calculation of the average timing for the stats calculation
|
||||
// happen inside of the calculation processing. This ensures that tracking stats on
|
||||
// stats calculation doesn't side effect the remaining running time.
|
||||
if (hasStatsCalculationTime) {
|
||||
averageStatsCalcultionTime.updateAverage(lastStatsCalculationTime);
|
||||
}
|
||||
|
||||
if (now - lastReport >= (report * MSEC_TO_USEC)) {
|
||||
|
||||
seqStats.pushStatsToHistory();
|
||||
|
||||
std::cout << "RECEIVE gap Difference From Expected\n"
|
||||
<< "Overall:\n"
|
||||
<< "min: " << timeGaps.getMin() << " usecs, "
|
||||
<< "max: " << timeGaps.getMax() << " usecs, "
|
||||
<< "avg: " << timeGaps.getAverage() << " usecs, "
|
||||
<< "stdev: " << stDev.getStDev() << " usecs\n"
|
||||
<< "Last 30s:\n"
|
||||
<< "min: " << timeGaps.getWindowMin() << " usecs, "
|
||||
<< "max: " << timeGaps.getWindowMax() << " usecs, "
|
||||
<< "avg: " << timeGaps.getWindowAverage() << " usecs, "
|
||||
<< "stdev: " << stDev30s.getStDev() << " usecs\n"
|
||||
<< "Last report interval:\n"
|
||||
<< "min: " << timeGapsPerReport.getWindowMin() << " usecs, "
|
||||
<< "max: " << timeGapsPerReport.getWindowMax() << " usecs, "
|
||||
<< "avg: " << timeGapsPerReport.getWindowAverage() << " usecs, "
|
||||
<< "stdev: " << stDevReportInterval.getStDev() << " usecs\n"
|
||||
<< "Average Execution Times Last 30s:\n"
|
||||
<< " network: " << averageNetworkTime.getAverage() << " usecs average\n"
|
||||
<< " stats: " << averageStatsCalcultionTime.getAverage() << " usecs average"
|
||||
<< "\n";
|
||||
stDevReportInterval.reset();
|
||||
|
||||
if (stDev30s.getSamples() > SAMPLES_FOR_30_SECONDS) {
|
||||
stDev30s.reset();
|
||||
}
|
||||
|
||||
PacketStreamStats packetStatsLast30s = seqStats.getStatsForHistoryWindow();
|
||||
PacketStreamStats packetStatsLastReportInterval = seqStats.getStatsForLastHistoryInterval();
|
||||
|
||||
std::cout << "RECEIVE Packet Stats\n"
|
||||
<< "Overall:\n"
|
||||
<< "lost: " << seqStats.getLost() << ", "
|
||||
<< "lost %: " << seqStats.getStats().getLostRate() * 100.0f << "%\n"
|
||||
<< "Last 30s:\n"
|
||||
<< "lost: " << packetStatsLast30s._lost << ", "
|
||||
<< "lost %: " << packetStatsLast30s.getLostRate() * 100.0f << "%\n"
|
||||
<< "Last report interval:\n"
|
||||
<< "lost: " << packetStatsLastReportInterval._lost << ", "
|
||||
<< "lost %: " << packetStatsLastReportInterval.getLostRate() * 100.0f << "%\n"
|
||||
<< "\n\n";
|
||||
|
||||
lastReport = now;
|
||||
}
|
||||
|
||||
quint64 statsCalcultionEnd = usecTimestampNow();
|
||||
|
||||
lastStatsCalculationTime = (float)(statsCalcultionEnd - statsCalcultionStart);
|
||||
if (lastStatsCalculationTime > LARGE_STATS_TIME) {
|
||||
qDebug() << "WARNING -- unexpectedly large lastStatsCalculationTime=" << lastStatsCalculationTime;
|
||||
}
|
||||
hasStatsCalculationTime = true;
|
||||
}
|
||||
}
|
||||
delete[] inputBuffer;
|
||||
|
||||
#ifdef _WIN32
|
||||
WSACleanup();
|
||||
#endif
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
//
|
||||
// main.cpp
|
||||
// tests/networking/src
|
||||
//
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include "SequenceNumberStatsTests.h"
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
SequenceNumberStatsTests::runAllTests();
|
||||
printf("tests passed! press enter to exit");
|
||||
getchar();
|
||||
return 0;
|
||||
}
|
|
@ -1,6 +1,10 @@
|
|||
|
||||
# Declare dependencies
|
||||
macro (ADD_TESTCASE_DEPENDENCIES)
|
||||
macro (SETUP_TESTCASE_DEPENDENCIES)
|
||||
|
||||
message(STATUS "setting up physics dependencies")
|
||||
message(STATUS "TARGET_NAME = " ${TARGET_NAME})
|
||||
|
||||
add_dependency_external_projects(glm)
|
||||
find_package(GLM REQUIRED)
|
||||
target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS})
|
||||
|
@ -8,10 +12,12 @@ macro (ADD_TESTCASE_DEPENDENCIES)
|
|||
add_dependency_external_projects(bullet)
|
||||
|
||||
find_package(Bullet REQUIRED)
|
||||
|
||||
target_include_directories(${TARGET_NAME} SYSTEM PRIVATE ${BULLET_INCLUDE_DIRS})
|
||||
target_link_libraries(${TARGET_NAME} ${BULLET_LIBRARIES})
|
||||
|
||||
message(STATUS "BULLET_INCLUDE_DIRS = " ${BULLET_INCLUDE_DIRS})
|
||||
message(STATUS "TARGET_NAME = " ${TARGET_NAME})
|
||||
|
||||
link_hifi_libraries(shared physics)
|
||||
copy_dlls_beside_windows_executable()
|
||||
endmacro ()
|
||||
|
|
|
@ -16,6 +16,10 @@
|
|||
|
||||
#include "BulletUtilTests.h"
|
||||
|
||||
|
||||
|
||||
QTEST_MAIN(BulletUtilTests)
|
||||
|
||||
void BulletUtilTests::fromBulletToGLM() {
|
||||
btVector3 bV(1.23f, 4.56f, 7.89f);
|
||||
glm::vec3 gV = bulletToGLM(bV);
|
||||
|
@ -98,9 +102,6 @@ void BulletUtilTests::fromGLMToBullet() {
|
|||
}
|
||||
}
|
||||
|
||||
QTEST_MAIN(BulletUtilTests)
|
||||
|
||||
|
||||
//void BulletUtilTests::runAllTests() {
|
||||
// fromBulletToGLM();
|
||||
// fromGLMToBullet();
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
#include "CollisionInfoTests.h"
|
||||
|
||||
|
||||
|
||||
QTEST_MAIN(CollisionInfoTests)
|
||||
/*
|
||||
|
||||
static glm::vec3 xAxis(1.0f, 0.0f, 0.0f);
|
||||
|
@ -106,8 +108,6 @@ void CollisionInfoTests::translateThenRotate() {
|
|||
}
|
||||
*/
|
||||
|
||||
QTEST_MAIN(CollisionInfoTests)
|
||||
|
||||
//void CollisionInfoTests::runAllTests() {
|
||||
// CollisionInfoTests::rotateThenTranslate();
|
||||
// CollisionInfoTests::translateThenRotate();
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
const btScalar acceptableRelativeError(1.0e-5f);
|
||||
const btScalar acceptableAbsoluteError(1.0e-4f);
|
||||
|
||||
QTEST_MAIN(MeshMassPropertiesTests)
|
||||
|
||||
void printMatrix(const std::string& name, const btMatrix3x3& matrix) {
|
||||
std::cout << name << " = [" << std::endl;
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
|
|
|
@ -32,6 +32,8 @@ static const glm::vec3 xAxis(1.0f, 0.0f, 0.0f);
|
|||
static const glm::vec3 yAxis(0.0f, 1.0f, 0.0f);
|
||||
static const glm::vec3 zAxis(0.0f, 0.0f, 1.0f);
|
||||
|
||||
QTEST_MAIN(ShapeColliderTests)
|
||||
|
||||
void ShapeColliderTests::sphereMissesSphere() {
|
||||
// non-overlapping spheres of unequal size
|
||||
float radiusA = 7.0f;
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
|
||||
#include "ShapeInfoTests.h"
|
||||
|
||||
QTEST_MAIN(ShapeInfoTests)
|
||||
|
||||
void ShapeInfoTests::testHashFunctions() {
|
||||
int maxTests = 10000000;
|
||||
ShapeInfo info;
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
|
||||
#include "ShapeManagerTests.h"
|
||||
|
||||
QTEST_MAIN(ShapeManagerTests)
|
||||
|
||||
void ShapeManagerTests::testShapeAccounting() {
|
||||
ShapeManager shapeManager;
|
||||
ShapeInfo info;
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
//
|
||||
// main.cpp
|
||||
// tests/physics/src
|
||||
//
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
//#include <QtConcurrent>
|
||||
|
||||
//#include "ShapeColliderTests.h"
|
||||
#include "ShapeInfoTests.h"
|
||||
#include "ShapeManagerTests.h"
|
||||
//#include "BulletUtilTests.h"
|
||||
#include "MeshMassPropertiesTests.h"
|
||||
|
||||
//int main(int argc, char** argv) {
|
||||
// ShapeColliderTests::runAllTests();
|
||||
// ShapeInfoTests::runAllTests();
|
||||
// ShapeManagerTests::runAllTests();
|
||||
// BulletUtilTests::runAllTests();
|
||||
// MeshMassPropertiesTests::runAllTests();
|
||||
// return 0;
|
||||
//}
|
||||
|
||||
//QTEST_MAIN(BulletUtilTests)
|
||||
|
||||
// Custom main function to run multiple unit tests. Just copy + paste this into future tests.
|
||||
//#define RUN_TEST(Test) { Test test; runTest(test); }
|
||||
#define RUN_TEST(Test) { runTest(new Test()); }
|
||||
int main (int argc, const char ** argv) {
|
||||
QStringList args;
|
||||
for (int i = 0; i < argc; ++i)
|
||||
args.append(QString { argv[i] });
|
||||
int status = 0;
|
||||
|
||||
auto runTest = [&status, args] (QObject * test) {
|
||||
status |= QTest::qExec(test, args);
|
||||
};
|
||||
|
||||
// Run test classes
|
||||
// RUN_TEST(ShapeColliderTests)
|
||||
RUN_TEST(ShapeInfoTests)
|
||||
RUN_TEST(ShapeManagerTests)
|
||||
// RUN_TEST(BulletUtilTests)
|
||||
RUN_TEST(MeshMassPropertiesTests)
|
||||
|
||||
return status;
|
||||
}
|
|
@ -1,279 +0,0 @@
|
|||
//
|
||||
// main.cpp
|
||||
// tests/render-utils/src
|
||||
//
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include "TextRenderer.h"
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdouble-promotion"
|
||||
#endif
|
||||
|
||||
#include <QWindow>
|
||||
#include <QFile>
|
||||
#include <QTime>
|
||||
#include <QImage>
|
||||
#include <QTimer>
|
||||
#include <QElapsedTimer>
|
||||
#include <QOpenGLContext>
|
||||
#include <QOpenGLBuffer>
|
||||
#include <QOpenGLShaderProgram>
|
||||
#include <QResizeEvent>
|
||||
#include <QLoggingCategory>
|
||||
#include <QOpenGLTexture>
|
||||
#include <QOpenGLVertexArrayObject>
|
||||
#include <QApplication>
|
||||
#include <QOpenGLDebugLogger>
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#include <unordered_map>
|
||||
#include <memory>
|
||||
#include <glm/glm.hpp>
|
||||
#include <PathUtils.h>
|
||||
#include <QDir>
|
||||
|
||||
class RateCounter {
|
||||
std::vector<float> times;
|
||||
QElapsedTimer timer;
|
||||
public:
|
||||
RateCounter() {
|
||||
timer.start();
|
||||
}
|
||||
|
||||
void reset() {
|
||||
times.clear();
|
||||
}
|
||||
|
||||
unsigned int count() const {
|
||||
return times.size() - 1;
|
||||
}
|
||||
|
||||
float elapsed() const {
|
||||
if (times.size() < 1) {
|
||||
return 0.0f;
|
||||
}
|
||||
float elapsed = *times.rbegin() - *times.begin();
|
||||
return elapsed;
|
||||
}
|
||||
|
||||
void increment() {
|
||||
times.push_back(timer.elapsed() / 1000.0f);
|
||||
}
|
||||
|
||||
float rate() const {
|
||||
if (elapsed() == 0.0f) {
|
||||
return NAN;
|
||||
}
|
||||
return (float) count() / elapsed();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const QString& getQmlDir() {
|
||||
static QString dir;
|
||||
if (dir.isEmpty()) {
|
||||
QDir path(__FILE__);
|
||||
path.cdUp();
|
||||
dir = path.cleanPath(path.absoluteFilePath("../../../interface/resources/qml/")) + "/";
|
||||
qDebug() << "Qml Path: " << dir;
|
||||
}
|
||||
return dir;
|
||||
}
|
||||
|
||||
// Create a simple OpenGL window that renders text in various ways
|
||||
class QTestWindow : public QWindow {
|
||||
Q_OBJECT
|
||||
|
||||
QOpenGLContext* _context{ nullptr };
|
||||
QSize _size;
|
||||
TextRenderer* _textRenderer[4];
|
||||
RateCounter fps;
|
||||
|
||||
protected:
|
||||
void renderText();
|
||||
|
||||
private:
|
||||
void resizeWindow(const QSize& size) {
|
||||
_size = size;
|
||||
}
|
||||
|
||||
public:
|
||||
QTestWindow() {
|
||||
setSurfaceType(QSurface::OpenGLSurface);
|
||||
|
||||
QSurfaceFormat format;
|
||||
// Qt Quick may need a depth and stencil buffer. Always make sure these are available.
|
||||
format.setDepthBufferSize(16);
|
||||
format.setStencilBufferSize(8);
|
||||
format.setVersion(4, 5);
|
||||
format.setProfile(QSurfaceFormat::OpenGLContextProfile::CompatibilityProfile);
|
||||
format.setOption(QSurfaceFormat::DebugContext);
|
||||
|
||||
setFormat(format);
|
||||
|
||||
_context = new QOpenGLContext;
|
||||
_context->setFormat(format);
|
||||
_context->create();
|
||||
|
||||
show();
|
||||
makeCurrent();
|
||||
|
||||
{
|
||||
QOpenGLDebugLogger* logger = new QOpenGLDebugLogger(this);
|
||||
logger->initialize(); // initializes in the current context, i.e. ctx
|
||||
logger->enableMessages();
|
||||
connect(logger, &QOpenGLDebugLogger::messageLogged, this, [&](const QOpenGLDebugMessage & debugMessage) {
|
||||
qDebug() << debugMessage;
|
||||
});
|
||||
// logger->startLogging(QOpenGLDebugLogger::SynchronousLogging);
|
||||
}
|
||||
qDebug() << (const char*)glGetString(GL_VERSION);
|
||||
|
||||
#ifdef WIN32
|
||||
glewExperimental = true;
|
||||
GLenum err = glewInit();
|
||||
if (GLEW_OK != err) {
|
||||
/* Problem: glewInit failed, something is seriously wrong. */
|
||||
const GLubyte * errStr = glewGetErrorString(err);
|
||||
qDebug("Error: %s\n", errStr);
|
||||
}
|
||||
qDebug("Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));
|
||||
|
||||
if (wglewGetExtension("WGL_EXT_swap_control")) {
|
||||
int swapInterval = wglGetSwapIntervalEXT();
|
||||
qDebug("V-Sync is %s\n", (swapInterval > 0 ? "ON" : "OFF"));
|
||||
}
|
||||
glGetError();
|
||||
#endif
|
||||
|
||||
_textRenderer[0] = TextRenderer::getInstance(SANS_FONT_FAMILY, 12, false);
|
||||
_textRenderer[1] = TextRenderer::getInstance(SERIF_FONT_FAMILY, 12, false,
|
||||
TextRenderer::SHADOW_EFFECT);
|
||||
_textRenderer[2] = TextRenderer::getInstance(MONO_FONT_FAMILY, 48, -1,
|
||||
false, TextRenderer::OUTLINE_EFFECT);
|
||||
_textRenderer[3] = TextRenderer::getInstance(INCONSOLATA_FONT_FAMILY, 24);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glClearColor(0.2f, 0.2f, 0.2f, 1);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
makeCurrent();
|
||||
|
||||
setFramePosition(QPoint(-1000, 0));
|
||||
resize(QSize(800, 600));
|
||||
}
|
||||
|
||||
virtual ~QTestWindow() {
|
||||
}
|
||||
|
||||
void draw();
|
||||
void makeCurrent() {
|
||||
_context->makeCurrent(this);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
void resizeEvent(QResizeEvent* ev) override {
|
||||
resizeWindow(ev->size());
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef SERIF_FONT_FAMILY
|
||||
#define SERIF_FONT_FAMILY "Times New Roman"
|
||||
#endif
|
||||
|
||||
static const wchar_t* EXAMPLE_TEXT = L"Hello";
|
||||
//static const wchar_t* EXAMPLE_TEXT = L"\xC1y Hello 1.0\ny\xC1 line 2\n\xC1y";
|
||||
static const glm::uvec2 QUAD_OFFSET(10, 10);
|
||||
|
||||
static const glm::vec3 COLORS[4] = { { 1.0, 1.0, 1.0 }, { 0.5, 1.0, 0.5 }, {
|
||||
1.0, 0.5, 0.5 }, { 0.5, 0.5, 1.0 } };
|
||||
|
||||
void QTestWindow::renderText() {
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(0, _size.width(), _size.height(), 0, 1, -1);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
|
||||
const glm::uvec2 size = glm::uvec2(_size.width() / 2, _size.height() / 2);
|
||||
|
||||
const glm::uvec2 offsets[4] = {
|
||||
{ QUAD_OFFSET.x, QUAD_OFFSET.y },
|
||||
{ size.x + QUAD_OFFSET.x, QUAD_OFFSET.y },
|
||||
{ size.x + QUAD_OFFSET.x, size.y + QUAD_OFFSET.y },
|
||||
{ QUAD_OFFSET.x, size.y + QUAD_OFFSET.y },
|
||||
};
|
||||
|
||||
QString str = QString::fromWCharArray(EXAMPLE_TEXT);
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
glm::vec2 bounds = _textRenderer[i]->computeExtent(str);
|
||||
glPushMatrix();
|
||||
{
|
||||
glTranslatef(offsets[i].x, offsets[i].y, 0);
|
||||
glColor3f(0, 0, 0);
|
||||
glBegin(GL_QUADS);
|
||||
{
|
||||
glVertex2f(0, 0);
|
||||
glVertex2f(0, bounds.y);
|
||||
glVertex2f(bounds.x, bounds.y);
|
||||
glVertex2f(bounds.x, 0);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
glPopMatrix();
|
||||
const int testCount = 100;
|
||||
for (int j = 0; j < testCount; ++j) {
|
||||
// Draw backgrounds around where the text will appear
|
||||
// Draw the text itself
|
||||
_textRenderer[i]->draw(offsets[i].x, offsets[i].y, str.toLocal8Bit().constData(),
|
||||
glm::vec4(COLORS[i], 1.0f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QTestWindow::draw() {
|
||||
if (!isVisible()) {
|
||||
return;
|
||||
}
|
||||
|
||||
makeCurrent();
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glViewport(0, 0, _size.width() * devicePixelRatio(), _size.height() * devicePixelRatio());
|
||||
|
||||
renderText();
|
||||
|
||||
_context->swapBuffers(this);
|
||||
glFinish();
|
||||
|
||||
fps.increment();
|
||||
if (fps.elapsed() >= 2.0f) {
|
||||
qDebug() << "FPS: " << fps.rate();
|
||||
fps.reset();
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
QGuiApplication app(argc, argv);
|
||||
QTestWindow window;
|
||||
QTimer timer;
|
||||
timer.setInterval(1);
|
||||
app.connect(&timer, &QTimer::timeout, &app, [&] {
|
||||
window.draw();
|
||||
});
|
||||
timer.start();
|
||||
app.exec();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include "main.moc"
|
|
@ -1,22 +0,0 @@
|
|||
//
|
||||
// main.cpp
|
||||
// tests/physics/src
|
||||
//
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include "AngularConstraintTests.h"
|
||||
#include "MovingPercentileTests.h"
|
||||
#include "MovingMinMaxAvgTests.h"
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
MovingMinMaxAvgTests::runAllTests();
|
||||
MovingPercentileTests::runAllTests();
|
||||
AngularConstraintTests::runAllTests();
|
||||
printf("tests complete, press enter to exit\n");
|
||||
getchar();
|
||||
return 0;
|
||||
}
|
|
@ -1,510 +0,0 @@
|
|||
//
|
||||
// main.cpp
|
||||
// tests/render-utils/src
|
||||
//
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include "OffscreenUi.h"
|
||||
#include <QWindow>
|
||||
#include <QFile>
|
||||
#include <QTime>
|
||||
#include <QImage>
|
||||
#include <QTimer>
|
||||
#include <QElapsedTimer>
|
||||
#include <QOpenGLContext>
|
||||
#include <QOpenGLBuffer>
|
||||
#include <QOpenGLShaderProgram>
|
||||
#include <QResizeEvent>
|
||||
#include <QLoggingCategory>
|
||||
#include <QOpenGLTexture>
|
||||
#include <QOpenGLVertexArrayObject>
|
||||
#include <QApplication>
|
||||
#include <QOpenGLDebugLogger>
|
||||
#include <QOpenGLFunctions>
|
||||
#include <QQmlContext>
|
||||
#include <QtQml/QQmlApplicationEngine>
|
||||
#include <PathUtils.h>
|
||||
#include <unordered_map>
|
||||
#include <memory>
|
||||
#include <glm/glm.hpp>
|
||||
#include <PathUtils.h>
|
||||
#include <QDir>
|
||||
#include "MessageDialog.h"
|
||||
#include "VrMenu.h"
|
||||
#include "InfoView.h"
|
||||
#include <QDesktopWidget>
|
||||
|
||||
class RateCounter {
|
||||
std::vector<float> times;
|
||||
QElapsedTimer timer;
|
||||
public:
|
||||
RateCounter() {
|
||||
timer.start();
|
||||
}
|
||||
|
||||
void reset() {
|
||||
times.clear();
|
||||
}
|
||||
|
||||
unsigned int count() const {
|
||||
return times.size() - 1;
|
||||
}
|
||||
|
||||
float elapsed() const {
|
||||
if (times.size() < 1) {
|
||||
return 0.0f;
|
||||
}
|
||||
float elapsed = *times.rbegin() - *times.begin();
|
||||
return elapsed;
|
||||
}
|
||||
|
||||
void increment() {
|
||||
times.push_back(timer.elapsed() / 1000.0f);
|
||||
}
|
||||
|
||||
float rate() const {
|
||||
if (elapsed() == 0.0f) {
|
||||
return NAN;
|
||||
}
|
||||
return (float) count() / elapsed();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class MenuConstants : public QObject{
|
||||
Q_OBJECT
|
||||
Q_ENUMS(Item)
|
||||
|
||||
public:
|
||||
enum Item {
|
||||
AboutApp,
|
||||
AddRemoveFriends,
|
||||
AddressBar,
|
||||
AlignForearmsWithWrists,
|
||||
AlternateIK,
|
||||
AmbientOcclusion,
|
||||
Animations,
|
||||
Atmosphere,
|
||||
Attachments,
|
||||
AudioNoiseReduction,
|
||||
AudioScope,
|
||||
AudioScopeFiftyFrames,
|
||||
AudioScopeFiveFrames,
|
||||
AudioScopeFrames,
|
||||
AudioScopePause,
|
||||
AudioScopeTwentyFrames,
|
||||
AudioStats,
|
||||
AudioStatsShowInjectedStreams,
|
||||
BandwidthDetails,
|
||||
BlueSpeechSphere,
|
||||
BookmarkLocation,
|
||||
Bookmarks,
|
||||
CascadedShadows,
|
||||
CachesSize,
|
||||
Chat,
|
||||
Collisions,
|
||||
Console,
|
||||
ControlWithSpeech,
|
||||
CopyAddress,
|
||||
CopyPath,
|
||||
DecreaseAvatarSize,
|
||||
DeleteBookmark,
|
||||
DisableActivityLogger,
|
||||
DisableLightEntities,
|
||||
DisableNackPackets,
|
||||
DiskCacheEditor,
|
||||
DisplayHands,
|
||||
DisplayHandTargets,
|
||||
DisplayModelBounds,
|
||||
DisplayModelTriangles,
|
||||
DisplayModelElementChildProxies,
|
||||
DisplayModelElementProxy,
|
||||
DisplayDebugTimingDetails,
|
||||
DontDoPrecisionPicking,
|
||||
DontFadeOnOctreeServerChanges,
|
||||
DontRenderEntitiesAsScene,
|
||||
EchoLocalAudio,
|
||||
EchoServerAudio,
|
||||
EditEntitiesHelp,
|
||||
Enable3DTVMode,
|
||||
EnableCharacterController,
|
||||
EnableGlowEffect,
|
||||
EnableVRMode,
|
||||
ExpandMyAvatarSimulateTiming,
|
||||
ExpandMyAvatarTiming,
|
||||
ExpandOtherAvatarTiming,
|
||||
ExpandPaintGLTiming,
|
||||
ExpandUpdateTiming,
|
||||
Faceshift,
|
||||
FilterSixense,
|
||||
FirstPerson,
|
||||
FrameTimer,
|
||||
Fullscreen,
|
||||
FullscreenMirror,
|
||||
GlowWhenSpeaking,
|
||||
NamesAboveHeads,
|
||||
GoToUser,
|
||||
HMDTools,
|
||||
IncreaseAvatarSize,
|
||||
KeyboardMotorControl,
|
||||
LeapMotionOnHMD,
|
||||
LoadScript,
|
||||
LoadScriptURL,
|
||||
LoadRSSDKFile,
|
||||
LodTools,
|
||||
Login,
|
||||
Log,
|
||||
LowVelocityFilter,
|
||||
Mirror,
|
||||
MuteAudio,
|
||||
MuteEnvironment,
|
||||
MuteFaceTracking,
|
||||
NoFaceTracking,
|
||||
NoShadows,
|
||||
OctreeStats,
|
||||
OffAxisProjection,
|
||||
OnlyDisplayTopTen,
|
||||
PackageModel,
|
||||
Pair,
|
||||
PipelineWarnings,
|
||||
Preferences,
|
||||
Quit,
|
||||
ReloadAllScripts,
|
||||
RenderBoundingCollisionShapes,
|
||||
RenderFocusIndicator,
|
||||
RenderHeadCollisionShapes,
|
||||
RenderLookAtVectors,
|
||||
RenderSkeletonCollisionShapes,
|
||||
RenderTargetFramerate,
|
||||
RenderTargetFramerateUnlimited,
|
||||
RenderTargetFramerate60,
|
||||
RenderTargetFramerate50,
|
||||
RenderTargetFramerate40,
|
||||
RenderTargetFramerate30,
|
||||
RenderTargetFramerateVSyncOn,
|
||||
RenderResolution,
|
||||
RenderResolutionOne,
|
||||
RenderResolutionTwoThird,
|
||||
RenderResolutionHalf,
|
||||
RenderResolutionThird,
|
||||
RenderResolutionQuarter,
|
||||
RenderAmbientLight,
|
||||
RenderAmbientLightGlobal,
|
||||
RenderAmbientLight0,
|
||||
RenderAmbientLight1,
|
||||
RenderAmbientLight2,
|
||||
RenderAmbientLight3,
|
||||
RenderAmbientLight4,
|
||||
RenderAmbientLight5,
|
||||
RenderAmbientLight6,
|
||||
RenderAmbientLight7,
|
||||
RenderAmbientLight8,
|
||||
RenderAmbientLight9,
|
||||
ResetAvatarSize,
|
||||
ResetSensors,
|
||||
RunningScripts,
|
||||
RunTimingTests,
|
||||
ScriptEditor,
|
||||
ScriptedMotorControl,
|
||||
ShowBordersEntityNodes,
|
||||
ShowIKConstraints,
|
||||
SimpleShadows,
|
||||
SixenseEnabled,
|
||||
SixenseMouseInput,
|
||||
SixenseLasers,
|
||||
ShiftHipsForIdleAnimations,
|
||||
Stars,
|
||||
Stats,
|
||||
StereoAudio,
|
||||
StopAllScripts,
|
||||
SuppressShortTimings,
|
||||
TestPing,
|
||||
ToolWindow,
|
||||
TransmitterDrive,
|
||||
TurnWithHead,
|
||||
UseAudioForMouth,
|
||||
UseCamera,
|
||||
VelocityFilter,
|
||||
VisibleToEveryone,
|
||||
VisibleToFriends,
|
||||
VisibleToNoOne,
|
||||
Wireframe,
|
||||
};
|
||||
|
||||
public:
|
||||
MenuConstants(QObject* parent = nullptr) : QObject(parent) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
const QString& getResourcesDir() {
|
||||
static QString dir;
|
||||
if (dir.isEmpty()) {
|
||||
QDir path(__FILE__);
|
||||
path.cdUp();
|
||||
dir = path.cleanPath(path.absoluteFilePath("../../../interface/resources/")) + "/";
|
||||
qDebug() << "Resources Path: " << dir;
|
||||
}
|
||||
return dir;
|
||||
}
|
||||
|
||||
const QString& getQmlDir() {
|
||||
static QString dir;
|
||||
if (dir.isEmpty()) {
|
||||
dir = getResourcesDir() + "qml/";
|
||||
qDebug() << "Qml Path: " << dir;
|
||||
}
|
||||
return dir;
|
||||
}
|
||||
|
||||
const QString& getTestQmlDir() {
|
||||
static QString dir;
|
||||
if (dir.isEmpty()) {
|
||||
QDir path(__FILE__);
|
||||
path.cdUp();
|
||||
dir = path.cleanPath(path.absoluteFilePath("../")) + "/";
|
||||
qDebug() << "Qml Test Path: " << dir;
|
||||
}
|
||||
return dir;
|
||||
}
|
||||
|
||||
// Create a simple OpenGL window that renders text in various ways
|
||||
class QTestWindow : public QWindow, private QOpenGLFunctions {
|
||||
Q_OBJECT
|
||||
|
||||
QOpenGLContext* _context{ nullptr };
|
||||
QSize _size;
|
||||
bool _altPressed{ false };
|
||||
RateCounter fps;
|
||||
QTimer _timer;
|
||||
int testQmlTexture{ 0 };
|
||||
|
||||
public:
|
||||
QObject* rootMenu;
|
||||
|
||||
QTestWindow() {
|
||||
_timer.setInterval(1);
|
||||
connect(&_timer, &QTimer::timeout, [=] {
|
||||
draw();
|
||||
});
|
||||
|
||||
DependencyManager::set<OffscreenUi>();
|
||||
setSurfaceType(QSurface::OpenGLSurface);
|
||||
|
||||
QSurfaceFormat format;
|
||||
format.setDepthBufferSize(16);
|
||||
format.setStencilBufferSize(8);
|
||||
format.setVersion(4, 1);
|
||||
format.setProfile(QSurfaceFormat::OpenGLContextProfile::CompatibilityProfile);
|
||||
format.setOption(QSurfaceFormat::DebugContext);
|
||||
|
||||
setFormat(format);
|
||||
|
||||
_context = new QOpenGLContext;
|
||||
_context->setFormat(format);
|
||||
if (!_context->create()) {
|
||||
qFatal("Could not create OpenGL context");
|
||||
}
|
||||
|
||||
show();
|
||||
makeCurrent();
|
||||
initializeOpenGLFunctions();
|
||||
|
||||
{
|
||||
QOpenGLDebugLogger* logger = new QOpenGLDebugLogger(this);
|
||||
logger->initialize(); // initializes in the current context, i.e. ctx
|
||||
logger->enableMessages();
|
||||
connect(logger, &QOpenGLDebugLogger::messageLogged, this, [&](const QOpenGLDebugMessage & debugMessage) {
|
||||
qDebug() << debugMessage;
|
||||
});
|
||||
// logger->startLogging(QOpenGLDebugLogger::SynchronousLogging);
|
||||
}
|
||||
|
||||
qDebug() << (const char*)this->glGetString(GL_VERSION);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glClearColor(0.2f, 0.2f, 0.2f, 1);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
MessageDialog::registerType();
|
||||
VrMenu::registerType();
|
||||
InfoView::registerType();
|
||||
qmlRegisterType<MenuConstants>("Hifi", 1, 0, "MenuConstants");
|
||||
|
||||
|
||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||
offscreenUi->create(_context);
|
||||
connect(offscreenUi.data(), &OffscreenUi::textureUpdated, this, [this, offscreenUi](int textureId) {
|
||||
offscreenUi->lockTexture(textureId);
|
||||
assert(!glGetError());
|
||||
GLuint oldTexture = testQmlTexture;
|
||||
testQmlTexture = textureId;
|
||||
if (oldTexture) {
|
||||
offscreenUi->releaseTexture(oldTexture);
|
||||
}
|
||||
});
|
||||
|
||||
makeCurrent();
|
||||
|
||||
offscreenUi->setProxyWindow(this);
|
||||
QDesktopWidget* desktop = QApplication::desktop();
|
||||
QRect rect = desktop->availableGeometry(desktop->screenCount() - 1);
|
||||
int height = rect.height();
|
||||
//rect.setHeight(height / 2);
|
||||
rect.setY(rect.y() + height / 2);
|
||||
setGeometry(rect);
|
||||
// setFramePosition(QPoint(-1000, 0));
|
||||
// resize(QSize(800, 600));
|
||||
|
||||
#ifdef QML_CONTROL_GALLERY
|
||||
offscreenUi->setBaseUrl(QUrl::fromLocalFile(getTestQmlDir()));
|
||||
offscreenUi->load(QUrl("main.qml"));
|
||||
#else
|
||||
offscreenUi->setBaseUrl(QUrl::fromLocalFile(getQmlDir()));
|
||||
offscreenUi->load(QUrl("TestRoot.qml"));
|
||||
offscreenUi->load(QUrl("TestMenu.qml"));
|
||||
// Requires a root menu to have been loaded before it can load
|
||||
VrMenu::load();
|
||||
#endif
|
||||
installEventFilter(offscreenUi.data());
|
||||
offscreenUi->resume();
|
||||
_timer.start();
|
||||
}
|
||||
|
||||
virtual ~QTestWindow() {
|
||||
DependencyManager::destroy<OffscreenUi>();
|
||||
}
|
||||
|
||||
private:
|
||||
void draw() {
|
||||
if (!isVisible()) {
|
||||
return;
|
||||
}
|
||||
|
||||
makeCurrent();
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glViewport(0, 0, _size.width() * devicePixelRatio(), _size.height() * devicePixelRatio());
|
||||
|
||||
renderQml();
|
||||
|
||||
_context->swapBuffers(this);
|
||||
glFinish();
|
||||
|
||||
fps.increment();
|
||||
if (fps.elapsed() >= 2.0f) {
|
||||
qDebug() << "FPS: " << fps.rate();
|
||||
fps.reset();
|
||||
}
|
||||
}
|
||||
|
||||
void makeCurrent() {
|
||||
_context->makeCurrent(this);
|
||||
}
|
||||
|
||||
void renderQml();
|
||||
|
||||
void resizeWindow(const QSize & size) {
|
||||
_size = size;
|
||||
DependencyManager::get<OffscreenUi>()->resize(_size);
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent* ev) override {
|
||||
resizeWindow(ev->size());
|
||||
}
|
||||
|
||||
|
||||
void keyPressEvent(QKeyEvent* event) {
|
||||
_altPressed = Qt::Key_Alt == event->key();
|
||||
switch (event->key()) {
|
||||
case Qt::Key_B:
|
||||
if (event->modifiers() & Qt::CTRL) {
|
||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||
offscreenUi->load("Browser.qml");
|
||||
}
|
||||
break;
|
||||
case Qt::Key_L:
|
||||
if (event->modifiers() & Qt::CTRL) {
|
||||
InfoView::show(getResourcesDir() + "html/interface-welcome.html", true);
|
||||
}
|
||||
break;
|
||||
case Qt::Key_K:
|
||||
if (event->modifiers() & Qt::CTRL) {
|
||||
OffscreenUi::question("Message title", "Message contents", [](QMessageBox::Button b){
|
||||
qDebug() << b;
|
||||
});
|
||||
}
|
||||
break;
|
||||
case Qt::Key_J:
|
||||
if (event->modifiers() & Qt::CTRL) {
|
||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||
rootMenu = offscreenUi->getRootItem()->findChild<QObject*>("rootMenu");
|
||||
QMetaObject::invokeMethod(rootMenu, "popup");
|
||||
}
|
||||
break;
|
||||
}
|
||||
QWindow::keyPressEvent(event);
|
||||
}
|
||||
QQmlContext* menuContext{ nullptr };
|
||||
void keyReleaseEvent(QKeyEvent *event) {
|
||||
if (_altPressed && Qt::Key_Alt == event->key()) {
|
||||
VrMenu::toggle();
|
||||
}
|
||||
}
|
||||
|
||||
void moveEvent(QMoveEvent* event) {
|
||||
static qreal oldPixelRatio = 0.0;
|
||||
if (devicePixelRatio() != oldPixelRatio) {
|
||||
oldPixelRatio = devicePixelRatio();
|
||||
resizeWindow(size());
|
||||
}
|
||||
QWindow::moveEvent(event);
|
||||
}
|
||||
};
|
||||
|
||||
void QTestWindow::renderQml() {
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
if (testQmlTexture > 0) {
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, testQmlTexture);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
}
|
||||
glBegin(GL_QUADS);
|
||||
{
|
||||
glTexCoord2f(0, 0);
|
||||
glVertex2f(-1, -1);
|
||||
glTexCoord2f(0, 1);
|
||||
glVertex2f(-1, 1);
|
||||
glTexCoord2f(1, 1);
|
||||
glVertex2f(1, 1);
|
||||
glTexCoord2f(1, 0);
|
||||
glVertex2f(1, -1);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
|
||||
|
||||
const char * LOG_FILTER_RULES = R"V0G0N(
|
||||
hifi.offscreen.focus.debug=false
|
||||
qt.quick.mouse.debug=false
|
||||
)V0G0N";
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
QApplication app(argc, argv);
|
||||
QLoggingCategory::setFilterRules(LOG_FILTER_RULES);
|
||||
QTestWindow window;
|
||||
app.exec();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include "main.moc"
|
Loading…
Reference in a new issue