Commit d7d20cda authored by BrutPitt's avatar BrutPitt
Browse files

ver 1.6.0 WiP - splitView: side by side cockpit and standard view

parent 04d6a21e
......@@ -86,7 +86,7 @@ void shaderPointClass::initShader()
// particlesBase
//
////////////////////////////////////////////////////////////////////////////////
GLuint particlesBaseClass::render(GLuint fbIdx, emitterBaseClass *emitter, bool isFullScreenPiP, bool cpitView)
GLuint particlesBaseClass::render(GLuint fbIdx, emitterBaseClass *emitter, bool isFullScreenPiP, bool cpitView)
{
setFlagUpdate();
const GLsizei shadowDetail = theApp->useDetailedShadows() ? GLsizei(2) : GLsizei(1);
......@@ -112,9 +112,11 @@ GLuint particlesBaseClass::render(GLuint fbIdx, emitterBaseClass *emitter, bool
getUPlanes().buildInvMV_forPlanes(this); // checkPlanes and eventually build invMat
tfSettinsClass &cPit = getTFSettings();
if(checkFlagUpdate()) {
//getUData().scrnRes = vec2((isTFRender && cPit.getPIPposition() == cPit.pip::splitView) ? getRenderFBO().getSizeX()<<1 : getRenderFBO().getSizeX(), (isTFRender && cPit.getPIPposition() == cPit.pip::splitView) ? getRenderFBO().getSizeY()<<1 : getRenderFBO().getSizeY());
getUData().scrnRes = vec2(getRenderFBO().getSizeX(), getRenderFBO().getSizeY());
//getUData().scrnRes = vec2(vp.w, vp.h);
getUData().invScrnRes = 1.f/getUData().scrnRes;
getUData().ySizeRatio = theApp->isParticlesSizeConstant() ? 1.0 : float(getUData().scrnRes.y/1024.0);
getUData().ptSizeRatio = 1.0/(length(getUData().scrnRes) / getUData().scrnRes.x);
......@@ -129,7 +131,6 @@ GLuint particlesBaseClass::render(GLuint fbIdx, emitterBaseClass *emitter, bool
float distAtt = getUData().pointDistAtten; // FIXME: use external setting so don't save and restore below
if(isTFRender) getUData().pointDistAtten = 0.f; // no distance attenuation on cpitView
tfSettinsClass &cPit = getTFSettings();
getUData().elapsedTime = cPit.getUdata().elapsedTime;
getUData().lifeTime = tfSettinsClass::getPIPposition() && cPit.cockPit() ? std::max(cPit.getLifeTimeCP(),cPit.getLifeTime()) :
......@@ -138,7 +139,7 @@ GLuint particlesBaseClass::render(GLuint fbIdx, emitterBaseClass *emitter, bool
cpitView ? cPit.getLifeTimeAttenCP() : cPit.getLifeTimeAtten(); // if PiP get max for both to sync view
getUData().smoothDistance= cPit.getSmoothDistance();
getUData().vpReSize = isFullScreenPiP ? 1.0 : cPit.getPIPzoom()*.5;
getUData().vpReSize = isFullScreenPiP || cPit.getPIPposition() == cPit.pip::splitView ? 1.0 : cPit.getPIPzoom()*.5;
getUData().zNear = currentTMat->getPerspNear();
getUData().zFar = currentTMat->getPerspFar();
......@@ -184,9 +185,10 @@ GLuint particlesBaseClass::render(GLuint fbIdx, emitterBaseClass *emitter, bool
setLightDir(normalize(getLightDir()) * (dist*(theApp->useDetailedShadows() ? 1.5f : 1.5f /* 2/2.5*/) + dist*.1f));
}
//if(shadowDetail>1) glViewport(0,0, getUData().scrnRes.x*shadowDetail, getUData().scrnRes.y*shadowDetail);
ivec4 vp;
if(isTFRender) glGetIntegerv(GL_VIEWPORT, (GLint *) value_ptr(vp)); // partial reverted: https://github.com/BrutPitt/glChAoS.P/commit/4bcfc6dd577255ac9460fcc656bcf6796e917c46#
else vp = {0, 0, int(getUData().scrnRes.x), int(getUData().scrnRes.y) };
//ivec4 vp;
//if(isTFRender) glGetIntegerv(GL_VIEWPORT, (GLint *) value_ptr(vp)); // partial reverted: https://github.com/BrutPitt/glChAoS.P/commit/4bcfc6dd577255ac9460fcc656bcf6796e917c46#
//else vp = {0, 0, int(getUData().scrnRes.x), int(getUData().scrnRes.y) };
glViewport(0,0, getUData().scrnRes.x*shadowDetail, getUData().scrnRes.y*shadowDetail);
......@@ -205,7 +207,7 @@ GLuint particlesBaseClass::render(GLuint fbIdx, emitterBaseClass *emitter, bool
emitter->renderEvents();
getShadow()->releaseRender();
glViewport(vp.x,vp.y, vp.z, vp.w);
//glViewport(vp.x,vp.y, vp.z, vp.w);
//FIXME: POV.z+Dolly.z (shadow) ==> look UP
currentTMat->setPOV(tmpPov);
......@@ -221,6 +223,11 @@ GLuint particlesBaseClass::render(GLuint fbIdx, emitterBaseClass *emitter, bool
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, getRenderFBO().getFB(fbIdx));
if(isTFRender)
glViewport(cPit.getViewportSize().x, cPit.getViewportSize().y, cPit.getViewportSize().z, cPit.getViewportSize().w);
else
glViewport(0,0, getUData().scrnRes.x, getUData().scrnRes.y);
// Clear Depth buffer
if(depthBuffActive) {
glEnable(GL_DEPTH_TEST);
......@@ -237,6 +244,7 @@ GLuint particlesBaseClass::render(GLuint fbIdx, emitterBaseClass *emitter, bool
glBlendFunc(getSrcBlend(), getDstBlend());
}
// Normal Render
/////////////////////////////////////////////
bindPipeline();
......@@ -317,6 +325,7 @@ GLuint particlesBaseClass::render(GLuint fbIdx, emitterBaseClass *emitter, bool
// FIXME: use external setting so don't save and restore below ==> look UP
if(isTFRender) getUData().pointDistAtten = distAtt;
//glViewport(0,0, getUData().scrnRes.x, getUData().scrnRes.y);
return returnedTex;
}
......@@ -1205,7 +1214,7 @@ void shadowClass::releaseRender()
tfSettinsClass::tfCommonsStruct tfSettinsClass::tfCommons;
void tfSettinsClass::setViewport(int w, int h) {
float szX = float(w)*getPIPzoom()*.5+.5, szY = float(h)*getPIPzoom()*.5+.5;
float szX = float(w)*getPIPzoom()+.5, szY = float(h)*getPIPzoom()+.5;
w++; h++;
switch(getPIPposition()) {
case pip::lTop:
......@@ -1218,13 +1227,18 @@ void tfSettinsClass::setViewport(int w, int h) {
setViewportSize(ivec4(w-szX,h-szY, szX, szY));
break;
case pip::rBottom:
setViewportSize(ivec4(w-szX,0 , szX, szY));
setViewportSize(ivec4(w-szX, 0, szX, szY));
break;
case pip::splitView:
{
const float zoom = 1.f-getPIPzoom();
setViewportSize(ivec4(float(w)*getPIPzoom(), float(h)*getPIPzoom()*.5, float(w)*zoom, float(h)*zoom));
}
break;
default:
case pip::noPIP:
default:
setViewportSize(ivec4(0,0, w, h));
break;
}
glViewport(getViewportSize().x, getViewportSize().y, getViewportSize().z, getViewportSize().w);
}
......@@ -399,6 +399,8 @@ public:
//void setMaxEmissionFrame(int i) { maxEmissionFrame = i; } //getEmittedParticles
//static int getMaxEmissionFrame() { return maxEmissionFrame; }
ivec4 &getViewportSize() { return viewportSize; }
void setViewportSize(const ivec4 &v) { viewportSize = v; }
private:
......@@ -406,36 +408,33 @@ private:
bool isTFMode = false; // TransformFeedback Mode
bool isCockPit = false;
int pipPosition = noPIP;
float perspAngle = 65.f;
float perspAngle = 60.f;
bool invertPip = false;
ivec4 viewportSize = ivec4(0, 0, 100, 100);
float pipZoom = .5; // 1.0 -> 1/4 Window
} static tfCommons;
ivec4 viewportSize = ivec4(0, 0, 100, 100);
float smoothDistance = .250;
float lifeTime = 75.0;
float lifeTimeAtten = .3;
float lifeTimeCP = 75.0;
float lifeTimeAttenCP = .3;
float magnitude = 2.0;
float magnitudeInt = .2;
float magnitude = 1.5;
float magnitudeInt = .25;
float magnitudeAtten = .15;
float movePositionTail = 0;
bool isInvertView = false;
float tailPosition = .25;
float emitterPointSize = 1;
float cpPointSize = 7.f;
float cpMagnitude = 3.0;
float cpMagnitudeInt = .1;
float cpMagnitude = 1.0;
float cpMagnitudeInt = .2;
float cpMagnitudeAtten = .25;
bool cpFixDistance = true;
quat qRot = quat(1.0f,0.0f, 0.0f, 0.0f);
int slowMotionDpS = 100; //tfSettings DotPerSec
int slowMotionFSDpS = 5000; //FullScreen DotPerSec
static ivec4 &getViewportSize() { return tfCommons.viewportSize; }
static void setViewportSize(const ivec4 &v) { tfCommons.viewportSize = v; }
static constexpr float perspNear = .001f;
//Feedback Data
......
......@@ -718,11 +718,12 @@ void loadSettings(Config &cfg, particlesSystemClass *pSys, int typeToIgnore = lo
if(attractorsList.get()->dtType()) {
tfSettinsClass::tfMode(c.get_or("tfModeOn", false));
tfSettinsClass::cockPit( c.get_or("cpitOn" , false));
tfSettinsClass::setPerspAngle( c.get_or("cpitFOVangle" , 60.f ));
tfSettinsClass::setPIPzoom( c.get_or("cpitPiPsize" , .5f ));
tfSettinsClass::invertPIP( c.get_or("cpitPiPinvert" , false));
tfSettinsClass::setPIPposition( c.get_or("cpitPiPpos" , int(tfSettinsClass::pip::noPIP)));
tfSettinsClass::cockPit(false); // OVERRIDE start anyway OFF // FIXME:???
tfSettinsClass::setPerspAngle( c.get_or("cpitFOVangle" , tfSettinsClass::getPerspAngle() ));
tfSettinsClass::setPIPzoom( c.get_or("cpitPiPsize" , tfSettinsClass::getPIPzoom() ));
tfSettinsClass::setPIPposition( c.get_or("cpitPiPpos" , tfSettinsClass::getPIPposition() ));
tfSettinsClass::invertPIP( c.get_or("cpitPiPinvert" , tfSettinsClass::invertPIP() ));
}
}
......
......@@ -101,6 +101,10 @@ GLint glWindow::onRender()
{
particlesSystem->renderPalette();
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
glViewport(0,0, particlesSystem->getWidth(), particlesSystem->getHeight());
glClearBufferfv(GL_COLOR, 0, value_ptr(particlesSystem->getParticleRenderPtr()->backgroundColor()));
#if !defined(GLCHAOSP_LIGHTVER)
particlesSystem->renderAxes();
......@@ -130,7 +134,6 @@ GLint glWindow::onRender()
getParticlesSystem()->getTMat()->applyTransforms();
GLuint texRendered = particlesSystem->render();
#endif
//glBindFramebuffer(GL_FRAMEBUFFER, 0); // bind both FRAMEBUFFERS to default
particlesSystem->clearFlagUpdate();
return texRendered;
......@@ -145,7 +148,7 @@ void glWindow::onIdle()
////////////////////////////////////////////////////////////////////////////
void glWindow::onReshape(GLint w, GLint h)
{
glViewport(0,0,w,h);
//glViewport(0,0,w,h);
theApp->SetWidth(w); theApp->SetHeight(h);
particlesSystem->getTMat()->getTrackball().viewportSize(w, h);
......
......@@ -180,11 +180,14 @@ GLuint particlesSystemClass::renderSingle()
GLuint particlesSystemClass::renderTF()
{
const int w = getWidth(), h = getHeight();
glViewport(0,0, w, h);
tfSettinsClass &cPit = getParticleRenderPtr()->getTFSettings();
const int w = getWidth(), h = getHeight();
if(cPit.cockPit() && cPit.getPIPposition() == cPit.pip::splitView) {
const float zoom = cPit.getPIPzoom();
cPit.setViewportSize(ivec4(0, float(h)*(1.f-zoom)*.5, float(w)*zoom, float(h)*zoom));
} else cPit.setViewportSize(ivec4(0,0, w, h));
getEmitter()->preRenderEvents();
const vec3 vecA(vec3(attractorsList.get()->getCurrent() ));
......@@ -199,7 +202,7 @@ GLuint particlesSystemClass::renderTF()
transformsClass *cpTM = getCockPitTMat();
cpTM->setPerspective(tfSettinsClass::getPerspAngle(), float(w) / float(h),
cpTM->setPerspective(tfSettinsClass::getPerspAngle(), float(cPit.getPIPposition() == cPit.pip::splitView ? w>>1 : w) / float(h),
tfSettinsClass::getPerspNear(),
getTMat()->getPerspFar());
......@@ -222,18 +225,18 @@ GLuint particlesSystemClass::renderTF()
cpTM->applyTransforms();
//Render TF full screen view
GLuint texRendered = renderParticles(true, !cPit.invertPIP());
GLuint texRendered = renderParticles(true, cPit.cockPit() && !cPit.invertPIP());
texRendered = renderGlowEffect(texRendered);
//Render PiP view
setFlagUpdate();
if(cPit.getPIPposition() != cPit.pip::noPIP) {
if(cPit.cockPit() && cPit.getPIPposition() != cPit.pip::noPIP) {
cPit.setViewport(w,h);
texRendered = renderParticles(false, cPit.invertPIP());
texRendered = renderGlowEffect(texRendered);
glViewport(0,0, w, h);
}
glViewport(0,0, w, h);
#if !defined(GLCHAOSP_NO_FXAA)
texRendered = renderFXAA(texRendered);
......
......@@ -80,9 +80,8 @@ public:
/////////////////////////////////////////////
GLuint render() {
return attractorsList.get()->dtType() && tfSettinsClass::tfMode() && tfSettinsClass::cockPit() ?
renderTF() :
renderSingle();
//return attractorsList.get()->dtType() && tfSettinsClass::tfMode() ? renderTF() : renderSingle();
return theApp->getEmitterEngineType() == enumEmitterEngine::emitterEngine_transformFeedback ? renderTF() : renderSingle();
}
/////////////////////////////////////////////
void renderPalette() { // ColorMaps: rebuilds texture only if settings are changed
......
......@@ -1531,18 +1531,6 @@ void progSettingDlgClass::view()
}
/*
ImGui::NewLine();
ImGui::Text(" Glow effect override");
ImGui::AlignTextToFramePadding();
bool b = bool(theApp->getVSync());
if(ImGui::Checkbox("Start always off", &b)) {
theApp->setVSync(b ? 1 : 0);
glfwSwapInterval(theApp->getVSync());
}
*/
ImGui::NewLine();
ImGui::Text(" GUI apparence / Fonts");
......@@ -1577,39 +1565,6 @@ void progSettingDlgClass::view()
}
ImGui::PopItemWidth();
/*
ImGui::AlignTextToFramePadding();
ImGui::TextDisabled("Thick:");
ImGui::SameLine();
ImGui::PushItemWidth(wButt*.5 -ImGui::GetCursorPosX() - border);
{
if(ImGui::DragFloat("##raster", &theDlg.RasterizerMultiply,.01, .1, 2.0,"%.2f")) {
theDlg.fontChanged = true;
}
}
ImGui::PopItemWidth();
ImGui::SameLine(wButt*.5 + border);
ImGui::TextDisabled("Spacing:");
ImGui::SameLine();
ImGui::PushItemWidth(wButt -ImGui::GetCursorPosX());
{
float f = theDlg.getFontZoom();
if(ImGui::DragFloat2("##spacing", &f,.01, .3, 3.0,"%.2f")) {
theDlg.setFontZoom(f);
ImGui::GetIO().FontGlobalScale=f;
}
}
ImGui::PopItemWidth();
ImGui::PushFont(theDlg.testFont);
ImGui::Text("ABCDEFG abcdefg 0123456789");
ImGui::PopFont();
*/
ImGui::NewLine();
static bool emitterChanges = false;
......@@ -2262,19 +2217,22 @@ void cockpitDlgClass::view()
if(ImGui::RadioButton("##rTop", pos == cPit.pip::rTop)) { cPit.setPIPposition(cPit.pip::rTop); }
ImGui::SameLine();
a = ImGui::GetCursorPosX();
{
bool b = cPit.invertPIP();
if(ImGui::Checkbox(" Invert PIP", &b)) cPit.invertPIP(b);
if(ImGui::RadioButton(" SplitView ", pos == cPit.pip::splitView)) { cPit.setPIPposition(cPit.pip::splitView); }
if(pos == cPit.pip::splitView) {
ImGui::SameLine();
if(ImGui::Button(" halfSplit ")) cPit.setPIPzoom(.5);
}
ImGui::SetCursorPosX(ImGui::GetCursorPosX()+size);
if(ImGui::RadioButton("##noPIP", pos == cPit.pip::noPIP)) { cPit.setPIPposition(cPit.pip::noPIP); }
ImGui::SameLine();
ImGui::SetCursorPosX(a);
ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x);
{
float f = cPit.getPIPzoom();
if(ImGui::SliderFloat("##zoomPIP", &f, .25, 2.0,"size PiP %.3f")) cPit.setPIPzoom(f);
float f = cPit.getPIPzoom()*100.f;
if(ImGui::SliderFloat("##zoomPIP", &f, 25.0f, 100.f,"size PiP %.1f%%")) cPit.setPIPzoom(f/100.f);
}
ImGui::PopItemWidth();
......@@ -2282,6 +2240,12 @@ void cockpitDlgClass::view()
ImGui::SameLine();
ImGui::SetCursorPosX(b+size);
if(ImGui::RadioButton("##rBottom", pos == cPit.pip::rBottom)) { cPit.setPIPposition(cPit.pip::rBottom); }
ImGui::SameLine();
a = ImGui::GetCursorPosX();
{
bool b = cPit.invertPIP();
if(ImGui::Checkbox(" Invert PIP", &b)) cPit.invertPIP(b);
}
}
ImGui::EndChild();
......@@ -2353,22 +2317,6 @@ void cockpitDlgClass::view()
}
}
/*
{
float f = cPit.getPerspNear();
if(ImGui::DragFloat("near", &f, .001f, .001f, FLT_MAX, "%.3f")) cPit.setPerspNear(f);
}
{
bool b = cPit.pipTransparentBckgrnd();
if(ImGui::Checkbox("TranspBack", &b)) cPit.pipTransparentBckgrnd(b);
}
ImGui::SameLine();
{
vec3 v(cPit.getPanDollyPos());
if(ImGui::DragFloat3("Pan/Dolly",value_ptr(v),.01,0.0,0.0)) cPit.setPanDollyPos(v);
}
*/
}
ImGui::End();
}
......@@ -2714,8 +2662,6 @@ void aboutDlgClass::view()
}
#define GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX 0x9047
#define GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX 0x9048
#define GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX 0x9049
......@@ -3087,22 +3033,6 @@ void mainImGuiDlgClass::postRenderImGui()
void mainImGuiDlgClass::renderImGui()
{
/*
if(fontChanged) {
//delete testFont;
fontCFG.RasterizerMultiply = RasterizerMultiply;
fontCFG.FontDataOwnedByAtlas=false;
// theDlg.testFont = ImGui::GetIO().Fonts->AddFontFromFileTTF("Fonts/Cousine-Regular.ttf", theDlg.getFontSize(), &theDlg.fontCFG);
//testFont = ImGui::GetIO().Fonts->AddFontFromFileTTF("Fonts/Cousine-Regular.ttf", getFontSize(), &fontCFG);
//theDlg.testFont = ImGui::GetIO().Fonts->AddFontFromFileTTF("Fonts/Cousine-Regular.ttf", theDlg.getFontSize(), &theDlg.fontCFG);
theDlg.mainFont->ConfigData->RasterizerMultiply = RasterizerMultiply;
ImGui_ImplOpenGL3_DestroyFontsTexture();
ImGui_ImplOpenGL3_CreateFontsTexture();
//ImGui::GetIO().Fonts->Fonts[0];
fontChanged = false;
}
*/
auto imguiNewFrame = []() {
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment