Revert "conflict"
This reverts commit3cd3b20600
, reversing changes made to8b4276f6ab
.
This commit is contained in:
parent
3cd3b20600
commit
192779d7bd
4 changed files with 18 additions and 14 deletions
|
@ -5,6 +5,7 @@
|
|||
|
||||
in vec4 fragment_color;
|
||||
in vec2 vertex_pos;
|
||||
in vec2 julia_position;
|
||||
|
||||
out vec4 color;
|
||||
|
||||
|
@ -15,7 +16,7 @@ const int i_max = 200;
|
|||
|
||||
void main()
|
||||
{
|
||||
vec2 z = vertex_pos * m;
|
||||
vec2 z = julia_position * m;
|
||||
int i;
|
||||
|
||||
for(i = 0; i < i_max; i++) {
|
||||
|
|
|
@ -9,8 +9,11 @@ in vec4 in_color;
|
|||
uniform mat4 view;
|
||||
uniform mat4 proj;
|
||||
|
||||
uniform vec2 julia_positions[3];
|
||||
|
||||
out vec4 fragment_color;
|
||||
out vec2 vertex_pos;
|
||||
out vec2 julia_position;
|
||||
|
||||
void main()
|
||||
{
|
||||
|
@ -18,9 +21,6 @@ void main()
|
|||
gl_Position = proj * view * in_position;
|
||||
|
||||
fragment_color = in_color;
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
||||
julia_position = julia_positions[gl_VertexID % 3];
|
||||
>>>>>>> 8b4276f6ab9ed1d7d6e1909f36944eaa9a8964da
|
||||
}
|
|
@ -26,8 +26,6 @@ class Viewer : public nse::gui::AbstractViewer
|
|||
nanogui::Slider *sldJuliaCY;
|
||||
nanogui::Slider *sldJuliaZoom; //Zoom factor for the Julia fractal
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
nanogui::Slider *point1X;
|
||||
nanogui::Slider *point1Y;
|
||||
nanogui::Slider *point2X;
|
||||
|
@ -35,7 +33,6 @@ class Viewer : public nse::gui::AbstractViewer
|
|||
nanogui::Slider *point3X;
|
||||
nanogui::Slider *point3Y;
|
||||
|
||||
>>>>>>> 8b4276f6ab9ed1d7d6e1909f36944eaa9a8964da
|
||||
// The following variables hold OpenGL object IDs
|
||||
GLuint vertex_shader_id, // ID of the vertex shader
|
||||
fragment_shader_id, // ID of the fragment shader
|
||||
|
@ -50,13 +47,9 @@ class Viewer : public nse::gui::AbstractViewer
|
|||
GLint julia_m_id;
|
||||
GLint julia_c_id;
|
||||
|
||||
<<<<<<< HEAD
|
||||
// Read, Compile and link the shader codes to a shader program
|
||||
=======
|
||||
GLint julia_pos_id;
|
||||
|
||||
// Read, Compile and link the shader codes to a shader program
|
||||
>>>>>>> 8b4276f6ab9ed1d7d6e1909f36944eaa9a8964da
|
||||
void CreateShaders();
|
||||
// Create and define the vertex array and add a number of vertex buffers
|
||||
void CreateVertexBuffers();
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
|
||||
#include "glsl.h"
|
||||
|
||||
using namespace nse::gui;
|
||||
|
||||
Viewer::Viewer()
|
||||
: AbstractViewer("CG1 Exercise 1")
|
||||
{
|
||||
|
@ -29,6 +31,8 @@ Viewer::Viewer()
|
|||
julia_m_id = glGetUniformLocation(program_id, "m");
|
||||
julia_c_id = glGetUniformLocation(program_id, "c");
|
||||
|
||||
julia_pos_id = glGetUniformLocation(program_id, "julia_positions");
|
||||
|
||||
modelViewMatrix.setIdentity();
|
||||
projectionMatrix.setIdentity();
|
||||
|
||||
|
@ -50,8 +54,6 @@ void Viewer::SetupGUI()
|
|||
sldJuliaCY = nse::gui::AddLabeledSliderWithDefaultDisplay(mainWindow, "JuliaC.Y", std::make_pair(-1.0f, 1.0f), -0.3f, 2);
|
||||
sldJuliaZoom = nse::gui::AddLabeledSliderWithDefaultDisplay(mainWindow, "Julia Zoom", std::make_pair(0.01f, 10.0f), 1.0f, 2);
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
point1X = AddLabeledSliderWithDefaultDisplay(mainWindow, "Point1.X", std::make_pair(-3.0f, 3.0f), -0.8f, 2);
|
||||
point1Y = AddLabeledSliderWithDefaultDisplay(mainWindow, "Point1.Y", std::make_pair(-3.0f, 3.0f), 0.6f, 2);
|
||||
point2X = AddLabeledSliderWithDefaultDisplay(mainWindow, "Point2.X", std::make_pair(-3.0f, 3.0f), 0.5f, 2);
|
||||
|
@ -59,7 +61,6 @@ void Viewer::SetupGUI()
|
|||
point3X = AddLabeledSliderWithDefaultDisplay(mainWindow, "Point3.X", std::make_pair(-3.0f, 3.0f), 0.8f, 2);
|
||||
point3Y = AddLabeledSliderWithDefaultDisplay(mainWindow, "Point3.Y", std::make_pair(-3.0f, 3.0f), 1.0f, 2);
|
||||
|
||||
>>>>>>> 8b4276f6ab9ed1d7d6e1909f36944eaa9a8964da
|
||||
performLayout();
|
||||
}
|
||||
|
||||
|
@ -257,6 +258,13 @@ void Viewer::drawContents()
|
|||
else
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
// create uniform buffer for julia_positions
|
||||
float julia_positions[6] = {
|
||||
point1X->value(), point1Y->value(),
|
||||
point2X->value(), point2Y->value(),
|
||||
point3X->value(), point3Y->value()
|
||||
};
|
||||
|
||||
// Activate the shader program
|
||||
glUseProgram(program_id);
|
||||
|
||||
|
@ -272,6 +280,8 @@ void Viewer::drawContents()
|
|||
glUniform1f(julia_m_id, juliaZoom);
|
||||
glUniform2fv(julia_c_id, 1, juliaC.data());
|
||||
|
||||
glUniform2fv(julia_pos_id, 6, julia_positions);
|
||||
|
||||
// Bind the vertex array
|
||||
glBindVertexArray(vertex_array_id);
|
||||
// Draw the bound vertex array. Start at element 0 and draw 3 vertices
|
||||
|
|
Loading…
Reference in a new issue