Changeset 656
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/scene.cpp
r654 r656 139 139 #if SHADER_CRAP 140 140 float *vertices = new float[18]; 141 vertices[0] = -0.5f; vertices[1] = -0.5f; vertices[2] = 0.0f;142 vertices[3] = -0.5f; vertices[4] = 0.5f; vertices[5] = 0.0f;143 vertices[6] = 0.5f; vertices[7] =0.5f; vertices[8] = 0.0f;141 vertices[0] = -0.5f; vertices[1] = 0.5f; vertices[2] = 0.0f; 142 vertices[3] = 0.5f; vertices[4] = 0.5f; vertices[5] = 0.0f; 143 vertices[6] = -0.5f; vertices[7] = -0.5f; vertices[8] = 0.0f; 144 144 145 145 vertices[9] = 0.5f; vertices[10] = -0.5f; vertices[11] = 0.0f; … … 148 148 149 149 const GLfloat colors[6][3] = { 150 { 1.0, 0.0, 0.0 },151 { 0.0, 1.0, 0.0 },152 150 { 0.0, 0.0, 1.0 }, 153 151 { 1.0, 0.0, 0.0 }, 154 152 { 0.0, 1.0, 0.0 }, 155 { 1.0, 1.0, 0.0 } }; 156 157 GLuint id[3]; 153 { 1.0, 1.0, 0.0 }, 154 { 0.0, 1.0, 0.0 }, 155 { 1.0, 0.0, 0.0 } }; 156 157 const GLfloat tex[6][2] = { 158 { 0.0, 0.0 }, 159 { 1.0, 0.0 }, 160 { 0.0, 1.0 }, 161 { 1.0, 1.0 }, 162 { 0.0, 1.0 }, 163 { 1.0, 0.0 } }; 164 165 GLuint id[4]; 158 166 glGenVertexArrays(1, &id[0]); 159 167 glBindVertexArray(id[0]); 160 glGenBuffers( 2, &id[1]);168 glGenBuffers(3, &id[1]); 161 169 162 170 glBindBuffer(GL_ARRAY_BUFFER, id[1]); … … 170 178 glEnableVertexAttribArray(1); 171 179 180 glBindBuffer(GL_ARRAY_BUFFER, id[3]); 181 glBufferData(GL_ARRAY_BUFFER, 12 * sizeof(GLfloat), tex, GL_STATIC_DRAW); 182 glVertexAttribPointer((GLuint)2, 2, GL_FLOAT, GL_FALSE, 0, 0); 183 glEnableVertexAttribArray(2); 184 172 185 delete[] vertices; 173 186 174 187 glUseProgram(prog); 175 188 glBindVertexArray(id[0]); 189 Tiler::Bind(1 << 16); 176 190 glDrawArrays(GL_TRIANGLES, 0, 6); 177 191 glBindVertexArray(0); -
trunk/src/video.cpp
r654 r656 43 43 "in vec3 in_Position;\n" 44 44 "in vec3 in_Color;\n" 45 "in vec2 in_TexCoord;\n" 45 46 "out vec3 pass_Color;\n" 46 47 "uniform mat4 projection_matrix;\n" … … 51 52 "{\n" 52 53 " //gl_Position = projection_matrix * view_matrix * model_matrix * vec4(in_Position, 1.0f);\n" 53 " gl_Position = vec4(in_Position, 1.0f);\n" 54 " gl_Position = projection_matrix * view_matrix * model_matrix * vec4(in_Position, 1.0f);\n" 55 " gl_TexCoord[0] = vec4(in_TexCoord, 0.0, 0.0);\n" 54 56 " pass_Color = in_Color;\n" 55 57 "}\n"; … … 58 60 "#version 130\n" 59 61 "\n" 62 "uniform sampler2D in_Texture;\n" 60 63 "in vec3 pass_Color;\n" 61 64 "out vec4 out_Color;\n" … … 63 66 "void main()\n" 64 67 "{\n" 65 " gl_FragColor = vec4(pass_Color, 1.0);\n" 68 " gl_FragColor = 0.5 * (texture2D(in_Texture, vec2(gl_TexCoord[0]))\n" 69 " + vec4(pass_Color, 1.0));\n" 66 70 "}\n"; 67 71 #endif … … 107 111 glBindAttribLocation(prog, 0, "in_Position"); 108 112 glBindAttribLocation(prog, 1, "in_Color"); 113 glBindAttribLocation(prog, 2, "in_TexCoord"); 109 114 glLinkProgram(prog); 110 115 glValidateProgram(prog); … … 123 128 float width = GetWidth(); 124 129 float height = GetHeight(); 125 float near = -width - height; 126 float far = width + height; 130 //float near = -width - height; 131 //float far = width + height; 132 float near = 20.0f; 133 float far = 0.1f; 127 134 projection_matrix = float4x4::perspective(theta, width, height, near, far); 128 135 #else … … 187 194 view_matrix = float4x4(1.0f); 188 195 view_matrix[3][0] = 0.0f; 189 view_matrix[3][ 0] = 0.0f;190 view_matrix[3][ 0] = -5.0f;196 view_matrix[3][1] = 0.0f; 197 view_matrix[3][2] = -5.0f; 191 198 192 199 model_matrix = float4x4(1.0f); … … 209 216 #endif 210 217 211 SetFov(0.0f); 218 #if SHADER_CRAP 219 static float time; 220 time += 0.01f; 221 SetFov(1.0f + sinf(time)); 222 #else 223 SetFov(0.5f); 224 #endif 212 225 } 213 226
Note: See TracChangeset
for help on using the changeset viewer.