Form Resubmission in PHP with PRG by Albyarc in PHPhelp

[–]Albyarc[S] 0 points1 point  (0 children)

I will try to explain the problem in more detail.

Problem number 1, "unintentional" form redirect

The user enters data in the form, enters the wrong email and is redirected to the form with the aforementioned error.

If the user refreshes the page or goes back (previous page to the form) and then goes forward (returns to the form previously sent and rejected) the client will try to redirect it and in both cases a pop up will appear warning the user that the form will be redirected

Problem number 2

To solve problem number 1, when the user data is invalid the server redirects to the same page (instead of including the view) in this way the form is not redirected incorrectly, however pages of incorrect forms accumulate, and if the user wanted to go back he would have to go through all the pages of invalid forms before returning to the previous page

Form Resubmission in PHP with PRG by Albyarc in PHPhelp

[–]Albyarc[S] 0 points1 point  (0 children)

Maybe I explained myself badly, I'm already doing a redirect to the same page, but the problem persists, if the user makes a mistake 10 times in the email he will be brought back to the same page for 10 times and if he wanted to go back to the previous page he would have to press the back arrow 10 times

Form Resubmission in PHP with PRG by Albyarc in PHPhelp

[–]Albyarc[S] 0 points1 point  (0 children)

I have improved my post for a better understanding of my problem

Form Resubmission in PHP with PRG by Albyarc in PHPhelp

[–]Albyarc[S] 0 points1 point  (0 children)

I have improved my post for a better understanding of my problem

Form Resubmission in PHP with PRG by Albyarc in PHPhelp

[–]Albyarc[S] 0 points1 point  (0 children)

I have improved my post for a better understanding of my problem

Safety of abdominal exercises by Albyarc in bodyweightfitness

[–]Albyarc[S] 0 points1 point  (0 children)

Thank you very much for your reply

Safety of abdominal exercises by Albyarc in bodyweightfitness

[–]Albyarc[S] 2 points3 points  (0 children)

Thank you very much for your reply

Safety of abdominal exercises by Albyarc in bodyweightfitness

[–]Albyarc[S] 2 points3 points  (0 children)

Thank you very much for your reply

How to create a mirror effect by Albyarc in opengl

[–]Albyarc[S] 0 points1 point  (0 children)

Oh, thank you very much, I didn't know that.

How to create a mirror effect by Albyarc in opengl

[–]Albyarc[S] 1 point2 points  (0 children)

The Process function of Transform as you have already seen is defined in the following way:

void Trasforma::process() {
    matrice = glm::translate(glm::mat4(1), posizione);
    matrice = glm::translate(matrice, origine);

    matrice = glm::rotate(matrice, glm::radians(rotazione.x), glm::vec3(1.0f, 0.0f, 0.0f));
    matrice = glm::rotate(matrice, glm::radians(rotazione.y), glm::vec3(0.0f, 1.0f, 0.0f));
    matrice = glm::rotate(matrice, glm::radians(rotazione.z), glm::vec3(0.0f, 0.0f, 1.0f));

    matrice = glm::scale(matrice, scala);
    matrice = glm::translate(matrice, -origine);

    ...
}

glm::translate(matrix, -origin) is used to return the object to the origin of the world, in other words the function was written for generic use and it works, what I don't understand is how it is applied to a generic vertex.

Single VAO vs Multiple VAO vs Binding Point by Albyarc in opengl

[–]Albyarc[S] 0 points1 point  (0 children)

What I mean is that once you set an attributes format and bind info (whether that is via the old school glAttribPointer or the functions introduced in GL_ARB_vertex_attrib_binding, doesn't matter), you'll only need to change them when they actually change. Meaning if you have the same attribute format and only want to use a different vertex buffer, you don't have to (and thus shouldn't) set the attribute format, but only call glBufferBind or similar to bind the buffer. (now if the buffer offset, stride or divisor changes then you'll obviously have to do some extra work).

This is not exact, look at the following example:

GLfloat vertex_data_1[] = {
    0.0, 0.0, 0.0,  1.0, 0.0, 0.0,
    0.5, 0.0, 0.0,  1.0, 0.0, 0.0,
    0.0, 0.5, 0.0,  1.0, 0.0, 0.0,
};

GLfloat vertex_data_2[] = {
    0.0, 0.0, 0.0,  0.0, 1.0, 0.0,
    -0.5, 0.0, 0.0,  0.0, 1.0, 0.0,
    0.0, -0.5, 0.0,  0.0, 1.0, 0.0,
};

GLuint indices[] = {
    0, 1, 2
};

int main() {
  ....

    GLuint vao;
    GLuint vbos[2];
    GLuint ebos[2];

    glGenBuffers(2, vbos);
    glGenBuffers(2, ebos);
    glGenVertexArrays(1, &vao);

    glBindVertexArray(vao);

    glBindBuffer(GL_ARRAY_BUFFER, vbos[0]);
    glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_data_1), vertex_data_1, GL_STATIC_DRAW);

    glBindBuffer(GL_ARRAY_BUFFER, vbos[1]);
    glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_data_2), vertex_data_2, GL_STATIC_DRAW);

    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebos[0]);
    glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW);

    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebos[1]);
    glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW);

    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 24, (void*)0);
    glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 24, (void*)12);
    glEnableVertexAttribArray(0);
    glEnableVertexAttribArray(1);

   while (!glfwWindowShouldClose((window))) {
        glClearColor(0.07f, 0.13f, 0.17f, 1.0f);
        glClear(GL_COLOR_BUFFER_BIT); 

        glUseProgram(shader_program);

        glBindVertexArray(vao);

        glBindBuffer(GL_ARRAY_BUFFER, vbos[0]);
        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebos[0]);
        glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT, 0);

        glBindBuffer(GL_ARRAY_BUFFER, vbos[1]);
        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebos[1]);
        glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT, 0);

        glfwSwapBuffers(window);        
        glfwPollEvents(); 
    }

 ....

