So I’m trying to accomplish the following: draw a point on a mouse click. However, that doesn’t seem so complicated, but I need to “keep” those points on the screen and then draw a spline from those points. So for instance I have the following
void mouseButtonCallback(GLFWwindow* _window, int button, int action, int mods)
{
switch (button)
{
case GLFW_MOUSE_BUTTON_LEFT:
if (action == GLFW_RELEASE)
{
if (transitionalFlag == false) {
glfwGetCursorPos(window, &x, &y);
setPositionVector(x, y);
pointsClickedByUser.push_back(positionsClickedByUser);
}
else {
glfwGetCursorPos(window, &x, &y);
setPositionVector(x, y);
pointsClickedByUserTranslational.push_back(positionsClickedByUser);
}
}
}
Note: the If statement is because one of the line taken in is on the X-Y plane and the other on the X-Z plane ( doing a translational sweep with 2 spline selected by the user)
So, From those points , I have to save it into a vector and eventually put it in a VBO to be drawn, right? My question is this: How would I bind a VAO/VBO to allow points to be drawn and spline afterwards. Would it be with an if statement and what not? I’m rather new at this and drawing two “different” ( different because one is a point and the other is a line) objects is throwing me off.
What I was thinking was that I could create a variable GLfloat point_pos[3]; and always just give it to one vao and then draw it. However, how would I then bind my spline?
I don’t really know if I’m making sense, correct me wherever I’m wrong!
Wouldn’t that create an issue because my vector is empty from the get-go? and data keeps being fed into it every time a user clicks onto the screen? If I had a predefined vector it would be easier for me ( I mean, I’ve done a few exercise like that). However, it seems as if I Bind my buffer and send it to the gpu I get weird errors all along the way.
I mean something like this ( don’t mind the code, it’s just practice ) :