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
|
||||
|
||||
#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
|
||||
#endif
|
||||
|
||||
@ -50,7 +50,7 @@
|
||||
#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
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
@ -88,7 +88,7 @@ typedef unsigned int uint;
|
||||
// 64bit integer support via the int64 type
|
||||
#ifdef WIN32
|
||||
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;
|
||||
#endif
|
||||
|
||||
|
@ -33,6 +33,12 @@
|
||||
|
||||
namespace cvf {
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
class FileWrapper
|
||||
{
|
||||
public:
|
||||
@ -77,6 +83,7 @@ private:
|
||||
};
|
||||
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
/// \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();
|
||||
if (logEventLevel == Logger::LL_ERROR)
|
||||
{
|
||||
str = "ERROR: " + logEvent.message();
|
||||
str = logEvent.source() + "**ERROR**: " + logEvent.message();
|
||||
addLocationInfo = true;
|
||||
}
|
||||
else if (logEventLevel == Logger::LL_WARNING)
|
||||
{
|
||||
str = "warn: " + logEvent.message();
|
||||
str = logEvent.source() + "(warn): " + logEvent.message();
|
||||
}
|
||||
else if (logEventLevel == Logger::LL_INFO)
|
||||
{
|
||||
str = "info: " + logEvent.message();
|
||||
str = logEvent.source() + "(i): " + logEvent.message();
|
||||
}
|
||||
else if (logEventLevel == Logger::LL_DEBUG)
|
||||
{
|
||||
str = "debug: " + logEvent.message();
|
||||
str = logEvent.source() + "(d): " + logEvent.message();
|
||||
}
|
||||
|
||||
if (addLocationInfo)
|
||||
|
@ -49,10 +49,10 @@ private:
|
||||
void swap(LogEvent& other);
|
||||
|
||||
private:
|
||||
String m_source;
|
||||
String m_message;
|
||||
Logger::Level m_level;
|
||||
CodeLocation m_codeLocation;
|
||||
String m_source; // Source of the log event, normally name of the logger
|
||||
String m_message; // The logged message
|
||||
Logger::Level m_level; // The log level of the event
|
||||
CodeLocation m_codeLocation; // Source code location of log statement
|
||||
};
|
||||
|
||||
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
#include "cvfBase.h"
|
||||
#include "cvfLogManager.h"
|
||||
#include "cvfLogger.h"
|
||||
#include "cvfLogDestinationConsole.h"
|
||||
|
||||
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)
|
||||
{
|
||||
@ -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)
|
||||
{
|
||||
|
@ -22,12 +22,12 @@
|
||||
#include "cvfObject.h"
|
||||
#include "cvfString.h"
|
||||
#include "cvfMutex.h"
|
||||
#include "cvfLogger.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace cvf {
|
||||
|
||||
class Logger;
|
||||
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
|
||||
|
||||
|
@ -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.
|
||||
/// \sa Logger::Level
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void Logger::setLevel(int logLevel)
|
||||
{
|
||||
|
@ -27,7 +27,7 @@
|
||||
#pragma warning (pop)
|
||||
#endif
|
||||
|
||||
#ifdef CVF_LINUX
|
||||
#if defined CVF_LINUX || defined(CVF_ANDROID)
|
||||
#include <pthread.h>
|
||||
#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
|
||||
{
|
||||
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.
|
||||
std::string toStdString() const;
|
||||
std::wstring toStdWString() const;
|
||||
|
||||
CharArray toUtf8() const;
|
||||
|
||||
static String fromAscii(const char* str, size_t strSize = npos);
|
||||
static String fromUtf8(const char* str);
|
||||
|
||||
bool isEmpty() const;
|
||||
|
@ -27,7 +27,7 @@
|
||||
#pragma warning (pop)
|
||||
#endif
|
||||
|
||||
#ifdef CVF_LINUX
|
||||
#if defined(CVF_LINUX) || defined(CVF_ANDROID)
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
@ -68,7 +68,7 @@ public:
|
||||
};
|
||||
#endif //WIN32
|
||||
|
||||
#ifdef CVF_LINUX
|
||||
#if defined(CVF_LINUX) || defined(CVF_ANDROID)
|
||||
class PrivateTimerState
|
||||
{
|
||||
public:
|
||||
@ -83,7 +83,7 @@ public:
|
||||
timespec m_timeStart;
|
||||
timespec m_timeMark;
|
||||
};
|
||||
#endif // CVF_LINUX
|
||||
#endif // CVF_LINUX || CVF_ANDROID
|
||||
|
||||
|
||||
#if defined(CVF_IOS) || defined(CVF_OSX)
|
||||
@ -107,7 +107,7 @@ public:
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// 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)
|
||||
{
|
||||
timespec temp;
|
||||
@ -170,7 +170,7 @@ void Timer::restart()
|
||||
m_timerState->m_startTick = tick.QuadPart;
|
||||
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);
|
||||
m_timerState->m_timeMark = m_timerState->m_timeStart;
|
||||
@ -196,7 +196,7 @@ double Timer::time() const
|
||||
QueryPerformanceCounter(&nowTick);
|
||||
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;
|
||||
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);
|
||||
m_timerState->m_lastLapTick = nowTick.QuadPart;
|
||||
|
||||
#elif CVF_LINUX
|
||||
#elif defined(CVF_LINUX) || defined(CVF_ANDROID)
|
||||
|
||||
timespec timeNow;
|
||||
clock_gettime(CLOCK_MONOTONIC, &timeNow);
|
||||
|
@ -31,10 +31,12 @@
|
||||
#include <cstdarg>
|
||||
#endif
|
||||
|
||||
#ifdef CVF_ANDROID
|
||||
#include <android/log.h>
|
||||
#endif
|
||||
|
||||
namespace cvf {
|
||||
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
/// \class cvf::Trace
|
||||
@ -70,6 +72,8 @@ void Trace::show(const char* format, ...)
|
||||
|
||||
#ifdef WIN32
|
||||
_vsnprintf_s(temp, maxFormatLength, format, argList);
|
||||
#elif defined(CVF_ANDROID)
|
||||
__android_log_print(ANDROID_LOG_DEBUG, "CVF_TAG", format, argList);
|
||||
#else
|
||||
vsprintf(temp, format, argList);
|
||||
#endif
|
||||
@ -115,6 +119,8 @@ void Trace::showTraceOutput(String text, bool addNewLine)
|
||||
WriteConsoleA(hStdOutputHandle, ascii.ptr(), stringLength, &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
|
||||
fprintf(stderr, "%s", text.toAscii().ptr());
|
||||
if (addNewLine)
|
||||
|
@ -24,4 +24,4 @@
|
||||
#define CVF_MAJOR_VERSION "0" // Major version number
|
||||
#define CVF_MINOR_VERSION "9" // Minor version number
|
||||
#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)
|
||||
{
|
||||
// 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
|
||||
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];
|
||||
boundingBox.cornerVertices(corners);
|
||||
|
||||
@ -299,9 +297,9 @@ Vec3d Camera::fitViewEyePosition(const BoundingBox& boundingBox, const Vec3d& di
|
||||
cvf::Plane planeSide;
|
||||
planeSide.setFromPointAndNormal(boundingBox.center(), right);
|
||||
|
||||
// m_fieldOfViewYDeg is the complete angle in degrees, get half in radians
|
||||
double fovY = Math::toRadians(m_fieldOfViewYDeg/2.0);
|
||||
double fovX = Math::atan(Math::tan(fovY)*aspectRatio());
|
||||
// fieldOfViewYDeg is the complete angle in degrees, get half in radians
|
||||
double fovY = Math::toRadians(fieldOfViewYDeg/2.0);
|
||||
double fovX = Math::atan(Math::tan(fovY)*aspectRatio);
|
||||
|
||||
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)
|
||||
///
|
||||
/// Note that this will setup a perspective projection with the new clipping planes.
|
||||
/// Set the front and back clipping planes close to the given bounding box
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
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 fitViewOrtho(const BoundingBox& boundingBox, double eyeDist, const Vec3d& dir, const Vec3d& up, double coverageFactor = 0.9);
|
||||
|
||||
Vec3d fitViewEyePosition(const BoundingBox& boundingBox, const Vec3d& dir, const Vec3d& up, double coverageFactor = 0.9) const;
|
||||
static Vec3d computeFitViewEyePosition(const BoundingBox& boundingBox, const Vec3d& dir, const Vec3d& up, double coverageFactor, double fieldOfViewYDeg, double aspectRatio);
|
||||
|
||||
void setClipPlanesFromBoundingBox(const BoundingBox& boundingBox, double minNearPlaneDistance = 0.01);
|
||||
|
||||
|
@ -65,7 +65,7 @@ CameraAnimation::CameraAnimation(const Vec3d& currentPos, const Vec3d& currentDi
|
||||
/// }
|
||||
/// \endcode
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool CameraAnimation::newPosition(Vec3d* pos, Vec3d* dir, Vec3d* up)
|
||||
bool CameraAnimation::newPosition(Vec3d* pos, Vec3d* dir, Vec3d* up, double* relativeTimeStamp)
|
||||
{
|
||||
if (m_animDone)
|
||||
{
|
||||
@ -84,6 +84,7 @@ bool CameraAnimation::newPosition(Vec3d* pos, Vec3d* dir, Vec3d* up)
|
||||
*pos = m_newPos;
|
||||
*dir = m_newDir;
|
||||
*up = m_newUp;
|
||||
if (relativeTimeStamp) *relativeTimeStamp = 1.0;
|
||||
|
||||
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);
|
||||
*up = m_currentUp + (m_newUp - m_currentUp )*(timeNow/m_animDuration);
|
||||
|
||||
if (relativeTimeStamp) *relativeTimeStamp = timeNow/m_animDuration;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -21,10 +21,10 @@
|
||||
|
||||
#include "cvfObject.h"
|
||||
#include "cvfVector3.h"
|
||||
#include "cvfTimer.h"
|
||||
|
||||
namespace cvf {
|
||||
|
||||
class Timer;
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
@ -38,7 +38,7 @@ public:
|
||||
|
||||
void setDuration(double seconds);
|
||||
|
||||
bool newPosition(Vec3d* pos, Vec3d* dir, Vec3d* up);
|
||||
bool newPosition(Vec3d* pos, Vec3d* dir, Vec3d* up, double* relativeTimeStamp = NULL);
|
||||
|
||||
private:
|
||||
Vec3d m_currentPos;
|
||||
|
@ -67,6 +67,12 @@
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
|
||||
#elif defined(CVF_ANDROID)
|
||||
|
||||
// Android includes
|
||||
#include <GLES2/gl2.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
|
||||
#elif defined(CVF_IOS)
|
||||
|
||||
// iOS includes
|
||||
|
@ -58,10 +58,8 @@ private:
|
||||
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_SHOULD_LOG_RENDER_DEBUG(OGL_CTX_PTR) OGL_CTX_PTR->group()->logger()->isDebugEnabled()
|
||||
#define CVF_LOG_RENDER_ERROR(OGL_CTX_PTR, THE_MESSAGE) CVF_LOG_ERROR( (OGL_CTX_PTR->group()->logger()), (THE_MESSAGE))
|
||||
|
||||
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include "cvfOpenGLContext.h"
|
||||
#include "cvfOpenGLResourceManager.h"
|
||||
#include "cvfOpenGLCapabilities.h"
|
||||
#include "cvfLogDestinationConsole.h"
|
||||
#include "cvfLogManager.h"
|
||||
|
||||
#include <memory.h>
|
||||
|
||||
@ -58,7 +58,7 @@ OpenGLContextGroup::OpenGLContextGroup()
|
||||
m_wglewContextStruct(NULL)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,8 @@ OverlayColorLegend::OverlayColorLegend(Font* font)
|
||||
m_color(Color3::BLACK),
|
||||
m_lineColor(Color3::BLACK),
|
||||
m_lineWidth(1),
|
||||
m_font(font)
|
||||
m_font(font),
|
||||
m_margin(4)
|
||||
{
|
||||
CVF_ASSERT(font);
|
||||
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()));
|
||||
|
||||
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);
|
||||
|
||||
Vec2i legendBarOrigin = oglRect.min();
|
||||
@ -258,7 +261,9 @@ void OverlayColorLegend::render(OpenGLContext* oglContext, const Vec2i& position
|
||||
|
||||
// Get layout information
|
||||
// Todo: Cache this between renderings. Update only when needed.
|
||||
OverlayColorLegendLayoutInfo layout(position, size);
|
||||
OverlayColorLegendLayoutInfo layout;
|
||||
layout.position = position;
|
||||
layout.size = size;
|
||||
layoutInfo(&layout);
|
||||
|
||||
// Set up text drawer
|
||||
@ -560,7 +565,7 @@ void OverlayColorLegend::layoutInfo(OverlayColorLegendLayoutInfo* layout)
|
||||
ref<Glyph> glyph = m_font->getGlyph(L'A');
|
||||
layout->charHeight = static_cast<float>(glyph->height());
|
||||
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 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;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
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
|
||||
|
||||
|
@ -31,34 +31,7 @@ class Font;
|
||||
class ShaderProgram;
|
||||
class MatrixState;
|
||||
class TextDrawer;
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
// 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;
|
||||
};
|
||||
struct OverlayColorLegendLayoutInfo;
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
@ -83,6 +56,7 @@ public:
|
||||
void configureLevels(const Color3ubArray& levelColors, const DoubleArray& tickValues);
|
||||
|
||||
void setSizeHint(const Vec2ui& size);
|
||||
void setWidthToFitText();
|
||||
|
||||
void setColor(const Color3f& color);
|
||||
const Color3f& color() const;
|
||||
@ -96,12 +70,12 @@ public:
|
||||
String title() const;
|
||||
|
||||
protected:
|
||||
void render(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size, bool software);
|
||||
virtual void renderLegend(OpenGLContext* oglContext, OverlayColorLegendLayoutInfo* layout, const MatrixState& matrixState);
|
||||
virtual void renderLegendImmediateMode(OpenGLContext* oglContext, OverlayColorLegendLayoutInfo* layout);
|
||||
virtual void setupTextDrawer(TextDrawer* textDrawer, OverlayColorLegendLayoutInfo* layout);
|
||||
void render(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size, bool software);
|
||||
virtual void renderLegend(OpenGLContext* oglContext, OverlayColorLegendLayoutInfo* layout, const MatrixState& matrixState);
|
||||
virtual void renderLegendImmediateMode(OpenGLContext* oglContext, OverlayColorLegendLayoutInfo* layout);
|
||||
virtual void setupTextDrawer(TextDrawer* textDrawer, OverlayColorLegendLayoutInfo* layout);
|
||||
|
||||
void layoutInfo(OverlayColorLegendLayoutInfo* layout);
|
||||
void layoutInfo(OverlayColorLegendLayoutInfo* layout);
|
||||
|
||||
protected:
|
||||
Color3ubArray m_levelColors; // Colors for n levels
|
||||
@ -115,6 +89,28 @@ protected:
|
||||
int m_lineWidth;
|
||||
std::vector<String> m_titleStrings;
|
||||
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);
|
||||
|
||||
m_size.x() = image->width();
|
||||
m_size.y() = image->height();
|
||||
m_blendMode = NO_BLENDING;
|
||||
|
||||
m_sampler = new cvf::Sampler;
|
||||
@ -342,6 +340,9 @@ void OverlayImage::setImage(TextureImage* image)
|
||||
m_image = image;
|
||||
m_pow2Image = NULL;
|
||||
|
||||
m_size.x() = image->width();
|
||||
m_size.y() = image->height();
|
||||
|
||||
m_texture = new Texture(image);
|
||||
|
||||
m_textureBindings = NULL;
|
||||
@ -383,4 +384,22 @@ void OverlayImage::setBlending(Blending mode)
|
||||
m_blendMode = mode;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
float OverlayImage::globalAlpha() const
|
||||
{
|
||||
return m_alpha;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
OverlayImage::Blending OverlayImage::blending() const
|
||||
{
|
||||
return m_blendMode;
|
||||
}
|
||||
|
||||
} // namespace cvf
|
||||
|
@ -61,6 +61,8 @@ public:
|
||||
void setBlending(Blending mode);
|
||||
|
||||
const TextureImage* image() const;
|
||||
float globalAlpha() const;
|
||||
Blending blending() const;
|
||||
|
||||
private:
|
||||
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;
|
||||
switch (face)
|
||||
Color3f faceColor = Color3f(Color3::WHITE);
|
||||
|
||||
if (!hasTexture)
|
||||
{
|
||||
case NCF_X_POS:
|
||||
case NCF_X_NEG: faceColor = m_xFaceColor; break;
|
||||
case NCF_Y_POS:
|
||||
case NCF_Y_NEG: faceColor = m_yFaceColor; break;
|
||||
case NCF_Z_POS:
|
||||
case NCF_Z_NEG: faceColor = m_zFaceColor; break;
|
||||
switch (face)
|
||||
{
|
||||
case NCF_X_POS:
|
||||
case NCF_X_NEG: faceColor = m_xFaceColor; break;
|
||||
case NCF_Y_POS:
|
||||
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)
|
||||
@ -480,16 +484,12 @@ void OverlayNavigationCube::renderCubeGeos(OpenGLContext* oglContext, bool softw
|
||||
|
||||
if (software)
|
||||
{
|
||||
if (hasTexture)
|
||||
{
|
||||
glColor3f(1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
glColor3fv(renderFaceColor.ptr());
|
||||
}
|
||||
|
||||
#ifdef CVF_OPENGL_ES
|
||||
CVF_FAIL_MSG("Not supported on OpenGL ES");
|
||||
#else
|
||||
glColor3fv(renderFaceColor.ptr());
|
||||
m_cubeGeos[i]->renderImmediateMode(oglContext, matrixState);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -567,8 +567,12 @@ void OverlayNavigationCube::render2dItems(OpenGLContext* oglContext, const Vec2i
|
||||
|
||||
if (software)
|
||||
{
|
||||
#ifdef CVF_OPENGL_ES
|
||||
CVF_FAIL_MSG("Not supported on OpenGL ES");
|
||||
#else
|
||||
glColor3fv(renderFaceColor.ptr());
|
||||
m_2dGeos[i]->renderImmediateMode(oglContext, matrixState);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1105,7 +1109,7 @@ OverlayNavigationCube::NavCubeItem OverlayNavigationCube::navCubeItem(NavCubeFac
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
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
|
||||
NORMALIZE_FF, //Fixed function
|
||||
TEXTURE_MAPPING_FF, //Fixed function
|
||||
CLIP_PLANES_FF, //Fixed function
|
||||
#endif
|
||||
|
||||
COUNT // Must be the last entry
|
||||
|
@ -87,6 +87,7 @@ void RenderStateTracker::setupDefaultRenderStates()
|
||||
m_defaultRenderStates[RenderState::MATERIAL_FF] = new RenderStateMaterial_FF;
|
||||
m_defaultRenderStates[RenderState::NORMALIZE_FF] = new RenderStateNormalize_FF(false);
|
||||
m_defaultRenderStates[RenderState::TEXTURE_MAPPING_FF] = new RenderStateTextureMapping_FF;
|
||||
m_defaultRenderStates[RenderState::CLIP_PLANES_FF] = new RenderStateClipPlanes_FF;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -672,5 +672,100 @@ bool RenderStateTextureMapping_FF::isFixedFunction() const
|
||||
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 "cvfColor4.h"
|
||||
#include "cvfPlane.h"
|
||||
|
||||
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
|
||||
|
@ -7,7 +7,12 @@
|
||||
//#############################################################################################################################
|
||||
static const char calcClipDistances_inl[] =
|
||||
" \n"
|
||||
"#ifdef CVF_OPENGL_ES \n"
|
||||
"uniform mediump int u_clipPlaneCount; \n"
|
||||
"#else \n"
|
||||
"uniform int u_clipPlaneCount; \n"
|
||||
"#endif \n"
|
||||
" \n"
|
||||
"uniform vec4 u_ecClipPlanes[6]; \n"
|
||||
" \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"
|
||||
" for (i = 0; i < u_clipPlaneCount; i++) \n"
|
||||
" { \n"
|
||||
" if (v_clipDist[i] < 0) discard; \n"
|
||||
" if (v_clipDist[i] < 0.0) discard; \n"
|
||||
" } \n"
|
||||
"} \n";
|
||||
|
||||
@ -103,7 +108,7 @@ static const char fs_CenterLitSpherePoints_inl[] =
|
||||
"{ \n"
|
||||
" //const vec3 ecLightPosition = vec3(0.5, 5.0, 7.0); \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"
|
||||
" // Calculate normal from texture coordinates \n"
|
||||
" vec3 N; \n"
|
||||
@ -111,8 +116,8 @@ static const char fs_CenterLitSpherePoints_inl[] =
|
||||
" float mag = dot(N.xy, N.xy); \n"
|
||||
" \n"
|
||||
" // Kill pixels outside circle \n"
|
||||
" if (mag > 1) discard; \n"
|
||||
" N.z = sqrt(1 - mag); \n"
|
||||
" if (mag > 1.0) discard; \n"
|
||||
" N.z = sqrt(1.0 - mag); \n"
|
||||
" \n"
|
||||
" // Calculate diffuse lighting \n"
|
||||
" float diffuse = max(0.0, dot(lightDir, N)); \n"
|
||||
@ -120,7 +125,7 @@ static const char fs_CenterLitSpherePoints_inl[] =
|
||||
" vec4 color = srcFragment(); \n"
|
||||
" gl_FragColor = vec4(color.rgb*diffuse, color.a); \n"
|
||||
" \n"
|
||||
" //gl_FragDepth = gl_FragCoord.z - 15.0*(1-mag); \n"
|
||||
" //gl_FragDepth = gl_FragCoord.z - 15.0*(1.0-mag); \n"
|
||||
"} \n";
|
||||
|
||||
|
||||
@ -454,8 +459,8 @@ static const char fs_ParticleTraceComets_inl[] =
|
||||
" vec3 N; \n"
|
||||
" N.xy = vec2(v_circleFactors.x, v_circleFactors.y); \n"
|
||||
" float mag = dot(N.xy, N.xy); \n"
|
||||
" if (mag > 1) discard; \n"
|
||||
" N.z = sqrt(1 - mag); \n"
|
||||
" if (mag > 1.0) discard; \n"
|
||||
" N.z = sqrt(1.0 - mag); \n"
|
||||
" \n"
|
||||
" float diffuse = max(0.0, dot(lightDir, N)); \n"
|
||||
" \n"
|
||||
@ -941,7 +946,7 @@ static const char vs_DistanceScaledPoints_inl[] =
|
||||
" // Compute the point diameter in window coords (pixels) \n"
|
||||
" // Scale with distance for perspective correction of the size \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";
|
||||
|
||||
|
||||
@ -968,10 +973,18 @@ static const char vs_EnvironmentMapping_inl[] =
|
||||
"//-------------------------------------------------------------------------------------------------- \n"
|
||||
"void main () \n"
|
||||
"{ \n"
|
||||
"#ifdef CVF_CALC_SHADOW_COORD_IMPL \n"
|
||||
" calcShadowCoord(); \n"
|
||||
"#endif \n"
|
||||
" \n"
|
||||
" // Transforms vertex position and normal vector to eye space \n"
|
||||
" v_ecPosition = (cvfu_modelViewMatrix * cvfa_vertex).xyz; \n"
|
||||
" v_ecNormal = cvfu_normalMatrix * cvfa_normal; \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"
|
||||
" \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;
|
||||
#endif
|
||||
|
||||
uniform vec4 u_ecClipPlanes[6];
|
||||
|
||||
// The dimensioning should probably be via a define to be consistent between vs and fs
|
||||
|
@ -13,6 +13,6 @@ void checkDiscardFragment()
|
||||
int 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);
|
||||
//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
|
||||
vec3 N;
|
||||
@ -19,8 +19,8 @@ void main()
|
||||
float mag = dot(N.xy, N.xy);
|
||||
|
||||
// Kill pixels outside circle
|
||||
if (mag > 1) discard;
|
||||
N.z = sqrt(1 - mag);
|
||||
if (mag > 1.0) discard;
|
||||
N.z = sqrt(1.0 - mag);
|
||||
|
||||
// Calculate diffuse lighting
|
||||
float diffuse = max(0.0, dot(lightDir, N));
|
||||
@ -28,7 +28,7 @@ void main()
|
||||
vec4 color = srcFragment();
|
||||
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;
|
||||
N.xy = vec2(v_circleFactors.x, v_circleFactors.y);
|
||||
float mag = dot(N.xy, N.xy);
|
||||
if (mag > 1) discard;
|
||||
N.z = sqrt(1 - mag);
|
||||
if (mag > 1.0) discard;
|
||||
N.z = sqrt(1.0 - mag);
|
||||
|
||||
float diffuse = max(0.0, dot(lightDir, N));
|
||||
|
||||
|
@ -27,5 +27,5 @@ void main ()
|
||||
// Compute the point diameter in window coords (pixels)
|
||||
// Scale with distance for perspective correction of the size
|
||||
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 ()
|
||||
{
|
||||
#ifdef CVF_CALC_SHADOW_COORD_IMPL
|
||||
calcShadowCoord();
|
||||
#endif
|
||||
|
||||
// Transforms vertex position and normal vector to eye space
|
||||
v_ecPosition = (cvfu_modelViewMatrix * cvfa_vertex).xyz;
|
||||
v_ecNormal = cvfu_normalMatrix * cvfa_normal;
|
||||
|
||||
#ifdef CVF_CALC_CLIP_DISTANCES_IMPL
|
||||
calcClipDistances(vec4(v_ecPosition, 1));
|
||||
#endif
|
||||
|
||||
gl_Position = cvfu_modelViewProjectionMatrix*cvfa_vertex;
|
||||
|
||||
// Compute the texture coordinate for the environment map texture lookup
|
||||
|
@ -26,12 +26,12 @@
|
||||
#include "cvfEffect.h"
|
||||
#include "cvfRenderStateSet.h"
|
||||
#include "cvfShaderProgram.h"
|
||||
#include "cvfTrace.h"
|
||||
#include "cvfOpenGL.h"
|
||||
#include "cvfBufferObjectManaged.h"
|
||||
#include "cvfMatrixState.h"
|
||||
#include "cvfCamera.h"
|
||||
#include "cvfRenderStateTextureBindings.h"
|
||||
#include "cvfLogManager.h"
|
||||
|
||||
#include <memory.h>
|
||||
|
||||
@ -59,7 +59,8 @@ RenderEngine::RenderEngine()
|
||||
m_disableDrawableRender(false),
|
||||
m_disableApplyEffects(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 numPartsToDraw = std::min(numPartsInQueue, maxNumPartsToDraw);
|
||||
|
||||
bool debugLogging = CVF_SHOULD_LOG_RENDER_DEBUG(oglContext);
|
||||
if (debugLogging)
|
||||
{
|
||||
CVF_LOG_RENDER_DEBUG(oglContext, "RenderEngine::render(), numParts=" + String(static_cast<uint>(numPartsInQueue)));
|
||||
}
|
||||
CVF_LOG_DEBUG(m_logger, "RenderEngine::render(), numParts=" + String(static_cast<uint>(numPartsInQueue)));
|
||||
|
||||
size_t i;
|
||||
for (i = 0; i < numPartsToDraw; i++)
|
||||
@ -129,10 +126,7 @@ void RenderEngine::render(OpenGLContext* oglContext, RenderQueue* renderQueue, s
|
||||
CVF_ASSERT(effect);
|
||||
CVF_ASSERT(part);
|
||||
|
||||
if (debugLogging)
|
||||
{
|
||||
CVF_LOG_RENDER_DEBUG(oglContext, String("part#=%1, partName='%2'").arg(static_cast<uint>(i)).arg(part->name()));
|
||||
}
|
||||
CVF_LOG_DEBUG(m_logger, String("part#=%1, partName='%2'").arg(static_cast<uint>(i)).arg(part->name()));
|
||||
|
||||
// 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
|
||||
|
@ -28,6 +28,7 @@ class RenderQueue;
|
||||
class UniformSet;
|
||||
class Camera;
|
||||
class OpenGLContext;
|
||||
class Logger;
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
@ -73,6 +74,8 @@ private:
|
||||
bool m_disableApplyEffects;
|
||||
bool m_forceImmediateMode; // Can be used to force immediate mode drawing for debugging purposes (good old glBegin()/glEnd())
|
||||
bool m_enableItemCountUpdate;
|
||||
|
||||
ref<Logger> m_logger;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "cvfShaderProgram.h"
|
||||
#include "cvfRayIntersectSpec.h"
|
||||
#include "cvfHitItemCollection.h"
|
||||
#include "cvfLogManager.h"
|
||||
|
||||
namespace cvf {
|
||||
|
||||
@ -67,7 +68,8 @@ Rendering::Rendering(const String& renderingName)
|
||||
m_enableMask(0xffffffff),
|
||||
m_clearMode(Viewport::CLEAR_COLOR_DEPTH),
|
||||
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_visibleParts = new PartRenderHintCollection;
|
||||
@ -142,11 +144,7 @@ void Rendering::render(OpenGLContext* oglContext)
|
||||
{
|
||||
CVF_ASSERT(m_camera.notNull() && m_camera->viewport());
|
||||
|
||||
bool debugLogging = CVF_SHOULD_LOG_RENDER_DEBUG(oglContext);
|
||||
if (debugLogging)
|
||||
{
|
||||
CVF_LOG_RENDER_DEBUG(oglContext, String("Entering Rendering::render(), renderingName='%1'").arg(m_renderingName));
|
||||
}
|
||||
CVF_LOG_DEBUG(m_logger, String("Entering Rendering::render(), renderingName='%1'").arg(m_renderingName));
|
||||
|
||||
CVF_CHECK_OGL(oglContext);
|
||||
|
||||
@ -278,10 +276,7 @@ void Rendering::render(OpenGLContext* oglContext)
|
||||
|
||||
CVF_CHECK_OGL(oglContext);
|
||||
|
||||
if (debugLogging)
|
||||
{
|
||||
CVF_LOG_RENDER_DEBUG(oglContext, String("Exiting Rendering::render(), renderingName='%1'").arg(m_renderingName));
|
||||
}
|
||||
CVF_LOG_DEBUG(m_logger, String("Exiting Rendering::render(), renderingName='%1'").arg(m_renderingName));
|
||||
}
|
||||
|
||||
|
||||
@ -293,6 +288,13 @@ void Rendering::renderOverlayItems(OpenGLContext* oglContext, bool useSoftwareRe
|
||||
OverlayItemRectMap 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;
|
||||
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;
|
||||
bool m_enablePerformanceTiming;
|
||||
|
||||
ref<Logger> m_logger;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user