mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Integrating changes from CeeViz trunk per changelist 21999 (branch point for CVC) into ResInsight. Done in preparation to convert ResInsight to use CVC-june
Changes to Camera class, Camera::fitView() and rename/new impl of Camera::fitViewEyePosition()/ Camera::computeFitViewEyePosition Logging: Use new macro to get hold of logger. Modifications to prefixing of file log messages Changes to OverlayImage Added use of scissoring to Rendering::renderOverlayItems() Upping of CVF version number Tweaks to compile on Android Modifications in shaders to compile on OpenGL ES p4#: 22501
This commit is contained in:
parent
0c19d50582
commit
f667c604a3
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#if !defined(WIN32) && !defined(CVF_LINUX) && !defined(CVF_IOS) && !defined(CVF_OSX)
|
#if !defined(WIN32) && !defined(CVF_LINUX) && !defined(CVF_IOS) && !defined(CVF_OSX) && !defined(CVF_ANDROID)
|
||||||
#error No platform defined
|
#error No platform defined
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -50,7 +50,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if defined(CVF_LINUX) || defined(CVF_IOS) || defined(CVF_OSX)
|
#if defined(CVF_LINUX) || defined(CVF_IOS) || defined(CVF_OSX) || defined(CVF_ANDROID)
|
||||||
// Used by int64_t on *nix below
|
// Used by int64_t on *nix below
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#endif
|
#endif
|
||||||
@ -88,7 +88,7 @@ typedef unsigned int uint;
|
|||||||
// 64bit integer support via the int64 type
|
// 64bit integer support via the int64 type
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
typedef __int64 int64;
|
typedef __int64 int64;
|
||||||
#elif defined(CVF_LINUX) || defined(CVF_IOS) || defined(CVF_OSX)
|
#elif defined(CVF_LINUX) || defined(CVF_IOS) || defined(CVF_OSX) || defined(CVF_ANDROID)
|
||||||
typedef int64_t int64;
|
typedef int64_t int64;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -33,6 +33,12 @@
|
|||||||
|
|
||||||
namespace cvf {
|
namespace cvf {
|
||||||
|
|
||||||
|
|
||||||
|
//==================================================================================================
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//==================================================================================================
|
||||||
class FileWrapper
|
class FileWrapper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -77,6 +83,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
///
|
///
|
||||||
/// \class cvf::LogDestinationFile
|
/// \class cvf::LogDestinationFile
|
||||||
@ -86,6 +93,14 @@ private:
|
|||||||
///
|
///
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
LogDestinationFile::LogDestinationFile(const String& fileName)
|
||||||
|
: m_fileName(fileName)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -97,20 +112,20 @@ void LogDestinationFile::log(const LogEvent& logEvent)
|
|||||||
Logger::Level logEventLevel = logEvent.level();
|
Logger::Level logEventLevel = logEvent.level();
|
||||||
if (logEventLevel == Logger::LL_ERROR)
|
if (logEventLevel == Logger::LL_ERROR)
|
||||||
{
|
{
|
||||||
str = "ERROR: " + logEvent.message();
|
str = logEvent.source() + "**ERROR**: " + logEvent.message();
|
||||||
addLocationInfo = true;
|
addLocationInfo = true;
|
||||||
}
|
}
|
||||||
else if (logEventLevel == Logger::LL_WARNING)
|
else if (logEventLevel == Logger::LL_WARNING)
|
||||||
{
|
{
|
||||||
str = "warn: " + logEvent.message();
|
str = logEvent.source() + "(warn): " + logEvent.message();
|
||||||
}
|
}
|
||||||
else if (logEventLevel == Logger::LL_INFO)
|
else if (logEventLevel == Logger::LL_INFO)
|
||||||
{
|
{
|
||||||
str = "info: " + logEvent.message();
|
str = logEvent.source() + "(i): " + logEvent.message();
|
||||||
}
|
}
|
||||||
else if (logEventLevel == Logger::LL_DEBUG)
|
else if (logEventLevel == Logger::LL_DEBUG)
|
||||||
{
|
{
|
||||||
str = "debug: " + logEvent.message();
|
str = logEvent.source() + "(d): " + logEvent.message();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addLocationInfo)
|
if (addLocationInfo)
|
||||||
|
@ -49,10 +49,10 @@ private:
|
|||||||
void swap(LogEvent& other);
|
void swap(LogEvent& other);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
String m_source;
|
String m_source; // Source of the log event, normally name of the logger
|
||||||
String m_message;
|
String m_message; // The logged message
|
||||||
Logger::Level m_level;
|
Logger::Level m_level; // The log level of the event
|
||||||
CodeLocation m_codeLocation;
|
CodeLocation m_codeLocation; // Source code location of log statement
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
#include "cvfBase.h"
|
#include "cvfBase.h"
|
||||||
#include "cvfLogManager.h"
|
#include "cvfLogManager.h"
|
||||||
#include "cvfLogger.h"
|
|
||||||
#include "cvfLogDestinationConsole.h"
|
#include "cvfLogDestinationConsole.h"
|
||||||
|
|
||||||
namespace cvf {
|
namespace cvf {
|
||||||
@ -137,7 +136,9 @@ Logger* LogManager::rootLogger()
|
|||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
/// Sets the logging level of the given logger and all its descendants.
|
||||||
///
|
///
|
||||||
|
/// Specify an empty name to set logging level of all current loggers.
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void LogManager::setLevelRecursive(const String& baseLoggerName, int logLevel)
|
void LogManager::setLevelRecursive(const String& baseLoggerName, int logLevel)
|
||||||
{
|
{
|
||||||
@ -167,7 +168,7 @@ void LogManager::setLevelRecursive(const String& baseLoggerName, int logLevel)
|
|||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
/// Sets the log destination for the specified logger and all its children.
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void LogManager::setDestinationRecursive(const String& baseLoggerName, LogDestination* logDestination)
|
void LogManager::setDestinationRecursive(const String& baseLoggerName, LogDestination* logDestination)
|
||||||
{
|
{
|
||||||
|
@ -22,12 +22,12 @@
|
|||||||
#include "cvfObject.h"
|
#include "cvfObject.h"
|
||||||
#include "cvfString.h"
|
#include "cvfString.h"
|
||||||
#include "cvfMutex.h"
|
#include "cvfMutex.h"
|
||||||
|
#include "cvfLogger.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
namespace cvf {
|
namespace cvf {
|
||||||
|
|
||||||
class Logger;
|
|
||||||
class LogDestination;
|
class LogDestination;
|
||||||
|
|
||||||
|
|
||||||
@ -68,6 +68,9 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Helper macros for getting or creating a named logger
|
||||||
|
#define CVF_GET_LOGGER(loggerName) (cvf::LogManager::instance()->logger(loggerName))
|
||||||
|
|
||||||
|
|
||||||
} // cvf
|
} // cvf
|
||||||
|
|
||||||
|
@ -68,9 +68,10 @@ const String& Logger::name() const
|
|||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
/// Set the logging level of this logger
|
/// Sets the logging level of this logger
|
||||||
///
|
///
|
||||||
/// Set a level of 0 to disable all logging for this logger.
|
/// Set a level of 0 to disable all logging for this logger.
|
||||||
|
/// \sa Logger::Level
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void Logger::setLevel(int logLevel)
|
void Logger::setLevel(int logLevel)
|
||||||
{
|
{
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#pragma warning (pop)
|
#pragma warning (pop)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CVF_LINUX
|
#if defined CVF_LINUX || defined(CVF_ANDROID)
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -71,10 +71,10 @@ private:
|
|||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
//
|
//
|
||||||
// Linux implementation using POSIX/Pthreads
|
// Linux and Android implementation using POSIX/Pthreads
|
||||||
//
|
//
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
#ifdef CVF_LINUX
|
#if defined(CVF_LINUX) || defined(CVF_ANDROID) || defined(CVF_IOS) || defined(CVF_OSX)
|
||||||
class MutexImpl
|
class MutexImpl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -580,6 +580,31 @@ CharArray String::toUtf8() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
/// Returns a String initialized with the first \a strSize characters from the string str
|
||||||
|
///
|
||||||
|
/// If \a strSize is npos, this function will compute the length of the string.
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
cvf::String String::fromAscii(const char* str, size_t strSize)
|
||||||
|
{
|
||||||
|
if (str != NULL)
|
||||||
|
{
|
||||||
|
if (strSize == npos)
|
||||||
|
{
|
||||||
|
strSize = strlen(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Raw conversion, no UTF8
|
||||||
|
return String(std::wstring(str, str + strSize));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return String();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -77,8 +77,9 @@ public:
|
|||||||
CharArray toAscii() const; // Useful when you need a const char* pointer.
|
CharArray toAscii() const; // Useful when you need a const char* pointer.
|
||||||
std::string toStdString() const;
|
std::string toStdString() const;
|
||||||
std::wstring toStdWString() const;
|
std::wstring toStdWString() const;
|
||||||
|
|
||||||
CharArray toUtf8() const;
|
CharArray toUtf8() const;
|
||||||
|
|
||||||
|
static String fromAscii(const char* str, size_t strSize = npos);
|
||||||
static String fromUtf8(const char* str);
|
static String fromUtf8(const char* str);
|
||||||
|
|
||||||
bool isEmpty() const;
|
bool isEmpty() const;
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#pragma warning (pop)
|
#pragma warning (pop)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CVF_LINUX
|
#if defined(CVF_LINUX) || defined(CVF_ANDROID)
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ public:
|
|||||||
};
|
};
|
||||||
#endif //WIN32
|
#endif //WIN32
|
||||||
|
|
||||||
#ifdef CVF_LINUX
|
#if defined(CVF_LINUX) || defined(CVF_ANDROID)
|
||||||
class PrivateTimerState
|
class PrivateTimerState
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -83,7 +83,7 @@ public:
|
|||||||
timespec m_timeStart;
|
timespec m_timeStart;
|
||||||
timespec m_timeMark;
|
timespec m_timeMark;
|
||||||
};
|
};
|
||||||
#endif // CVF_LINUX
|
#endif // CVF_LINUX || CVF_ANDROID
|
||||||
|
|
||||||
|
|
||||||
#if defined(CVF_IOS) || defined(CVF_OSX)
|
#if defined(CVF_IOS) || defined(CVF_OSX)
|
||||||
@ -107,7 +107,7 @@ public:
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
/// Static helper on Linux to compute difference between two timespecs
|
/// Static helper on Linux to compute difference between two timespecs
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
#ifdef CVF_LINUX
|
#if defined(CVF_LINUX) || defined(CVF_ANDROID)
|
||||||
static timespec ComputeTimespecDiff(const timespec start, const timespec end)
|
static timespec ComputeTimespecDiff(const timespec start, const timespec end)
|
||||||
{
|
{
|
||||||
timespec temp;
|
timespec temp;
|
||||||
@ -170,7 +170,7 @@ void Timer::restart()
|
|||||||
m_timerState->m_startTick = tick.QuadPart;
|
m_timerState->m_startTick = tick.QuadPart;
|
||||||
m_timerState->m_lastLapTick = m_timerState->m_startTick;
|
m_timerState->m_lastLapTick = m_timerState->m_startTick;
|
||||||
|
|
||||||
#elif CVF_LINUX
|
#elif defined(CVF_LINUX) || defined(CVF_ANDROID)
|
||||||
|
|
||||||
clock_gettime(CLOCK_MONOTONIC, &m_timerState->m_timeStart);
|
clock_gettime(CLOCK_MONOTONIC, &m_timerState->m_timeStart);
|
||||||
m_timerState->m_timeMark = m_timerState->m_timeStart;
|
m_timerState->m_timeMark = m_timerState->m_timeStart;
|
||||||
@ -196,7 +196,7 @@ double Timer::time() const
|
|||||||
QueryPerformanceCounter(&nowTick);
|
QueryPerformanceCounter(&nowTick);
|
||||||
return static_cast<double>((nowTick.QuadPart - m_timerState->m_startTick))/static_cast<double>(m_timerState->m_ticksPerSecond);
|
return static_cast<double>((nowTick.QuadPart - m_timerState->m_startTick))/static_cast<double>(m_timerState->m_ticksPerSecond);
|
||||||
|
|
||||||
#elif CVF_LINUX
|
#elif defined(CVF_LINUX) || defined(CVF_ANDROID)
|
||||||
|
|
||||||
timespec timeNow;
|
timespec timeNow;
|
||||||
clock_gettime(CLOCK_MONOTONIC, &timeNow);
|
clock_gettime(CLOCK_MONOTONIC, &timeNow);
|
||||||
@ -230,7 +230,7 @@ double Timer::lapTime()
|
|||||||
double lapTime = static_cast<double>((nowTick.QuadPart - m_timerState->m_lastLapTick))/static_cast<double>(m_timerState->m_ticksPerSecond);
|
double lapTime = static_cast<double>((nowTick.QuadPart - m_timerState->m_lastLapTick))/static_cast<double>(m_timerState->m_ticksPerSecond);
|
||||||
m_timerState->m_lastLapTick = nowTick.QuadPart;
|
m_timerState->m_lastLapTick = nowTick.QuadPart;
|
||||||
|
|
||||||
#elif CVF_LINUX
|
#elif defined(CVF_LINUX) || defined(CVF_ANDROID)
|
||||||
|
|
||||||
timespec timeNow;
|
timespec timeNow;
|
||||||
clock_gettime(CLOCK_MONOTONIC, &timeNow);
|
clock_gettime(CLOCK_MONOTONIC, &timeNow);
|
||||||
|
@ -31,10 +31,12 @@
|
|||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CVF_ANDROID
|
||||||
|
#include <android/log.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace cvf {
|
namespace cvf {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
///
|
///
|
||||||
/// \class cvf::Trace
|
/// \class cvf::Trace
|
||||||
@ -70,6 +72,8 @@ void Trace::show(const char* format, ...)
|
|||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
_vsnprintf_s(temp, maxFormatLength, format, argList);
|
_vsnprintf_s(temp, maxFormatLength, format, argList);
|
||||||
|
#elif defined(CVF_ANDROID)
|
||||||
|
__android_log_print(ANDROID_LOG_DEBUG, "CVF_TAG", format, argList);
|
||||||
#else
|
#else
|
||||||
vsprintf(temp, format, argList);
|
vsprintf(temp, format, argList);
|
||||||
#endif
|
#endif
|
||||||
@ -115,6 +119,8 @@ void Trace::showTraceOutput(String text, bool addNewLine)
|
|||||||
WriteConsoleA(hStdOutputHandle, ascii.ptr(), stringLength, &iDum, NULL);
|
WriteConsoleA(hStdOutputHandle, ascii.ptr(), stringLength, &iDum, NULL);
|
||||||
if (addNewLine) WriteConsole(hStdOutputHandle, "\n", 1, &iDum, NULL);
|
if (addNewLine) WriteConsole(hStdOutputHandle, "\n", 1, &iDum, NULL);
|
||||||
}
|
}
|
||||||
|
#elif defined(CVF_ANDROID)
|
||||||
|
__android_log_print(ANDROID_LOG_DEBUG, "CVF_TAG", "%s", text.toAscii().ptr());
|
||||||
#else
|
#else
|
||||||
fprintf(stderr, "%s", text.toAscii().ptr());
|
fprintf(stderr, "%s", text.toAscii().ptr());
|
||||||
if (addNewLine)
|
if (addNewLine)
|
||||||
|
@ -24,4 +24,4 @@
|
|||||||
#define CVF_MAJOR_VERSION "0" // Major version number
|
#define CVF_MAJOR_VERSION "0" // Major version number
|
||||||
#define CVF_MINOR_VERSION "9" // Minor version number
|
#define CVF_MINOR_VERSION "9" // Minor version number
|
||||||
#define CVF_SPECIAL_BUILD "" // Special build description
|
#define CVF_SPECIAL_BUILD "" // Special build description
|
||||||
#define CVF_BUILD_NUMBER "4" // Build number. Increase for each shipment
|
#define CVF_BUILD_NUMBER "5" // Build number. Increase for each shipment
|
||||||
|
@ -271,7 +271,7 @@ void Camera::setProjectionAsPixelExact2D()
|
|||||||
void Camera::fitView(const BoundingBox& boundingBox, const Vec3d& dir, const Vec3d& up, double coverageFactor)
|
void Camera::fitView(const BoundingBox& boundingBox, const Vec3d& dir, const Vec3d& up, double coverageFactor)
|
||||||
{
|
{
|
||||||
// Use old view direction, but look towards model center
|
// Use old view direction, but look towards model center
|
||||||
Vec3d eye = fitViewEyePosition(boundingBox, dir, up, coverageFactor);
|
Vec3d eye = computeFitViewEyePosition(boundingBox, dir, up, coverageFactor, m_fieldOfViewYDeg, viewport()->aspectRatio());
|
||||||
|
|
||||||
// Will update cached values
|
// Will update cached values
|
||||||
setFromLookAt(eye, boundingBox.center(), up);
|
setFromLookAt(eye, boundingBox.center(), up);
|
||||||
@ -281,10 +281,8 @@ void Camera::fitView(const BoundingBox& boundingBox, const Vec3d& dir, const Vec
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
Vec3d Camera::fitViewEyePosition(const BoundingBox& boundingBox, const Vec3d& dir, const Vec3d& up, double coverageFactor) const
|
Vec3d Camera::computeFitViewEyePosition(const BoundingBox& boundingBox, const Vec3d& dir, const Vec3d& up, double coverageFactor, double fieldOfViewYDeg, double aspectRatio)
|
||||||
{
|
{
|
||||||
CVF_ASSERT(projection() == PERSPECTIVE);
|
|
||||||
|
|
||||||
cvf::Vec3d corners[8];
|
cvf::Vec3d corners[8];
|
||||||
boundingBox.cornerVertices(corners);
|
boundingBox.cornerVertices(corners);
|
||||||
|
|
||||||
@ -299,9 +297,9 @@ Vec3d Camera::fitViewEyePosition(const BoundingBox& boundingBox, const Vec3d& di
|
|||||||
cvf::Plane planeSide;
|
cvf::Plane planeSide;
|
||||||
planeSide.setFromPointAndNormal(boundingBox.center(), right);
|
planeSide.setFromPointAndNormal(boundingBox.center(), right);
|
||||||
|
|
||||||
// m_fieldOfViewYDeg is the complete angle in degrees, get half in radians
|
// fieldOfViewYDeg is the complete angle in degrees, get half in radians
|
||||||
double fovY = Math::toRadians(m_fieldOfViewYDeg/2.0);
|
double fovY = Math::toRadians(fieldOfViewYDeg/2.0);
|
||||||
double fovX = Math::atan(Math::tan(fovY)*aspectRatio());
|
double fovX = Math::atan(Math::tan(fovY)*aspectRatio);
|
||||||
|
|
||||||
double dist = 0;
|
double dist = 0;
|
||||||
|
|
||||||
@ -392,9 +390,7 @@ void Camera::fitViewOrtho(const BoundingBox& boundingBox, double eyeDist, const
|
|||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
/// Set the front and back clipping planes close to the given bounding box (perspective projection)
|
/// Set the front and back clipping planes close to the given bounding box
|
||||||
///
|
|
||||||
/// Note that this will setup a perspective projection with the new clipping planes.
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void Camera::setClipPlanesFromBoundingBox(const BoundingBox& boundingBox, double minNearPlaneDistance)
|
void Camera::setClipPlanesFromBoundingBox(const BoundingBox& boundingBox, double minNearPlaneDistance)
|
||||||
{
|
{
|
||||||
|
@ -65,8 +65,7 @@ public:
|
|||||||
|
|
||||||
void fitView(const BoundingBox& boundingBox, const Vec3d& dir, const Vec3d& up, double coverageFactor = 0.9);
|
void fitView(const BoundingBox& boundingBox, const Vec3d& dir, const Vec3d& up, double coverageFactor = 0.9);
|
||||||
void fitViewOrtho(const BoundingBox& boundingBox, double eyeDist, const Vec3d& dir, const Vec3d& up, double coverageFactor = 0.9);
|
void fitViewOrtho(const BoundingBox& boundingBox, double eyeDist, const Vec3d& dir, const Vec3d& up, double coverageFactor = 0.9);
|
||||||
|
static Vec3d computeFitViewEyePosition(const BoundingBox& boundingBox, const Vec3d& dir, const Vec3d& up, double coverageFactor, double fieldOfViewYDeg, double aspectRatio);
|
||||||
Vec3d fitViewEyePosition(const BoundingBox& boundingBox, const Vec3d& dir, const Vec3d& up, double coverageFactor = 0.9) const;
|
|
||||||
|
|
||||||
void setClipPlanesFromBoundingBox(const BoundingBox& boundingBox, double minNearPlaneDistance = 0.01);
|
void setClipPlanesFromBoundingBox(const BoundingBox& boundingBox, double minNearPlaneDistance = 0.01);
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ CameraAnimation::CameraAnimation(const Vec3d& currentPos, const Vec3d& currentDi
|
|||||||
/// }
|
/// }
|
||||||
/// \endcode
|
/// \endcode
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
bool CameraAnimation::newPosition(Vec3d* pos, Vec3d* dir, Vec3d* up)
|
bool CameraAnimation::newPosition(Vec3d* pos, Vec3d* dir, Vec3d* up, double* relativeTimeStamp)
|
||||||
{
|
{
|
||||||
if (m_animDone)
|
if (m_animDone)
|
||||||
{
|
{
|
||||||
@ -84,6 +84,7 @@ bool CameraAnimation::newPosition(Vec3d* pos, Vec3d* dir, Vec3d* up)
|
|||||||
*pos = m_newPos;
|
*pos = m_newPos;
|
||||||
*dir = m_newDir;
|
*dir = m_newDir;
|
||||||
*up = m_newUp;
|
*up = m_newUp;
|
||||||
|
if (relativeTimeStamp) *relativeTimeStamp = 1.0;
|
||||||
|
|
||||||
m_animDone = true;
|
m_animDone = true;
|
||||||
|
|
||||||
@ -94,6 +95,8 @@ bool CameraAnimation::newPosition(Vec3d* pos, Vec3d* dir, Vec3d* up)
|
|||||||
*dir = m_currentDir + (m_newDir - m_currentDir)*(timeNow/m_animDuration);
|
*dir = m_currentDir + (m_newDir - m_currentDir)*(timeNow/m_animDuration);
|
||||||
*up = m_currentUp + (m_newUp - m_currentUp )*(timeNow/m_animDuration);
|
*up = m_currentUp + (m_newUp - m_currentUp )*(timeNow/m_animDuration);
|
||||||
|
|
||||||
|
if (relativeTimeStamp) *relativeTimeStamp = timeNow/m_animDuration;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,10 +21,10 @@
|
|||||||
|
|
||||||
#include "cvfObject.h"
|
#include "cvfObject.h"
|
||||||
#include "cvfVector3.h"
|
#include "cvfVector3.h"
|
||||||
|
#include "cvfTimer.h"
|
||||||
|
|
||||||
namespace cvf {
|
namespace cvf {
|
||||||
|
|
||||||
class Timer;
|
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
//
|
//
|
||||||
@ -38,7 +38,7 @@ public:
|
|||||||
|
|
||||||
void setDuration(double seconds);
|
void setDuration(double seconds);
|
||||||
|
|
||||||
bool newPosition(Vec3d* pos, Vec3d* dir, Vec3d* up);
|
bool newPosition(Vec3d* pos, Vec3d* dir, Vec3d* up, double* relativeTimeStamp = NULL);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vec3d m_currentPos;
|
Vec3d m_currentPos;
|
||||||
|
@ -67,6 +67,12 @@
|
|||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
#include <GL/glu.h>
|
#include <GL/glu.h>
|
||||||
|
|
||||||
|
#elif defined(CVF_ANDROID)
|
||||||
|
|
||||||
|
// Android includes
|
||||||
|
#include <GLES2/gl2.h>
|
||||||
|
#include <GLES2/gl2ext.h>
|
||||||
|
|
||||||
#elif defined(CVF_IOS)
|
#elif defined(CVF_IOS)
|
||||||
|
|
||||||
// iOS includes
|
// iOS includes
|
||||||
|
@ -58,10 +58,8 @@ private:
|
|||||||
friend class OpenGLContextGroup;
|
friend class OpenGLContextGroup;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define CVF_LOG_RENDER_ERROR(OGL_CTX_PTR, THE_MESSAGE) OGL_CTX_PTR->group()->logger()->error((THE_MESSAGE), CVF_CODE_LOCATION)
|
|
||||||
|
|
||||||
#define CVF_LOG_RENDER_DEBUG(OGL_CTX_PTR, THE_MESSAGE) OGL_CTX_PTR->group()->logger()->debug((THE_MESSAGE), CVF_CODE_LOCATION)
|
#define CVF_LOG_RENDER_ERROR(OGL_CTX_PTR, THE_MESSAGE) CVF_LOG_ERROR( (OGL_CTX_PTR->group()->logger()), (THE_MESSAGE))
|
||||||
#define CVF_SHOULD_LOG_RENDER_DEBUG(OGL_CTX_PTR) OGL_CTX_PTR->group()->logger()->isDebugEnabled()
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include "cvfOpenGLContext.h"
|
#include "cvfOpenGLContext.h"
|
||||||
#include "cvfOpenGLResourceManager.h"
|
#include "cvfOpenGLResourceManager.h"
|
||||||
#include "cvfOpenGLCapabilities.h"
|
#include "cvfOpenGLCapabilities.h"
|
||||||
#include "cvfLogDestinationConsole.h"
|
#include "cvfLogManager.h"
|
||||||
|
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ OpenGLContextGroup::OpenGLContextGroup()
|
|||||||
m_wglewContextStruct(NULL)
|
m_wglewContextStruct(NULL)
|
||||||
{
|
{
|
||||||
m_resourceManager = new OpenGLResourceManager;
|
m_resourceManager = new OpenGLResourceManager;
|
||||||
m_logger = new Logger("cvf.OpenGL", Logger::LL_WARNING, new LogDestinationConsole);
|
m_logger = CVF_GET_LOGGER("cee.cvf.OpenGL");
|
||||||
m_capabilities = new OpenGLCapabilities;
|
m_capabilities = new OpenGLCapabilities;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,8 @@ OverlayColorLegend::OverlayColorLegend(Font* font)
|
|||||||
m_color(Color3::BLACK),
|
m_color(Color3::BLACK),
|
||||||
m_lineColor(Color3::BLACK),
|
m_lineColor(Color3::BLACK),
|
||||||
m_lineWidth(1),
|
m_lineWidth(1),
|
||||||
m_font(font)
|
m_font(font),
|
||||||
|
m_margin(4)
|
||||||
{
|
{
|
||||||
CVF_ASSERT(font);
|
CVF_ASSERT(font);
|
||||||
CVF_ASSERT(!font->isEmpty());
|
CVF_ASSERT(!font->isEmpty());
|
||||||
@ -220,7 +221,9 @@ bool OverlayColorLegend::pick(int x, int y, const Vec2i& position, const Vec2ui&
|
|||||||
{
|
{
|
||||||
Recti oglRect(position, static_cast<int>(size.x()), static_cast<int>(size.y()));
|
Recti oglRect(position, static_cast<int>(size.x()), static_cast<int>(size.y()));
|
||||||
|
|
||||||
OverlayColorLegendLayoutInfo layoutInViewPortCoords(oglRect.min(), Vec2ui(static_cast<uint>(oglRect.width()), static_cast<uint>(oglRect.height())));
|
OverlayColorLegendLayoutInfo layoutInViewPortCoords;
|
||||||
|
layoutInViewPortCoords.position = oglRect.min();
|
||||||
|
layoutInViewPortCoords.size = Vec2ui(static_cast<uint>(oglRect.width()), static_cast<uint>(oglRect.height()));
|
||||||
layoutInfo(&layoutInViewPortCoords);
|
layoutInfo(&layoutInViewPortCoords);
|
||||||
|
|
||||||
Vec2i legendBarOrigin = oglRect.min();
|
Vec2i legendBarOrigin = oglRect.min();
|
||||||
@ -258,7 +261,9 @@ void OverlayColorLegend::render(OpenGLContext* oglContext, const Vec2i& position
|
|||||||
|
|
||||||
// Get layout information
|
// Get layout information
|
||||||
// Todo: Cache this between renderings. Update only when needed.
|
// Todo: Cache this between renderings. Update only when needed.
|
||||||
OverlayColorLegendLayoutInfo layout(position, size);
|
OverlayColorLegendLayoutInfo layout;
|
||||||
|
layout.position = position;
|
||||||
|
layout.size = size;
|
||||||
layoutInfo(&layout);
|
layoutInfo(&layout);
|
||||||
|
|
||||||
// Set up text drawer
|
// Set up text drawer
|
||||||
@ -560,7 +565,7 @@ void OverlayColorLegend::layoutInfo(OverlayColorLegendLayoutInfo* layout)
|
|||||||
ref<Glyph> glyph = m_font->getGlyph(L'A');
|
ref<Glyph> glyph = m_font->getGlyph(L'A');
|
||||||
layout->charHeight = static_cast<float>(glyph->height());
|
layout->charHeight = static_cast<float>(glyph->height());
|
||||||
layout->lineSpacing = layout->charHeight*1.5f;
|
layout->lineSpacing = layout->charHeight*1.5f;
|
||||||
layout->margins = Vec2f(4.0f, 4.0f);
|
layout->margins = Vec2f(static_cast<float>(m_margin), static_cast<float>(m_margin));
|
||||||
|
|
||||||
float legendWidth = 25.0f;
|
float legendWidth = 25.0f;
|
||||||
float legendHeight = static_cast<float>(layout->size.y()) - 2*layout->margins.y() - static_cast<float>(m_titleStrings.size())*layout->lineSpacing - layout->lineSpacing;
|
float legendHeight = static_cast<float>(layout->size.y()) - 2*layout->margins.y() - static_cast<float>(m_titleStrings.size())*layout->lineSpacing - layout->lineSpacing;
|
||||||
@ -649,5 +654,30 @@ int OverlayColorLegend::lineWidth() const
|
|||||||
return m_lineWidth;
|
return m_lineWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void OverlayColorLegend::setWidthToFitText()
|
||||||
|
{
|
||||||
|
cvf::uint textWidth = 0;
|
||||||
|
for (size_t i = 0; i < m_titleStrings.size(); ++i)
|
||||||
|
{
|
||||||
|
cvf::uint lineWidth = m_font->textExtent(m_titleStrings[i]).x();
|
||||||
|
|
||||||
|
if (lineWidth > textWidth)
|
||||||
|
{
|
||||||
|
textWidth = lineWidth;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cvf::uint minWidth = m_font->textExtent("-0.00000e-000").x() + 40;
|
||||||
|
|
||||||
|
// +1 to cater for any rasterization inaccuracy
|
||||||
|
textWidth = CVF_MAX(minWidth + 1, textWidth + m_margin + 1);
|
||||||
|
|
||||||
|
m_sizeHint.x() = textWidth;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace cvf
|
} // namespace cvf
|
||||||
|
|
||||||
|
@ -31,34 +31,7 @@ class Font;
|
|||||||
class ShaderProgram;
|
class ShaderProgram;
|
||||||
class MatrixState;
|
class MatrixState;
|
||||||
class TextDrawer;
|
class TextDrawer;
|
||||||
|
struct OverlayColorLegendLayoutInfo;
|
||||||
|
|
||||||
//==================================================================================================
|
|
||||||
//
|
|
||||||
// Helper for storing layout info
|
|
||||||
//
|
|
||||||
//==================================================================================================
|
|
||||||
struct OverlayColorLegendLayoutInfo
|
|
||||||
{
|
|
||||||
OverlayColorLegendLayoutInfo(const Vec2i& pos, const Vec2ui& setSize)
|
|
||||||
{
|
|
||||||
position = pos;
|
|
||||||
size = setSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
float charHeight;
|
|
||||||
float lineSpacing;
|
|
||||||
Vec2f margins;
|
|
||||||
float tickX;
|
|
||||||
float x0, x1;
|
|
||||||
|
|
||||||
Rectf legendRect;
|
|
||||||
|
|
||||||
ref<DoubleArray> tickPixelPos;
|
|
||||||
|
|
||||||
Vec2i position;
|
|
||||||
Vec2ui size;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
@ -83,6 +56,7 @@ public:
|
|||||||
void configureLevels(const Color3ubArray& levelColors, const DoubleArray& tickValues);
|
void configureLevels(const Color3ubArray& levelColors, const DoubleArray& tickValues);
|
||||||
|
|
||||||
void setSizeHint(const Vec2ui& size);
|
void setSizeHint(const Vec2ui& size);
|
||||||
|
void setWidthToFitText();
|
||||||
|
|
||||||
void setColor(const Color3f& color);
|
void setColor(const Color3f& color);
|
||||||
const Color3f& color() const;
|
const Color3f& color() const;
|
||||||
@ -96,12 +70,12 @@ public:
|
|||||||
String title() const;
|
String title() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void render(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size, bool software);
|
void render(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size, bool software);
|
||||||
virtual void renderLegend(OpenGLContext* oglContext, OverlayColorLegendLayoutInfo* layout, const MatrixState& matrixState);
|
virtual void renderLegend(OpenGLContext* oglContext, OverlayColorLegendLayoutInfo* layout, const MatrixState& matrixState);
|
||||||
virtual void renderLegendImmediateMode(OpenGLContext* oglContext, OverlayColorLegendLayoutInfo* layout);
|
virtual void renderLegendImmediateMode(OpenGLContext* oglContext, OverlayColorLegendLayoutInfo* layout);
|
||||||
virtual void setupTextDrawer(TextDrawer* textDrawer, OverlayColorLegendLayoutInfo* layout);
|
virtual void setupTextDrawer(TextDrawer* textDrawer, OverlayColorLegendLayoutInfo* layout);
|
||||||
|
|
||||||
void layoutInfo(OverlayColorLegendLayoutInfo* layout);
|
void layoutInfo(OverlayColorLegendLayoutInfo* layout);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Color3ubArray m_levelColors; // Colors for n levels
|
Color3ubArray m_levelColors; // Colors for n levels
|
||||||
@ -115,6 +89,28 @@ protected:
|
|||||||
int m_lineWidth;
|
int m_lineWidth;
|
||||||
std::vector<String> m_titleStrings;
|
std::vector<String> m_titleStrings;
|
||||||
ref<Font> m_font;
|
ref<Font> m_font;
|
||||||
|
|
||||||
|
const cvf::uint m_margin;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//==================================================================================================
|
||||||
|
//
|
||||||
|
// Internal helper for storing layout info to allow for custom rendered legends
|
||||||
|
//
|
||||||
|
//==================================================================================================
|
||||||
|
struct OverlayColorLegendLayoutInfo
|
||||||
|
{
|
||||||
|
float charHeight;
|
||||||
|
float lineSpacing;
|
||||||
|
Vec2f margins;
|
||||||
|
float tickX;
|
||||||
|
float x0;
|
||||||
|
float x1;
|
||||||
|
Rectf legendRect;
|
||||||
|
Vec2i position;
|
||||||
|
Vec2ui size;
|
||||||
|
ref<DoubleArray> tickPixelPos;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -61,8 +61,6 @@ OverlayImage::OverlayImage(TextureImage* image)
|
|||||||
{
|
{
|
||||||
CVF_ASSERT(image);
|
CVF_ASSERT(image);
|
||||||
|
|
||||||
m_size.x() = image->width();
|
|
||||||
m_size.y() = image->height();
|
|
||||||
m_blendMode = NO_BLENDING;
|
m_blendMode = NO_BLENDING;
|
||||||
|
|
||||||
m_sampler = new cvf::Sampler;
|
m_sampler = new cvf::Sampler;
|
||||||
@ -342,6 +340,9 @@ void OverlayImage::setImage(TextureImage* image)
|
|||||||
m_image = image;
|
m_image = image;
|
||||||
m_pow2Image = NULL;
|
m_pow2Image = NULL;
|
||||||
|
|
||||||
|
m_size.x() = image->width();
|
||||||
|
m_size.y() = image->height();
|
||||||
|
|
||||||
m_texture = new Texture(image);
|
m_texture = new Texture(image);
|
||||||
|
|
||||||
m_textureBindings = NULL;
|
m_textureBindings = NULL;
|
||||||
@ -383,4 +384,22 @@ void OverlayImage::setBlending(Blending mode)
|
|||||||
m_blendMode = mode;
|
m_blendMode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
float OverlayImage::globalAlpha() const
|
||||||
|
{
|
||||||
|
return m_alpha;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
OverlayImage::Blending OverlayImage::blending() const
|
||||||
|
{
|
||||||
|
return m_blendMode;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace cvf
|
} // namespace cvf
|
||||||
|
@ -61,6 +61,8 @@ public:
|
|||||||
void setBlending(Blending mode);
|
void setBlending(Blending mode);
|
||||||
|
|
||||||
const TextureImage* image() const;
|
const TextureImage* image() const;
|
||||||
|
float globalAlpha() const;
|
||||||
|
Blending blending() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void render(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size, bool software);
|
void render(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size, bool software);
|
||||||
|
@ -454,15 +454,19 @@ void OverlayNavigationCube::renderCubeGeos(OpenGLContext* oglContext, bool softw
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Color3f faceColor;
|
Color3f faceColor = Color3f(Color3::WHITE);
|
||||||
switch (face)
|
|
||||||
|
if (!hasTexture)
|
||||||
{
|
{
|
||||||
case NCF_X_POS:
|
switch (face)
|
||||||
case NCF_X_NEG: faceColor = m_xFaceColor; break;
|
{
|
||||||
case NCF_Y_POS:
|
case NCF_X_POS:
|
||||||
case NCF_Y_NEG: faceColor = m_yFaceColor; break;
|
case NCF_X_NEG: faceColor = m_xFaceColor; break;
|
||||||
case NCF_Z_POS:
|
case NCF_Y_POS:
|
||||||
case NCF_Z_NEG: faceColor = m_zFaceColor; break;
|
case NCF_Y_NEG: faceColor = m_yFaceColor; break;
|
||||||
|
case NCF_Z_POS:
|
||||||
|
case NCF_Z_NEG: faceColor = m_zFaceColor; break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < m_cubeGeos.size(); ++i)
|
for (size_t i = 0; i < m_cubeGeos.size(); ++i)
|
||||||
@ -480,16 +484,12 @@ void OverlayNavigationCube::renderCubeGeos(OpenGLContext* oglContext, bool softw
|
|||||||
|
|
||||||
if (software)
|
if (software)
|
||||||
{
|
{
|
||||||
if (hasTexture)
|
#ifdef CVF_OPENGL_ES
|
||||||
{
|
CVF_FAIL_MSG("Not supported on OpenGL ES");
|
||||||
glColor3f(1.0f, 1.0f, 1.0f);
|
#else
|
||||||
}
|
glColor3fv(renderFaceColor.ptr());
|
||||||
else
|
|
||||||
{
|
|
||||||
glColor3fv(renderFaceColor.ptr());
|
|
||||||
}
|
|
||||||
|
|
||||||
m_cubeGeos[i]->renderImmediateMode(oglContext, matrixState);
|
m_cubeGeos[i]->renderImmediateMode(oglContext, matrixState);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -567,8 +567,12 @@ void OverlayNavigationCube::render2dItems(OpenGLContext* oglContext, const Vec2i
|
|||||||
|
|
||||||
if (software)
|
if (software)
|
||||||
{
|
{
|
||||||
|
#ifdef CVF_OPENGL_ES
|
||||||
|
CVF_FAIL_MSG("Not supported on OpenGL ES");
|
||||||
|
#else
|
||||||
glColor3fv(renderFaceColor.ptr());
|
glColor3fv(renderFaceColor.ptr());
|
||||||
m_2dGeos[i]->renderImmediateMode(oglContext, matrixState);
|
m_2dGeos[i]->renderImmediateMode(oglContext, matrixState);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1105,7 +1109,7 @@ OverlayNavigationCube::NavCubeItem OverlayNavigationCube::navCubeItem(NavCubeFac
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
bool OverlayNavigationCube::pick(int winCoordX, int winCoordY, const Vec2i& position, const Vec2ui& size)
|
bool OverlayNavigationCube::pick(int winCoordX, int winCoordY, const Vec2i& position, const Vec2ui& size)
|
||||||
{
|
{
|
||||||
return pickItem(winCoordX, winCoordY, position, size) != cvf::UNDEFINED_UINT;
|
return pickItem(winCoordX, winCoordY, position, size) != cvf::UNDEFINED_SIZE_T;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -53,6 +53,7 @@ public:
|
|||||||
MATERIAL_FF, //Fixed function
|
MATERIAL_FF, //Fixed function
|
||||||
NORMALIZE_FF, //Fixed function
|
NORMALIZE_FF, //Fixed function
|
||||||
TEXTURE_MAPPING_FF, //Fixed function
|
TEXTURE_MAPPING_FF, //Fixed function
|
||||||
|
CLIP_PLANES_FF, //Fixed function
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
COUNT // Must be the last entry
|
COUNT // Must be the last entry
|
||||||
|
@ -87,6 +87,7 @@ void RenderStateTracker::setupDefaultRenderStates()
|
|||||||
m_defaultRenderStates[RenderState::MATERIAL_FF] = new RenderStateMaterial_FF;
|
m_defaultRenderStates[RenderState::MATERIAL_FF] = new RenderStateMaterial_FF;
|
||||||
m_defaultRenderStates[RenderState::NORMALIZE_FF] = new RenderStateNormalize_FF(false);
|
m_defaultRenderStates[RenderState::NORMALIZE_FF] = new RenderStateNormalize_FF(false);
|
||||||
m_defaultRenderStates[RenderState::TEXTURE_MAPPING_FF] = new RenderStateTextureMapping_FF;
|
m_defaultRenderStates[RenderState::TEXTURE_MAPPING_FF] = new RenderStateTextureMapping_FF;
|
||||||
|
m_defaultRenderStates[RenderState::CLIP_PLANES_FF] = new RenderStateClipPlanes_FF;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -672,5 +672,100 @@ bool RenderStateTextureMapping_FF::isFixedFunction() const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace cvf
|
//==================================================================================================
|
||||||
|
///
|
||||||
|
/// \class cvf::RenderStateClipPlanes_FF
|
||||||
|
/// \ingroup Render
|
||||||
|
///
|
||||||
|
/// Encapsulate OpenGL glClipPlane() and glEnable()/glDisable() with GL_CLIP_PLANE0 + idx
|
||||||
|
///
|
||||||
|
//==================================================================================================
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
RenderStateClipPlanes_FF::RenderStateClipPlanes_FF()
|
||||||
|
: RenderState(CLIP_PLANES_FF)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RenderStateClipPlanes_FF::addPlane(const cvf::Plane& plane)
|
||||||
|
{
|
||||||
|
m_clipPlanes.push_back(plane);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
size_t RenderStateClipPlanes_FF::planeCount() const
|
||||||
|
{
|
||||||
|
return m_clipPlanes.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
const Plane& RenderStateClipPlanes_FF::plane(size_t index)
|
||||||
|
{
|
||||||
|
CVF_ASSERT(index < m_clipPlanes.size());
|
||||||
|
return m_clipPlanes[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RenderStateClipPlanes_FF::removeAllPlanes()
|
||||||
|
{
|
||||||
|
m_clipPlanes.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
/// Supports 6 clipping planes, as all implementations of OpenGL is required to have at least 6
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RenderStateClipPlanes_FF::applyOpenGL(OpenGLContext* oglContext) const
|
||||||
|
{
|
||||||
|
for (size_t idx = 0; idx < m_clipPlanes.size(); idx++)
|
||||||
|
{
|
||||||
|
if (idx > 5)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set and enable plane
|
||||||
|
GLdouble plane[4];
|
||||||
|
|
||||||
|
plane[0] = m_clipPlanes[idx].A();
|
||||||
|
plane[1] = m_clipPlanes[idx].B();
|
||||||
|
plane[2] = m_clipPlanes[idx].C();
|
||||||
|
plane[3] = m_clipPlanes[idx].D();
|
||||||
|
|
||||||
|
glClipPlane((GLenum)(GL_CLIP_PLANE0 + idx), plane);
|
||||||
|
glEnable((GLenum)(GL_CLIP_PLANE0 + idx));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t idx = m_clipPlanes.size(); idx < 6; idx++)
|
||||||
|
{
|
||||||
|
glDisable((GLenum)(GL_CLIP_PLANE0 + idx));
|
||||||
|
}
|
||||||
|
|
||||||
|
CVF_CHECK_OGL(oglContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RenderStateClipPlanes_FF::isFixedFunction() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace cvf
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include "cvfRenderState.h"
|
#include "cvfRenderState.h"
|
||||||
#include "cvfColor4.h"
|
#include "cvfColor4.h"
|
||||||
|
#include "cvfPlane.h"
|
||||||
|
|
||||||
namespace cvf {
|
namespace cvf {
|
||||||
|
|
||||||
@ -207,4 +208,26 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//==================================================================================================
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//==================================================================================================
|
||||||
|
class RenderStateClipPlanes_FF : public RenderState
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RenderStateClipPlanes_FF();
|
||||||
|
|
||||||
|
void addPlane(const cvf::Plane& plane);
|
||||||
|
size_t planeCount() const;
|
||||||
|
const Plane& plane(size_t index);
|
||||||
|
void removeAllPlanes();
|
||||||
|
|
||||||
|
virtual void applyOpenGL(OpenGLContext* oglContext) const;
|
||||||
|
virtual bool isFixedFunction() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector<Plane> m_clipPlanes;
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace cvf
|
} // namespace cvf
|
||||||
|
@ -7,7 +7,12 @@
|
|||||||
//#############################################################################################################################
|
//#############################################################################################################################
|
||||||
static const char calcClipDistances_inl[] =
|
static const char calcClipDistances_inl[] =
|
||||||
" \n"
|
" \n"
|
||||||
|
"#ifdef CVF_OPENGL_ES \n"
|
||||||
|
"uniform mediump int u_clipPlaneCount; \n"
|
||||||
|
"#else \n"
|
||||||
"uniform int u_clipPlaneCount; \n"
|
"uniform int u_clipPlaneCount; \n"
|
||||||
|
"#endif \n"
|
||||||
|
" \n"
|
||||||
"uniform vec4 u_ecClipPlanes[6]; \n"
|
"uniform vec4 u_ecClipPlanes[6]; \n"
|
||||||
" \n"
|
" \n"
|
||||||
"// The dimensioning should probably be via a define to be consistent between vs and fs \n"
|
"// The dimensioning should probably be via a define to be consistent between vs and fs \n"
|
||||||
@ -81,7 +86,7 @@ static const char checkDiscard_ClipDistances_inl[] =
|
|||||||
" int i; \n"
|
" int i; \n"
|
||||||
" for (i = 0; i < u_clipPlaneCount; i++) \n"
|
" for (i = 0; i < u_clipPlaneCount; i++) \n"
|
||||||
" { \n"
|
" { \n"
|
||||||
" if (v_clipDist[i] < 0) discard; \n"
|
" if (v_clipDist[i] < 0.0) discard; \n"
|
||||||
" } \n"
|
" } \n"
|
||||||
"} \n";
|
"} \n";
|
||||||
|
|
||||||
@ -103,7 +108,7 @@ static const char fs_CenterLitSpherePoints_inl[] =
|
|||||||
"{ \n"
|
"{ \n"
|
||||||
" //const vec3 ecLightPosition = vec3(0.5, 5.0, 7.0); \n"
|
" //const vec3 ecLightPosition = vec3(0.5, 5.0, 7.0); \n"
|
||||||
" //vec3 lightDir = normalize(ecLightPosition - v_ecPosition); \n"
|
" //vec3 lightDir = normalize(ecLightPosition - v_ecPosition); \n"
|
||||||
" const vec3 lightDir = vec3(0, 0, 1); \n"
|
" const vec3 lightDir = vec3(0.0, 0.0, 1.0); \n"
|
||||||
" \n"
|
" \n"
|
||||||
" // Calculate normal from texture coordinates \n"
|
" // Calculate normal from texture coordinates \n"
|
||||||
" vec3 N; \n"
|
" vec3 N; \n"
|
||||||
@ -111,8 +116,8 @@ static const char fs_CenterLitSpherePoints_inl[] =
|
|||||||
" float mag = dot(N.xy, N.xy); \n"
|
" float mag = dot(N.xy, N.xy); \n"
|
||||||
" \n"
|
" \n"
|
||||||
" // Kill pixels outside circle \n"
|
" // Kill pixels outside circle \n"
|
||||||
" if (mag > 1) discard; \n"
|
" if (mag > 1.0) discard; \n"
|
||||||
" N.z = sqrt(1 - mag); \n"
|
" N.z = sqrt(1.0 - mag); \n"
|
||||||
" \n"
|
" \n"
|
||||||
" // Calculate diffuse lighting \n"
|
" // Calculate diffuse lighting \n"
|
||||||
" float diffuse = max(0.0, dot(lightDir, N)); \n"
|
" float diffuse = max(0.0, dot(lightDir, N)); \n"
|
||||||
@ -120,7 +125,7 @@ static const char fs_CenterLitSpherePoints_inl[] =
|
|||||||
" vec4 color = srcFragment(); \n"
|
" vec4 color = srcFragment(); \n"
|
||||||
" gl_FragColor = vec4(color.rgb*diffuse, color.a); \n"
|
" gl_FragColor = vec4(color.rgb*diffuse, color.a); \n"
|
||||||
" \n"
|
" \n"
|
||||||
" //gl_FragDepth = gl_FragCoord.z - 15.0*(1-mag); \n"
|
" //gl_FragDepth = gl_FragCoord.z - 15.0*(1.0-mag); \n"
|
||||||
"} \n";
|
"} \n";
|
||||||
|
|
||||||
|
|
||||||
@ -454,8 +459,8 @@ static const char fs_ParticleTraceComets_inl[] =
|
|||||||
" vec3 N; \n"
|
" vec3 N; \n"
|
||||||
" N.xy = vec2(v_circleFactors.x, v_circleFactors.y); \n"
|
" N.xy = vec2(v_circleFactors.x, v_circleFactors.y); \n"
|
||||||
" float mag = dot(N.xy, N.xy); \n"
|
" float mag = dot(N.xy, N.xy); \n"
|
||||||
" if (mag > 1) discard; \n"
|
" if (mag > 1.0) discard; \n"
|
||||||
" N.z = sqrt(1 - mag); \n"
|
" N.z = sqrt(1.0 - mag); \n"
|
||||||
" \n"
|
" \n"
|
||||||
" float diffuse = max(0.0, dot(lightDir, N)); \n"
|
" float diffuse = max(0.0, dot(lightDir, N)); \n"
|
||||||
" \n"
|
" \n"
|
||||||
@ -941,7 +946,7 @@ static const char vs_DistanceScaledPoints_inl[] =
|
|||||||
" // Compute the point diameter in window coords (pixels) \n"
|
" // Compute the point diameter in window coords (pixels) \n"
|
||||||
" // Scale with distance for perspective correction of the size \n"
|
" // Scale with distance for perspective correction of the size \n"
|
||||||
" float dist = length(v_ecPosition); \n"
|
" float dist = length(v_ecPosition); \n"
|
||||||
" gl_PointSize = 2*u_pointRadius/(cvfu_pixelHeightAtUnitDistance*dist); \n"
|
" gl_PointSize = 2.0*u_pointRadius/(cvfu_pixelHeightAtUnitDistance*dist); \n"
|
||||||
"} \n";
|
"} \n";
|
||||||
|
|
||||||
|
|
||||||
@ -968,10 +973,18 @@ static const char vs_EnvironmentMapping_inl[] =
|
|||||||
"//-------------------------------------------------------------------------------------------------- \n"
|
"//-------------------------------------------------------------------------------------------------- \n"
|
||||||
"void main () \n"
|
"void main () \n"
|
||||||
"{ \n"
|
"{ \n"
|
||||||
|
"#ifdef CVF_CALC_SHADOW_COORD_IMPL \n"
|
||||||
|
" calcShadowCoord(); \n"
|
||||||
|
"#endif \n"
|
||||||
|
" \n"
|
||||||
" // Transforms vertex position and normal vector to eye space \n"
|
" // Transforms vertex position and normal vector to eye space \n"
|
||||||
" v_ecPosition = (cvfu_modelViewMatrix * cvfa_vertex).xyz; \n"
|
" v_ecPosition = (cvfu_modelViewMatrix * cvfa_vertex).xyz; \n"
|
||||||
" v_ecNormal = cvfu_normalMatrix * cvfa_normal; \n"
|
" v_ecNormal = cvfu_normalMatrix * cvfa_normal; \n"
|
||||||
" \n"
|
" \n"
|
||||||
|
"#ifdef CVF_CALC_CLIP_DISTANCES_IMPL \n"
|
||||||
|
" calcClipDistances(vec4(v_ecPosition, 1)); \n"
|
||||||
|
"#endif \n"
|
||||||
|
" \n"
|
||||||
" gl_Position = cvfu_modelViewProjectionMatrix*cvfa_vertex; \n"
|
" gl_Position = cvfu_modelViewProjectionMatrix*cvfa_vertex; \n"
|
||||||
" \n"
|
" \n"
|
||||||
" // Compute the texture coordinate for the environment map texture lookup \n"
|
" // Compute the texture coordinate for the environment map texture lookup \n"
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
|
|
||||||
|
#ifdef CVF_OPENGL_ES
|
||||||
|
uniform mediump int u_clipPlaneCount;
|
||||||
|
#else
|
||||||
uniform int u_clipPlaneCount;
|
uniform int u_clipPlaneCount;
|
||||||
|
#endif
|
||||||
|
|
||||||
uniform vec4 u_ecClipPlanes[6];
|
uniform vec4 u_ecClipPlanes[6];
|
||||||
|
|
||||||
// The dimensioning should probably be via a define to be consistent between vs and fs
|
// The dimensioning should probably be via a define to be consistent between vs and fs
|
||||||
|
@ -13,6 +13,6 @@ void checkDiscardFragment()
|
|||||||
int i;
|
int i;
|
||||||
for (i = 0; i < u_clipPlaneCount; i++)
|
for (i = 0; i < u_clipPlaneCount; i++)
|
||||||
{
|
{
|
||||||
if (v_clipDist[i] < 0) discard;
|
if (v_clipDist[i] < 0.0) discard;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ void main()
|
|||||||
{
|
{
|
||||||
//const vec3 ecLightPosition = vec3(0.5, 5.0, 7.0);
|
//const vec3 ecLightPosition = vec3(0.5, 5.0, 7.0);
|
||||||
//vec3 lightDir = normalize(ecLightPosition - v_ecPosition);
|
//vec3 lightDir = normalize(ecLightPosition - v_ecPosition);
|
||||||
const vec3 lightDir = vec3(0, 0, 1);
|
const vec3 lightDir = vec3(0.0, 0.0, 1.0);
|
||||||
|
|
||||||
// Calculate normal from texture coordinates
|
// Calculate normal from texture coordinates
|
||||||
vec3 N;
|
vec3 N;
|
||||||
@ -19,8 +19,8 @@ void main()
|
|||||||
float mag = dot(N.xy, N.xy);
|
float mag = dot(N.xy, N.xy);
|
||||||
|
|
||||||
// Kill pixels outside circle
|
// Kill pixels outside circle
|
||||||
if (mag > 1) discard;
|
if (mag > 1.0) discard;
|
||||||
N.z = sqrt(1 - mag);
|
N.z = sqrt(1.0 - mag);
|
||||||
|
|
||||||
// Calculate diffuse lighting
|
// Calculate diffuse lighting
|
||||||
float diffuse = max(0.0, dot(lightDir, N));
|
float diffuse = max(0.0, dot(lightDir, N));
|
||||||
@ -28,7 +28,7 @@ void main()
|
|||||||
vec4 color = srcFragment();
|
vec4 color = srcFragment();
|
||||||
gl_FragColor = vec4(color.rgb*diffuse, color.a);
|
gl_FragColor = vec4(color.rgb*diffuse, color.a);
|
||||||
|
|
||||||
//gl_FragDepth = gl_FragCoord.z - 15.0*(1-mag);
|
//gl_FragDepth = gl_FragCoord.z - 15.0*(1.0-mag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,8 +15,8 @@ void main()
|
|||||||
vec3 N;
|
vec3 N;
|
||||||
N.xy = vec2(v_circleFactors.x, v_circleFactors.y);
|
N.xy = vec2(v_circleFactors.x, v_circleFactors.y);
|
||||||
float mag = dot(N.xy, N.xy);
|
float mag = dot(N.xy, N.xy);
|
||||||
if (mag > 1) discard;
|
if (mag > 1.0) discard;
|
||||||
N.z = sqrt(1 - mag);
|
N.z = sqrt(1.0 - mag);
|
||||||
|
|
||||||
float diffuse = max(0.0, dot(lightDir, N));
|
float diffuse = max(0.0, dot(lightDir, N));
|
||||||
|
|
||||||
|
@ -27,5 +27,5 @@ void main ()
|
|||||||
// Compute the point diameter in window coords (pixels)
|
// Compute the point diameter in window coords (pixels)
|
||||||
// Scale with distance for perspective correction of the size
|
// Scale with distance for perspective correction of the size
|
||||||
float dist = length(v_ecPosition);
|
float dist = length(v_ecPosition);
|
||||||
gl_PointSize = 2*u_pointRadius/(cvfu_pixelHeightAtUnitDistance*dist);
|
gl_PointSize = 2.0*u_pointRadius/(cvfu_pixelHeightAtUnitDistance*dist);
|
||||||
}
|
}
|
||||||
|
@ -17,10 +17,18 @@ varying vec2 v_texCoord;
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void main ()
|
void main ()
|
||||||
{
|
{
|
||||||
|
#ifdef CVF_CALC_SHADOW_COORD_IMPL
|
||||||
|
calcShadowCoord();
|
||||||
|
#endif
|
||||||
|
|
||||||
// Transforms vertex position and normal vector to eye space
|
// Transforms vertex position and normal vector to eye space
|
||||||
v_ecPosition = (cvfu_modelViewMatrix * cvfa_vertex).xyz;
|
v_ecPosition = (cvfu_modelViewMatrix * cvfa_vertex).xyz;
|
||||||
v_ecNormal = cvfu_normalMatrix * cvfa_normal;
|
v_ecNormal = cvfu_normalMatrix * cvfa_normal;
|
||||||
|
|
||||||
|
#ifdef CVF_CALC_CLIP_DISTANCES_IMPL
|
||||||
|
calcClipDistances(vec4(v_ecPosition, 1));
|
||||||
|
#endif
|
||||||
|
|
||||||
gl_Position = cvfu_modelViewProjectionMatrix*cvfa_vertex;
|
gl_Position = cvfu_modelViewProjectionMatrix*cvfa_vertex;
|
||||||
|
|
||||||
// Compute the texture coordinate for the environment map texture lookup
|
// Compute the texture coordinate for the environment map texture lookup
|
||||||
|
@ -26,12 +26,12 @@
|
|||||||
#include "cvfEffect.h"
|
#include "cvfEffect.h"
|
||||||
#include "cvfRenderStateSet.h"
|
#include "cvfRenderStateSet.h"
|
||||||
#include "cvfShaderProgram.h"
|
#include "cvfShaderProgram.h"
|
||||||
#include "cvfTrace.h"
|
|
||||||
#include "cvfOpenGL.h"
|
#include "cvfOpenGL.h"
|
||||||
#include "cvfBufferObjectManaged.h"
|
#include "cvfBufferObjectManaged.h"
|
||||||
#include "cvfMatrixState.h"
|
#include "cvfMatrixState.h"
|
||||||
#include "cvfCamera.h"
|
#include "cvfCamera.h"
|
||||||
#include "cvfRenderStateTextureBindings.h"
|
#include "cvfRenderStateTextureBindings.h"
|
||||||
|
#include "cvfLogManager.h"
|
||||||
|
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
|
|
||||||
@ -59,7 +59,8 @@ RenderEngine::RenderEngine()
|
|||||||
m_disableDrawableRender(false),
|
m_disableDrawableRender(false),
|
||||||
m_disableApplyEffects(false),
|
m_disableApplyEffects(false),
|
||||||
m_forceImmediateMode(false),
|
m_forceImmediateMode(false),
|
||||||
m_enableItemCountUpdate(false)
|
m_enableItemCountUpdate(false),
|
||||||
|
m_logger(CVF_GET_LOGGER("cee.cvf"))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,11 +111,7 @@ void RenderEngine::render(OpenGLContext* oglContext, RenderQueue* renderQueue, s
|
|||||||
size_t numPartsInQueue = renderQueue->count();
|
size_t numPartsInQueue = renderQueue->count();
|
||||||
size_t numPartsToDraw = std::min(numPartsInQueue, maxNumPartsToDraw);
|
size_t numPartsToDraw = std::min(numPartsInQueue, maxNumPartsToDraw);
|
||||||
|
|
||||||
bool debugLogging = CVF_SHOULD_LOG_RENDER_DEBUG(oglContext);
|
CVF_LOG_DEBUG(m_logger, "RenderEngine::render(), numParts=" + String(static_cast<uint>(numPartsInQueue)));
|
||||||
if (debugLogging)
|
|
||||||
{
|
|
||||||
CVF_LOG_RENDER_DEBUG(oglContext, "RenderEngine::render(), numParts=" + String(static_cast<uint>(numPartsInQueue)));
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t i;
|
size_t i;
|
||||||
for (i = 0; i < numPartsToDraw; i++)
|
for (i = 0; i < numPartsToDraw; i++)
|
||||||
@ -129,10 +126,7 @@ void RenderEngine::render(OpenGLContext* oglContext, RenderQueue* renderQueue, s
|
|||||||
CVF_ASSERT(effect);
|
CVF_ASSERT(effect);
|
||||||
CVF_ASSERT(part);
|
CVF_ASSERT(part);
|
||||||
|
|
||||||
if (debugLogging)
|
CVF_LOG_DEBUG(m_logger, String("part#=%1, partName='%2'").arg(static_cast<uint>(i)).arg(part->name()));
|
||||||
{
|
|
||||||
CVF_LOG_RENDER_DEBUG(oglContext, String("part#=%1, partName='%2'").arg(static_cast<uint>(i)).arg(part->name()));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update matrix state to reflect any part transformations
|
// Update matrix state to reflect any part transformations
|
||||||
// Register if the pass modifies the view matrix so that we can reset it at the end of this part
|
// Register if the pass modifies the view matrix so that we can reset it at the end of this part
|
||||||
|
@ -28,6 +28,7 @@ class RenderQueue;
|
|||||||
class UniformSet;
|
class UniformSet;
|
||||||
class Camera;
|
class Camera;
|
||||||
class OpenGLContext;
|
class OpenGLContext;
|
||||||
|
class Logger;
|
||||||
|
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
@ -73,6 +74,8 @@ private:
|
|||||||
bool m_disableApplyEffects;
|
bool m_disableApplyEffects;
|
||||||
bool m_forceImmediateMode; // Can be used to force immediate mode drawing for debugging purposes (good old glBegin()/glEnd())
|
bool m_forceImmediateMode; // Can be used to force immediate mode drawing for debugging purposes (good old glBegin()/glEnd())
|
||||||
bool m_enableItemCountUpdate;
|
bool m_enableItemCountUpdate;
|
||||||
|
|
||||||
|
ref<Logger> m_logger;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
#include "cvfShaderProgram.h"
|
#include "cvfShaderProgram.h"
|
||||||
#include "cvfRayIntersectSpec.h"
|
#include "cvfRayIntersectSpec.h"
|
||||||
#include "cvfHitItemCollection.h"
|
#include "cvfHitItemCollection.h"
|
||||||
|
#include "cvfLogManager.h"
|
||||||
|
|
||||||
namespace cvf {
|
namespace cvf {
|
||||||
|
|
||||||
@ -67,7 +68,8 @@ Rendering::Rendering(const String& renderingName)
|
|||||||
m_enableMask(0xffffffff),
|
m_enableMask(0xffffffff),
|
||||||
m_clearMode(Viewport::CLEAR_COLOR_DEPTH),
|
m_clearMode(Viewport::CLEAR_COLOR_DEPTH),
|
||||||
m_maxNumPartsToDraw(std::numeric_limits<size_t>::max()),
|
m_maxNumPartsToDraw(std::numeric_limits<size_t>::max()),
|
||||||
m_enablePerformanceTiming(true)
|
m_enablePerformanceTiming(true),
|
||||||
|
m_logger(CVF_GET_LOGGER("cee.cvf"))
|
||||||
{
|
{
|
||||||
m_camera = new Camera;
|
m_camera = new Camera;
|
||||||
m_visibleParts = new PartRenderHintCollection;
|
m_visibleParts = new PartRenderHintCollection;
|
||||||
@ -142,11 +144,7 @@ void Rendering::render(OpenGLContext* oglContext)
|
|||||||
{
|
{
|
||||||
CVF_ASSERT(m_camera.notNull() && m_camera->viewport());
|
CVF_ASSERT(m_camera.notNull() && m_camera->viewport());
|
||||||
|
|
||||||
bool debugLogging = CVF_SHOULD_LOG_RENDER_DEBUG(oglContext);
|
CVF_LOG_DEBUG(m_logger, String("Entering Rendering::render(), renderingName='%1'").arg(m_renderingName));
|
||||||
if (debugLogging)
|
|
||||||
{
|
|
||||||
CVF_LOG_RENDER_DEBUG(oglContext, String("Entering Rendering::render(), renderingName='%1'").arg(m_renderingName));
|
|
||||||
}
|
|
||||||
|
|
||||||
CVF_CHECK_OGL(oglContext);
|
CVF_CHECK_OGL(oglContext);
|
||||||
|
|
||||||
@ -278,10 +276,7 @@ void Rendering::render(OpenGLContext* oglContext)
|
|||||||
|
|
||||||
CVF_CHECK_OGL(oglContext);
|
CVF_CHECK_OGL(oglContext);
|
||||||
|
|
||||||
if (debugLogging)
|
CVF_LOG_DEBUG(m_logger, String("Exiting Rendering::render(), renderingName='%1'").arg(m_renderingName));
|
||||||
{
|
|
||||||
CVF_LOG_RENDER_DEBUG(oglContext, String("Exiting Rendering::render(), renderingName='%1'").arg(m_renderingName));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -293,6 +288,13 @@ void Rendering::renderOverlayItems(OpenGLContext* oglContext, bool useSoftwareRe
|
|||||||
OverlayItemRectMap itemRectMap;
|
OverlayItemRectMap itemRectMap;
|
||||||
calculateOverlayItemLayout(&itemRectMap);
|
calculateOverlayItemLayout(&itemRectMap);
|
||||||
|
|
||||||
|
// Must setup a scissor to limit the overlay items to the current viewport, as they might setup a local viewport (e.g. navigation cube)
|
||||||
|
GLboolean scissorWasOn = glIsEnabled(GL_SCISSOR_TEST);
|
||||||
|
int scissorBox[4] = {0, 0, -1, -1};
|
||||||
|
glGetIntegerv(GL_SCISSOR_BOX, scissorBox);
|
||||||
|
glScissor(static_cast<GLsizei>(m_camera->viewport()->x()), static_cast<GLsizei>(m_camera->viewport()->y()), static_cast<GLsizei>(m_camera->viewport()->width()), static_cast<GLsizei>(m_camera->viewport()->height()));
|
||||||
|
glEnable(GL_SCISSOR_TEST);
|
||||||
|
|
||||||
OverlayItemRectMap::iterator it;
|
OverlayItemRectMap::iterator it;
|
||||||
for (it = itemRectMap.begin(); it != itemRectMap.end(); ++it)
|
for (it = itemRectMap.begin(); it != itemRectMap.end(); ++it)
|
||||||
{
|
{
|
||||||
@ -327,6 +329,10 @@ void Rendering::renderOverlayItems(OpenGLContext* oglContext, bool useSoftwareRe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Restore scissor settings
|
||||||
|
if (!scissorWasOn) glDisable(GL_SCISSOR_TEST);
|
||||||
|
glScissor(scissorBox[0], scissorBox[1], scissorBox[2], scissorBox[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -155,6 +155,8 @@ private:
|
|||||||
|
|
||||||
PerformanceInfo m_performanceInfo;
|
PerformanceInfo m_performanceInfo;
|
||||||
bool m_enablePerformanceTiming;
|
bool m_enablePerformanceTiming;
|
||||||
|
|
||||||
|
ref<Logger> m_logger;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user