Commit ba53a953 authored by David Llewellyn-Jones's avatar David Llewellyn-Jones

Added shader controls (shadows, focus blur) and panel controls.

parent 547b864e
This diff is collapsed.
......@@ -9,9 +9,9 @@ uniform sampler2D framebufferDepth;
// 0 ... fFocusNear ... fFocusFar ... 1
// Blur near from 0 (max) to fFocusNear (none)
const float fFocusNear = 0.99;
uniform float fFocusNear = 0.99;
// Blur far from fFocusFar (min) to 1 (max)
const float fFocusFar = 0.99;
uniform float fFocusFar = 0.99;
// The smaller the value the greater the blur
const float fFocusScaleNear = 10.0;
const float fFocusScaleFar = 320.0;
......
......@@ -42,6 +42,8 @@ typedef enum {
FILESAVETAG_WIREFRAME,
FILESAVETAG_FULLSCREEN,
FILESAVETAG_BUTTONBARSTYLE,
FILESAVETAG_SHOWPANELLEFT,
FILESAVETAG_SHOWPANELBOTTOM,
FILESAVETAG_EXPORTBINARY,
FILESAVETAG_EXPORTALPHA,
FILESAVETAG_EXPORTMULTIPLIER,
......@@ -51,6 +53,10 @@ typedef enum {
FILESAVETAG_EXPORTTIMEEND,
FILESAVETAG_EXPORTFRAMES,
FILESAVETAG_USESHADERS,
FILESAVETAG_SHADOWS,
FILESAVETAG_FOCUSBLUR,
FILESAVETAG_FOCUSBLURNEAR,
FILESAVETAG_FOCUSBLURFAR,
FILESAVETAG_RADIUS,
FILESAVETAG_ROTATION,
......@@ -197,6 +203,8 @@ bool SaveFile (char const * szFilename, bool boConfigure, FunctyPersist * psFunc
boValue = GetFullScreen (psFunctyData->psVisData);
fprintf(fhFile, "\t\t<fullscreen bool=\"%d\"/>\n", boValue);
fprintf(fhFile, "\t\t<buttonbarstyle int=\"%d\"/>\n", psFunctyData->eButtonBarStyle);
fprintf(fhFile, "\t\t<showpanelleft bool=\"%d\"/>\n", psFunctyData->boShowPanelLeft);
fprintf(fhFile, "\t\t<showpanelbottom bool=\"%d\"/>\n", psFunctyData->boShowPanelBottom);
GetView (& fRadius, & fRotation, & fElevation, psFunctyData->psVisData);
fprintf (fhFile, "\t\t<radius double=\"%f\"/>\n", fRadius);
......@@ -213,6 +221,14 @@ bool SaveFile (char const * szFilename, bool boConfigure, FunctyPersist * psFunc
boValue = GetShadersActive (psFunctyData->psVisData);
fprintf (fhFile, "\t\t<useshaders bool=\"%d\"/>\n", boValue);
boValue = GetShadow (psFunctyData->psVisData);
fprintf (fhFile, "\t\t<shadows bool=\"%d\"/>\n", boValue);
boValue = GetFocusBlur (psFunctyData->psVisData);
fprintf (fhFile, "\t\t<focusblur bool=\"%d\"/>\n", boValue);
fValue = GetFocusBlurNear (psFunctyData->psVisData);
fprintf(fhFile, "\t\t<focusblurnear double=\"%f\"/>\n", fValue);
fValue = GetFocusBlurFar (psFunctyData->psVisData);
fprintf(fhFile, "\t\t<focusblurfar double=\"%f\"/>\n", fValue);
}
fprintf(fhFile, "\t</settings>\n");
......@@ -498,9 +514,27 @@ void StartElementFuncty (GMarkupParseContext * psContext, gchar const * szElemen
else if (strcmp (szElementName, "buttonbarstyle") == 0) {
psFilesaveData->eTag[psFilesaveData->nLevel] = FILESAVETAG_BUTTONBARSTYLE;
}
else if (strcmp (szElementName, "showpanelleft") == 0) {
psFilesaveData->eTag[psFilesaveData->nLevel] = FILESAVETAG_SHOWPANELLEFT;
}
else if (strcmp (szElementName, "showpanelbottom") == 0) {
psFilesaveData->eTag[psFilesaveData->nLevel] = FILESAVETAG_SHOWPANELBOTTOM;
}
else if (strcmp (szElementName, "useshaders") == 0) {
psFilesaveData->eTag[psFilesaveData->nLevel] = FILESAVETAG_USESHADERS;
}
else if (strcmp (szElementName, "shadows") == 0) {
psFilesaveData->eTag[psFilesaveData->nLevel] = FILESAVETAG_SHADOWS;
}
else if (strcmp (szElementName, "focusblur") == 0) {
psFilesaveData->eTag[psFilesaveData->nLevel] = FILESAVETAG_FOCUSBLUR;
}
else if (strcmp (szElementName, "focusblurnear") == 0) {
psFilesaveData->eTag[psFilesaveData->nLevel] = FILESAVETAG_FOCUSBLURNEAR;
}
else if (strcmp (szElementName, "focusblurfar") == 0) {
psFilesaveData->eTag[psFilesaveData->nLevel] = FILESAVETAG_FOCUSBLURFAR;
}
else if (strcmp (szElementName, "radius") == 0) {
psFilesaveData->eTag[psFilesaveData->nLevel] = FILESAVETAG_RADIUS;
}
......@@ -721,11 +755,31 @@ void StartElementSettings (FILESAVETAG eTag, gchar const * * aszAttributeNames,
SetFullScreenWindow (boValue, psFilesaveData->psFunctyData);
}
break;
case FILESAVETAG_SHOWPANELLEFT:
if (psFilesaveData->boConfigure) {
psFilesaveData->psFunctyData->boShowPanelLeft = boValue;
}
break;
case FILESAVETAG_SHOWPANELBOTTOM:
if (psFilesaveData->boConfigure) {
psFilesaveData->psFunctyData->boShowPanelBottom = boValue;
}
break;
case FILESAVETAG_USESHADERS:
if (psFilesaveData->boConfigure) {
SetShadersActive (boValue, psFilesaveData->psFunctyData->psVisData);
}
break;
case FILESAVETAG_SHADOWS:
if (psFilesaveData->boConfigure) {
SetShadow (boValue, psFilesaveData->psFunctyData->psVisData);
}
break;
case FILESAVETAG_FOCUSBLUR:
if (psFilesaveData->boConfigure) {
SetFocusBlur (boValue, psFilesaveData->psFunctyData->psVisData);
}
break;
case FILESAVETAG_EXPORTBINARY:
if (psFilesaveData->boConfigure) {
SetExportBinary (boValue, psFilesaveData->psFunctyData);
......@@ -785,6 +839,16 @@ void StartElementSettings (FILESAVETAG eTag, gchar const * * aszAttributeNames,
SetExportTimeEnd (fValue, psFilesaveData->psFunctyData);
}
break;
case FILESAVETAG_FOCUSBLURNEAR:
if (psFilesaveData->boConfigure) {
SetFocusBlurNear (fValue, psFilesaveData->psFunctyData->psVisData);
}
break;
case FILESAVETAG_FOCUSBLURFAR:
if (psFilesaveData->boConfigure) {
SetFocusBlurFar (fValue, psFilesaveData->psFunctyData->psVisData);
}
break;
default:
// Do nothing
break;
......
This diff is collapsed.
......@@ -69,6 +69,8 @@ struct _FunctyPersist {
FUNCTYPE eNextFunctionType;
//bool boButtonBarHidden;
BUTTONBARSTYLE eButtonBarStyle;
bool boShowPanelLeft;
bool boShowPanelBottom;
};
///////////////////////////////////////////////////////////////////
......
......@@ -151,6 +151,11 @@ struct _VisPersist {
float fZMomentumFunction;
bool boRangeChange;
bool boShader;
bool boShadow;
bool boFocusBlur;
float fFocusBlurNear;
float fFocusBlurFar;
GLint anViewPort[4];
GLdouble afModel[16];
GLdouble afProjection[16];
......@@ -309,9 +314,10 @@ VisPersist * NewVisPersist (void) {
psVisData->boRangeChange = FALSE;
psVisData->boShader = TRUE;
psVisData->boShadow = TRUE;
psVisData->boFocusBlur = TRUE;
psVisData->fFocusBlurNear = 0.99;
psVisData->fFocusBlurFar = 0.0;
// Make sure the function list is empty
psVisData->psFuncList = NULL;
......@@ -620,6 +626,10 @@ void RenderFramebufferToScreen (VisPersist * psVisData) {
static const GLfloat afVertices[(4 * 3)] = {1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f};
static const GLfloat afTexCoords[(4 * 2)] = {1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f};
static const GLubyte auIndices[(3 * 2)] = {0, 1, 2, 2, 3, 0};
GLint nFocusBlurNear;
GLint nFocusBlurFar;
GLfloat fFocusBlurNear;
GLfloat fFocusBlurFar;
// Set the co-ordinate system to be the screen in the range (0, 1)
glPushAttrib (GL_TRANSFORM_BIT | GL_VIEWPORT_BIT);
......@@ -637,9 +647,6 @@ void RenderFramebufferToScreen (VisPersist * psVisData) {
ActivateShader (psVisData->psScreenShader);
uShaderProgram = GetShaderProgram (psVisData->psScreenShader);
glDisable (GL_DEPTH_TEST);
glDisable (GL_TEXTURE_2D);
glActiveTexture (GL_TEXTURE1);
glBindTexture (GL_TEXTURE_2D, psVisData->auFrameTextures[1]);
glUniform1i (glGetUniformLocation (uShaderProgram, "framebufferDepth" ), 1);
......@@ -648,6 +655,23 @@ void RenderFramebufferToScreen (VisPersist * psVisData) {
glBindTexture (GL_TEXTURE_2D, psVisData->auFrameTextures[0]);
glUniform1i (glGetUniformLocation (uShaderProgram, "framebufferTexture" ), 0);
fFocusBlurNear = psVisData->fFocusBlurNear;
fFocusBlurFar = fFocusBlurNear + (psVisData->fFocusBlurFar * (1.0 - fFocusBlurNear));
if (!psVisData->boFocusBlur) {
fFocusBlurNear = 0.0f;
fFocusBlurFar = 1.0f;
}
nFocusBlurNear = glGetUniformLocation (uShaderProgram, "fFocusNear");
glUniform1fv (nFocusBlurNear, 1, (GLfloat *)(& fFocusBlurNear));
nFocusBlurFar = glGetUniformLocation (uShaderProgram, "fFocusFar");
glUniform1fv (nFocusBlurFar, 1, (GLfloat *)(& fFocusBlurFar));
glDisable (GL_DEPTH_TEST);
glDisable (GL_TEXTURE_2D);
// Render the box
glColor4f (1.0, 1.0, 1.0, 1.0);
......@@ -970,34 +994,36 @@ void RenderShadow (VisPersist * psVisData) {
glClearColor (0.0f, 0.0f, 0.0f, 1.0f);
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
/* pmLightTransform = GetLightTransform (psVisData->psShadowData);*/
/* glGetFloatv (GL_MODELVIEW_MATRIX, psVisData->mModelShadow.afM);*/
/* glGetFloatv (GL_PROJECTION_MATRIX, psVisData->mProjectionShadow.afM);*/
/* MultMatrixMatrix4 (pmLightTransform, & psVisData->mProjectionShadow, & psVisData->mModelShadow);*/
/* for (nCol = 0; nCol < 4; nCol++) {*/
/* for (nRow = 0; nRow < 4; nRow++) {*/
/* pmLightTransform->aafM[nCol][nRow] = (nCol == nRow);*/
/* }*/
/* }*/
SetLightTransformMatrix (psVisData);
//glGetDoublev (GL_MODELVIEW_MATRIX, psVisData->afModel);
//glGetDoublev (GL_PROJECTION_MATRIX, psVisData->afProjection);
//glGetIntegerv (GL_VIEWPORT, psVisData->anViewPort);
if (psVisData->boShadow) {
/* pmLightTransform = GetLightTransform (psVisData->psShadowData);*/
/* glGetFloatv (GL_MODELVIEW_MATRIX, psVisData->mModelShadow.afM);*/
/* glGetFloatv (GL_PROJECTION_MATRIX, psVisData->mProjectionShadow.afM);*/
/* MultMatrixMatrix4 (pmLightTransform, & psVisData->mProjectionShadow, & psVisData->mModelShadow);*/
/* for (nCol = 0; nCol < 4; nCol++) {*/
/* for (nRow = 0; nRow < 4; nRow++) {*/
/* pmLightTransform->aafM[nCol][nRow] = (nCol == nRow);*/
/* }*/
/* }*/
SetLightTransformMatrix (psVisData);
//glGetDoublev (GL_MODELVIEW_MATRIX, psVisData->afModel);
//glGetDoublev (GL_PROJECTION_MATRIX, psVisData->afProjection);
//glGetIntegerv (GL_VIEWPORT, psVisData->anViewPort);
// Draw the graph axes
if (psVisData->boDrawAxes) {
glDisable (GL_CULL_FACE);
DrawAxes (psVisData);
glEnable (GL_CULL_FACE);
}
// Draw the graph axes
if (psVisData->boDrawAxes) {
// Draw the graph
glDisable (GL_CULL_FACE);
DrawAxes (psVisData);
//glFrontFace (GL_CW);
DrawGraphsShadow (psVisData);
glEnable (GL_CULL_FACE);
//glFrontFace (GL_CCW);
}
// Draw the graph
glDisable (GL_CULL_FACE);
//glFrontFace (GL_CW);
DrawGraphsShadow (psVisData);
glEnable (GL_CULL_FACE);
//glFrontFace (GL_CCW);
}
void DrawAxes (VisPersist * psVisData) {
......@@ -2024,6 +2050,38 @@ void SetShadersActive (bool boShaderActive, VisPersist * psVisData) {
}
}
void SetShadow (bool boShadow, VisPersist * psVisData) {
psVisData->boShadow = boShadow;
}
bool GetShadow (VisPersist * psVisData) {
return psVisData->boShadow;
}
void SetFocusBlur (bool boFocusBlur, VisPersist * psVisData) {
psVisData->boFocusBlur = boFocusBlur;
}
bool GetFocusBlur (VisPersist * psVisData) {
return psVisData->boFocusBlur;
}
void SetFocusBlurNear (float fFocusBlurNear, VisPersist * psVisData) {
psVisData->fFocusBlurNear = fFocusBlurNear;
}
float GetFocusBlurNear (VisPersist * psVisData) {
return psVisData->fFocusBlurNear;
}
void SetFocusBlurFar (float fFocusBlurFar, VisPersist * psVisData) {
psVisData->fFocusBlurFar = fFocusBlurFar;
}
float GetFocusBlurFar (VisPersist * psVisData) {
return psVisData->fFocusBlurFar;
}
void GetDisplayProperties (float * pfViewRadius, float * pfLinkLen, float * pfCentring, float * pfRigidity, float * pfForce, float * pfResistance, VisPersist * psVisData) {
if (pfViewRadius) {
* pfViewRadius = psVisData->fViewRadius;
......
......@@ -87,6 +87,14 @@ void SetDrawAxes (bool boDrawAxes, VisPersist * psVisData);
bool GetDrawAxes (VisPersist * psVisData);
void SetWireframe (bool boWireframe, VisPersist * psVisData);
bool GetWireframe (VisPersist * psVisData);
void SetShadow (bool boShadow, VisPersist * psVisData);
bool GetShadow (VisPersist * psVisData);
void SetFocusBlur (bool boFocusBlur, VisPersist * psVisData);
bool GetFocusBlur (VisPersist * psVisData);
void SetFocusBlurNear (float fFocusBlurNear, VisPersist * psVisData);
float GetFocusBlurNear (VisPersist * psVisData);
void SetFocusBlurFar (float fFocusBlurFar, VisPersist * psVisData);
float GetFocusBlurFar (VisPersist * psVisData);
void SetShadersActive (bool boShaderActive, VisPersist * psVisData);
bool GetShadersActive (VisPersist * psVisData);
void RenderBitmapString (float fX, float fY, void * pFont, char const * szString);
......
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