Changeset 662
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/scene.cpp
r659 r662 39 39 extern Shader *stdshader; 40 40 #endif 41 extern float4x4 projection_matrix, view_matrix, model_matrix; 41 42 42 43 /* … … 135 136 qsort(data->tiles, data->ntiles, sizeof(Tile), SceneData::Compare); 136 137 138 // XXX: debug stuff 139 model_matrix = float4x4::translate(320.0f, 240.0f, 0.0f); 140 model_matrix = model_matrix * float4x4::rotate(-data->angle, 1.0f, 0.0f, 0.0f); 141 #if 0 142 static float f = 0.0f; 143 f += 0.01f; 144 model_matrix = model_matrix * float4x4::rotate(0.1f * sinf(f), 1.0f, 0.0f, 0.0f); 145 model_matrix = model_matrix * float4x4::rotate(0.3f * cosf(f), 0.0f, 0.0f, 1.0f); 146 #endif 147 model_matrix = model_matrix * float4x4::translate(-320.0f, -240.0f, 0.0f); 148 // XXX: end of debug stuff 149 137 150 #if LOL_EXPERIMENTAL 151 GLuint uni; 152 uni = stdshader->GetUniformLocation("model_matrix"); 153 glUniformMatrix4fv(uni, 1, GL_FALSE, &model_matrix[0][0]); 154 138 155 float *vertices = new float[18]; 139 vertices[0] = -0.5f; vertices[1] = 0.5f; vertices[2] = 0.0f;140 vertices[3] = 0.5f; vertices[4] = 0.5f; vertices[5] = 0.0f;141 vertices[6] = -0.5f; vertices[7] = -0.5f; vertices[8] = 0.0f;142 143 vertices[9] = 0.5f; vertices[10] = -0.5f; vertices[11] = 0.0f;144 vertices[12] = -0.5f; vertices[13] = -0.5f; vertices[14] = 0.0f;145 vertices[15] = 0.5f; vertices[16] = 0.5f; vertices[17] = 0.0f;156 vertices[0] = 0.0f; vertices[1] = 480.0f; vertices[2] = 0.0f; 157 vertices[3] = 640.0f; vertices[4] = 480.0f; vertices[5] = 0.0f; 158 vertices[6] = 0.0f; vertices[7] = 0.0f; vertices[8] = 0.0f; 159 160 vertices[9] = 640.0f; vertices[10] = 0.0f; vertices[11] = 0.0f; 161 vertices[12] = 0.0f; vertices[13] = 0.0f; vertices[14] = 0.0f; 162 vertices[15] = 640.0f; vertices[16] = 480.0f; vertices[17] = 0.0f; 146 163 147 164 const GLfloat colors[6][3] = { … … 194 211 195 212 #else 196 // XXX: debug stuff 197 glPushMatrix(); 198 static float f = 0.0f; 199 f += 0.05f; 200 glTranslatef(320.0f, 240.0f, 0.0f); 201 glRotatef(-data->angle, 1.0f, 0.0f, 0.0f); 202 #if 0 203 glRotatef(3.0f * sinf(f), 1.0f, 0.0f, 0.0f); 204 glRotatef(8.0f * cosf(f), 0.0f, 0.0f, 1.0f); 205 #endif 206 glTranslatef(-320.0f, -240.0f, 0.0f); 207 // XXX: end of debug stuff 213 glLoadIdentity(); 214 glMultMatrixf(&model_matrix[0][0]); 208 215 209 216 for (int buf = 0, i = 0, n; i < data->ntiles; i = n, buf += 2) … … 255 262 free(texture); 256 263 } 257 258 glPopMatrix();259 264 #endif 260 265 -
trunk/src/video.cpp
r659 r662 31 31 #if LOL_EXPERIMENTAL 32 32 Shader *stdshader; 33 34 float4x4 projection_matrix, view_matrix, model_matrix; 35 #endif 33 #endif 34 float4x4 projection_matrix, view_matrix, model_matrix; 36 35 37 36 #if LOL_EXPERIMENTAL … … 92 91 void Video::SetFov(float theta) 93 92 { 94 #if LOL_EXPERIMENTAL95 float width = GetWidth();96 float height = GetHeight();97 //float near = -width - height;98 //float far = width + height;99 float near = 20.0f;100 float far = 0.1f;101 projection_matrix = float4x4::perspective(theta, width, height, near, far);102 #else103 93 #undef near /* Fuck Microsoft */ 104 94 #undef far /* Fuck Microsoft again */ 105 glMatrixMode(GL_PROJECTION); 106 glLoadIdentity(); 95 float4x4 proj; 107 96 108 97 float width = GetWidth(); … … 115 104 { 116 105 /* The easy way: purely orthogonal projection. */ 117 glOrtho(0, width, 0, height, near, far);106 proj = float4x4::ortho(0, width, 0, height, near, far); 118 107 } 119 108 else … … 135 124 } 136 125 137 glFrustum(-near * t1, near * t1, -near * t2, near * t2, near, far); 138 glTranslatef(-0.5f * width, -0.5f * height, -dist); 126 proj = float4x4::frustum(-near * t1, near * t1, 127 -near * t2, near * t2, near, far) 128 * float4x4::translate(-0.5f * width, -0.5f * height, -dist); 139 129 } 130 131 #if LOL_EXPERIMENTAL 132 projection_matrix = proj; 133 view_matrix = float4x4(1.0f); 134 #else 135 glMatrixMode(GL_PROJECTION); 136 glLoadIdentity(); 137 glMultMatrixf(&proj[0][0]); 140 138 141 139 /* Reset the model view matrix, just in case */ … … 158 156 glViewport(0, 0, GetWidth(), GetHeight()); 159 157 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 160 161 view_matrix = float4x4(1.0f);162 view_matrix[3][0] = 0.0f;163 view_matrix[3][1] = 0.0f;164 view_matrix[3][2] = -5.0f;165 166 model_matrix = float4x4(1.0f);167 model_matrix[0][0] = 0.5f;168 model_matrix[1][1] = 0.5f;169 model_matrix[2][2] = 0.5f;170 158 171 159 GLuint uni; … … 174 162 uni = stdshader->GetUniformLocation("view_matrix"); 175 163 glUniformMatrix4fv(uni, 1, GL_FALSE, &view_matrix[0][0]); 176 uni = stdshader->GetUniformLocation("model_matrix");177 glUniformMatrix4fv(uni, 1, GL_FALSE, &model_matrix[0][0]);178 164 #else 179 165 glEnable(GL_DEPTH_TEST); … … 187 173 #endif 188 174 189 #if LOL_EXPERIMENTAL 190 static float time; 191 time += 0.01f; 192 SetFov(1.0f + sinf(time)); 193 #else 194 SetFov(0.5f); 195 #endif 175 SetFov(0.0f); 196 176 } 197 177
Note: See TracChangeset
for help on using the changeset viewer.