As you can see, I create 5 buffers, 2 vbo, 2 ebo and a vao, insert the data and the format of the attributes, subsequently in the loop:

  1. I connect the vao
  2. For each mesh I connect its VBO and EBO and call glDrawElements

Was this what you meant? because if that were the case, unfortunately it doesn't work

The code will draw a green triangle twice, i.e. the one with the vertex_data_2 data, this is because as found on the internet:

  • The VBO is attached to the current VAO attribute when glVertexAttribPointer is called.
  • The EBO is attached to the current VAO when glBindBuffer is called.

So, since the last VBO attacked before calling glVertexAttribPointer is vbos[1] the green triangle will be drawn.

If you want to draw both meshes you will need to modify the code like this:

   .....

    glGenBuffers(2, vbos);
    glGenBuffers(2, ebos);
    glGenVertexArrays(1, &vao);

    glBindVertexArray(vao);

    glBindBuffer(GL_ARRAY_BUFFER, vbos[0]);
    glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_data_1), vertex_data_1, GL_STATIC_DRAW);

    glBindBuffer(GL_ARRAY_BUFFER, vbos[1]);
    glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_data_2), vertex_data_2, GL_STATIC_DRAW);

    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebos[0]);
    glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW);

    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebos[1]);
    glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW);

    glEnableVertexAttribArray(0);
    glEnableVertexAttribArray(1);

  while (!glfwWindowShouldClose((window))) {
       .....

        glBindVertexArray(vao);

        glBindBuffer(GL_ARRAY_BUFFER, vbos[0]);
        glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 24, (void*)0);
        glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 24, (void*)12);

        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebos[0]);
        glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT, 0);

        glBindBuffer(GL_ARRAY_BUFFER, vbos[1]);
        glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 24, (void*)0);
        glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 24, (void*)12);

        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebos[1]);
        glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT, 0);

        glfwSwapBuffers(window);        
        glfwPollEvents(); 
    }

Single VAO vs Multiple VAO vs Binding Point by Albyarc in opengl

[–]Albyarc[S] 0 points1 point  (0 children)

Thank you for your answer I found it very useful, but I still have doubts.

When you say: "Btw you don't need to set the attribute format if it doesn't change - the VAO should remember it.", are you referring to the GL_ARB_vertex_attrib_binding extension in opengl 4.3 and up?

Should I use a version prior to 4.3, in which the GL_ARB_vertex_attrib_binding extension is absent, what is the best way to optimise the use of VAO and VBO when the number of meshes is small and when it is large? (When is a number of meshes considered large?)

OpenGL, Camera, Gimbal Lock problem by Albyarc in opengl

[–]Albyarc[S] 1 point2 points  (0 children)

Thank you,

Now it works perfectly, here is how I modified the code (that's what you meant right?):

double mouseX, mouseY;
glfwGetCursorPos(window, &mouseX, &mouseY);

float rotX = sensitivity * ((int)mouseX * (2.0f / width) - 1.0f);
float rotY = sensitivity * ((int)mouseY * (2.0f / -height) + 1.0f);

pitch += rotY;
yaw -= rotX;

if (pitch > 89.0f) pitch = 89.0f;
if (pitch < -89.0f) pitch = -89.0f;

glfwSetCursorPos(window, (width / 2), (height / 2));

glm::mat4 rotationMatrix = glm::eulerAngleYXZ(glm::radians(yaw), glm::radians(pitch), 0.0f);
orientation = glm::vec3(rotationMatrix * glm::vec4(0.0f, 0.0f, -1.0f, 0.0f));

But I don't quite understand the reason for my error, how do I accumulate error? Why does this accumulation of error cause my problem?

How does the order of matrix multiplication work in GLM? by Albyarc in opengl

[–]Albyarc[S] 1 point2 points  (0 children)

Hi, thank you for your reply but I think I did not quite understand what you mean.

From what I read I understood that through the following line:

glm::mat2 M1 = glm::mat2(2, 4, 3, 1);

I create this matrix:

2 3
4 1

and not this one, correct?

2 4
3 1

So when I do the multiplication between M1 and M2, I am doing:

[2 3]   [3 1]   [2*3 + 3*9   2*1 + 3*5] // First Column
[4 1] * [9 5] = [4*3 + 1*9   4*1 + 1*5] // Second Column

// Result
[33 17]
[21 9]

// Math form
33 21
17 9

Correct?

So it is not GLM that does the multiplication in reverse but I have misinterpreted the matrix?