0

Im trying to create a mesh of z = y^2 - x^2 for a uni assessment. Ive create a matrix array to that hold the sqaures that i want to draw as GL_LINE_STRIPS called sqaureMatrix[100]. What i want to know is how i can send that to a vertex shader and display it.

i will put some code below that says how ive set things up so far

asessment.cpp

mat4 squareMatrix[100];

// this is in general how i fill the matrix

mat4 pseudo = mat4

(
vec4(1,1,1,1),
vec4(1,1,1,1),
vec4(1,1,1,1),
vec4(1,1,1,1)
);

// loop through and actually add to the squarematrix like

squareMatrix[0] = pseudo;

vshader.glsl

uniform mat4 mMatrix;


void
main()
{
    for (int i = 0; i < 100; i++)
    {
        gl_Position = mMatrix[i];
    }
}

Well you get the jist of it. The matrix is set up fine. I thought I would just add it to clarify some things.

1
  • In most profiles, vertex shaders are only required to support 1024 uniform components. An array of 100 mat4s uses 1600. I'm not exactly sure what you are trying to do here, but that certainly cannot be it. Commented Sep 21, 2013 at 12:09

1 Answer 1

1

Well, you already have the array. So you point OpenGL to it by passing it as a Vertex Array (or you copy it onto a Vertex Buffer Object which is then referenced as Vertex Array). Google for those terms to understand what they do. They're part of every modern OpenGL tutorial. Then you make OpenGL draw from that data.

As it happens I only recently added a minimal VBO example to my codesamples GitHub repository, in response to another StackOverflow question. It matches your question as well.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.