:OpenGL을 직교 스케치와 GL_LINE_STRIP
을(0,0)은 그려지는 배열에있는 지점에 분명히 없습니다. 그냥 생각할 수없는 것 같습니다. 나는 어쩌면 내 배열 크기가 너무 크거나 뭔가 추측 것입니다하지만 난 여기
void PointArray::repopulateObjectBuffer()
{
//Rebind Appropriate VAO
glBindVertexArray(vertex_array_object_id);
//Recalculate Array Size
vertexArraySize = points.size()*sizeof(glm::vec2);
//Rebind Appropriate VBO
glBindBuffer(GL_ARRAY_BUFFER, buffer_object_id);
glBufferData(GL_ARRAY_BUFFER, vertexArraySize, NULL, GL_STATIC_DRAW);
glBufferSubData(GL_ARRAY_BUFFER, 0, vertexArraySize, (const GLvoid*)(&points[0]));
//Set up Vertex Arrays
glEnableVertexAttribArray(0); //SimpleShader attrib at position 0 = "vPosition"
glVertexAttribPointer((GLuint)0, 2, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0));
//Unbind
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindVertexArray(0);
}
void PointArray::draw() {
glBindVertexArray(vertex_array_object_id);
glLineWidth(4);
glDrawArrays(GL_LINE_STRIP, 0, vertexArraySize);
glBindVertexArray(0);
}
와는 배열과 무승부 호출을 채우는 내 코드를 추가하고 위치를 여기
를 볼 수 없습니다
void mouseMovement(int x, int y)
{
mouseDX = x - lastX ;
mouseDY = y - lastY ;
lastX = x;
lastY = y;
if(mouse_drag)
{
cam->RotateByMouse(glm::vec2(mouseDX*mouseSens, mouseDY * mouseSens));
}
if(sketching)
{
sketchLine.addPoint(glm::vec2((float)x,(float)y));
sketchLine.repopulateObjectBuffer();
updatePickray(x,y);
}
}
마지막으로 마우스 콜백 내 간단한 오르 정점 셰이더을 가리키는
in vec2 vPosition;
void main(){
const float right = 800.0;
const float bottom = 600.0;
const float left = 0.0;
const float top = 0.0;
const float far = 1.0;
const float near = -1.0;
mat4 orthoMat = mat4(
vec4(2.0/(right - left), 0, 0, 0),
vec4(0, 2.0/(top - bottom), 0, 0),
vec4(0, 0, -2.0/(far - near), 0),
vec4(-(right + left)/(right - left), -(top + bottom)/(top - bottom), -(far + near)/(far - near), 1)
);
gl_Position = orthoMat * vec4(vPosition, 0.0, 1.0);
}
나중에 참조 할 수 있도록 이미지를 인라인 할 수 없더라도 하나의 이미지로 링크 할 수 있습니다 (그리고 나 자신과 같은 사람이 아마도 인라인으로 표시 할 수 있습니다). – Tim