CPUアプリケーションで
:そして
//Create one Shader Storage Buffer Object for vertices of detected points
GLuint Detected_Vertices_SSBO;
glGenBuffers(1,&Detected_Vertices_SSBO);
glBindBuffer(GL_SHADER_STORAGE_BUFFER,Detected_Vertices_SSBO);
glBufferData(GL_SHADER_STORAGE_BUFFER,(sizeN-NbTotalreflectionPoints.at(i))*sizeof(glm::vec4),NULL,GL_DYNAMIC_DRAW);
sprintf(OpenGLErrorMessage,"%s\n","Error on Vertices SSBO at creation time.");
QuerryForOpenGLErrors(OpenGLErrorMessage);
glBindBufferBase(GL_SHADER_STORAGE_BUFFER,0,Detected_Vertices_SSBO);
sprintf(OpenGLErrorMessage,"%s\n","Error on Vertices SSBO at binding time.");
QuerryForOpenGLErrors(OpenGLErrorMessage);
//Create one Shader Storage Buffer Object for colors of detected points
GLuint Detected_Vertices_Colors_SSBO;
glGenBuffers(1,&Detected_Vertices_Colors_SSBO);
glBindBuffer(GL_SHADER_STORAGE_BUFFER,Detected_Vertices_Colors_SSBO);
glBufferData(GL_SHADER_STORAGE_BUFFER,(sizeN-NbTotalreflectionPoints.at(i))*sizeof(glm::vec4),NULL,GL_DYNAMIC_DRAW);
sprintf(OpenGLErrorMessage,"%s\n","Error on Colors of Vertices SSBO at creation time.");
QuerryForOpenGLErrors(OpenGLErrorMessage);
glBindBufferBase(GL_SHADER_STORAGE_BUFFER,1,Detected_Vertices_Colors_SSBO);
sprintf(OpenGLErrorMessage,"%s\n","Error on Vertices Colors SSBO at binding time.");
QuerryForOpenGLErrors(OpenGLErrorMessage);
….
glDrawArrays(GL_POINTS, 2*3+NbTargets1*12*3, NbPoints); //
glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT);
glFinish();
…
glBindBuffer(GL_SHADER_STORAGE_BUFFER, Detected_Vertices_SSBO);
glm::vec4 * SSBO_Position_ptr = (glm::vec4*)glMapBuffer(GL_SHADER_STORAGE_BUFFER,GL_READ_ONLY);
sprintf(OpenGLErrorMessage,"%s\n","Error on Vertices SSBO at mapping time.");
QuerryForOpenGLErrors(OpenGLErrorMessage);
glFinish();
glBindBuffer(GL_SHADER_STORAGE_BUFFER, Detected_Vertices_Colors_SSBO);
glm::vec4 * SSBO_Color_ptr = (glm::vec4*)glMapBuffer(GL_SHADER_STORAGE_BUFFER,GL_READ_ONLY);
sprintf(OpenGLErrorMessage,"%s\n","Error on Vertices Colors SSBO at mapping time.");
QuerryForOpenGLErrors(OpenGLErrorMessage);
glFinish();
、フラグメントシェーダで:
#version 430 core
レイアウト(early_fragment_tests)において、
// Interpolated values from the vertex shaders
in vec4 fragmentColor;
in vec4 worldspace;
//SSBO's for detected points and their colors
layout (binding=0, std430) coherent buffer detected_vertices_storage
{
vec4 detected_vertices[];
}Positions;
layout (binding=1, std430) coherent buffer detected_vertices_colors_storage
{
vec4 detected_vertices_colors[];
}Colors;
...
Positions.detected_vertices[int(round(Condition * ((gl_FragCoord.y-0.5)*1024.0+(gl_FragCoord.x-0.5))/(1024.0*1024.0)*NbOfCosines))] = worldspace;
Colors.detected_vertices_colors[int(round(Condition * ((gl_FragCoord.y-0.5)*1024.0+(gl_FragCoord.x-0.5))/(1024.0*1024.0)*NbOfCosines))] = color;
前記条件= 0または1
私はこれが役立つことを願っています。私はまだstackoverflowでこの書式のものに多くの問題を抱えていることを伝えて申し訳ありません。私はあまりにも古くなければならない!
問題がソースコードなしでわかりにくいです。 –
私は時間がかかるかもしれませんが、私はニコールボラスに答えるために一緒に何かを入れます – RobertB