Note that there are some explanatory texts on larger screens.

plurals
  1. POParticle trails OpenGL 3.3, glClear?
    primarykey
    data
    text
    <p>I'm an OpenGL newbie. I'm trying to create a system of particles and I have everything set up, but the particle trails.</p> <p>The easiest way, that I see, for me to implement this is to clear the screen with a nearly transparent colour e.g alpha = 0.05. This will fade the previous positions drawn.</p> <p>However, this doesn't work. I've also tried to draw a rectangle over the screen.</p> <p>After setting alpha of my particles to 0.3, my transparency doesn't seem to be working.</p> <p>This is my code:</p> <pre><code>do{ glBindVertexArray(VertexArrayID); glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer); time = (float)glfwGetTime(); // ** Calculating new positions and placing into vertex array iter = 0; for(int i = 0; i &lt; n; i++){ bodies[i].F(bodies, i, n, 1); bodies[i].calcPosition(dt); bodies[i].getVertexArray(vertexArray, iter, scale, i); } for(int i = 0; i &lt; n; i++){ bodies[i].F(bodies, i, n, 2); bodies[i].calcVelocity(dt); } // ** glBufferData(GL_ARRAY_BUFFER, 21 * 6 * n * sizeof(float), vertexArray, GL_STREAM_DRAW); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebo); glBufferData(GL_ELEMENT_ARRAY_BUFFER, 20 * 3 * n * sizeof(GLuint), elements, GL_STREAM_DRAW); glEnableVertexAttribArray(0); glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer); glVertexAttribPointer( 0, 2, GL_FLOAT, GL_FALSE, 6*sizeof(float), (void*)0 ); glEnableVertexAttribArray(1); glVertexAttribPointer( 1, 4, GL_FLOAT, GL_FALSE, 6*sizeof(float), (void*)(2*sizeof(float)) ); glDrawElements(GL_TRIANGLES, 20 * 3 * n, GL_UNSIGNED_INT, 0); glDisableVertexAttribArray(0); glDisableVertexAttribArray(1); glfwSwapBuffers(); while((float)glfwGetTime() - time &lt; dt){ } } // Check if the ESC key was pressed or the window was closed while( glfwGetKey( GLFW_KEY_ESC ) != GLFW_PRESS &amp;&amp; glfwGetWindowParam( GLFW_OPENED ) ); </code></pre> <p>My shaders:</p> <pre><code>#version 330 core in vec4 Color; out vec4 outColor; void main() { outColor = Color; } #version 330 core layout(location = 0) in vec2 position; layout(location = 1) in vec4 color; out vec4 Color; void main(){ gl_Position = vec4(position, 0.0, 1.0); Color = color; } </code></pre> <p>This outputs n circles (20 sided polygons) travelling round the screen in different colours. All previous drawings stay on the screen, I want them to fade</p> <p>Thanks Andy</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload