------------------------------------------------------------------------------
| 61 | |
| 62 | //------------------------------------------------------------------------------ |
| 63 | bool vtkVRRay::Build(vtkOpenGLRenderWindow* win) |
| 64 | { |
| 65 | // Ray geometry |
| 66 | float vert[] = { 0, 0, 0, 0, 0, -1 }; |
| 67 | |
| 68 | this->RayVBO->Upload(vert, 2 * 3, vtkOpenGLBufferObject::ArrayBuffer); |
| 69 | |
| 70 | this->RayHelper.Program = win->GetShaderCache()->ReadyShaderProgram( |
| 71 | |
| 72 | // vertex shader |
| 73 | "//VTK::System::Dec\n" |
| 74 | "uniform mat4 matrix;\n" |
| 75 | "uniform float scale;\n" |
| 76 | "in vec3 position;\n" |
| 77 | "void main()\n" |
| 78 | "{\n" |
| 79 | " gl_Position = matrix * vec4(scale * position, 1.0);\n" |
| 80 | "}\n", |
| 81 | |
| 82 | // fragment shader |
| 83 | "//VTK::System::Dec\n" |
| 84 | "//VTK::Output::Dec\n" |
| 85 | "uniform vec3 color;\n" |
| 86 | "void main()\n" |
| 87 | "{\n" |
| 88 | " gl_FragData[0] = vec4(color, 1.0);\n" |
| 89 | "}\n", |
| 90 | |
| 91 | // geom shader |
| 92 | ""); |
| 93 | vtkShaderProgram* program = this->RayHelper.Program; |
| 94 | this->RayHelper.VAO->Bind(); |
| 95 | if (!this->RayHelper.VAO->AddAttributeArray( |
| 96 | program, this->RayVBO, "position", 0, 3 * sizeof(float), VTK_FLOAT, 3, false)) |
| 97 | { |
| 98 | vtkErrorMacro(<< "Error setting position in shader VAO."); |
| 99 | } |
| 100 | |
| 101 | return true; |
| 102 | } |
| 103 | |
| 104 | //------------------------------------------------------------------------------ |
| 105 | void vtkVRRay::Render(vtkOpenGLRenderWindow* win, vtkMatrix4x4* poseMatrix) |
no test coverage detected