view3d
diff src/scene.c @ 4:0aee5df08cfc
fixed some shit
author | John Tsiombikas <nuclear@mutantstargoat.com> |
---|---|
date | Thu, 19 Jan 2012 07:03:47 +0200 |
parents | 7e982a61852a |
children | 58ddd42848f9 |
line diff
1.1 --- a/src/scene.c Thu Jan 19 06:15:10 2012 +0200 1.2 +++ b/src/scene.c Thu Jan 19 07:03:47 2012 +0200 1.3 @@ -26,17 +26,17 @@ 1.4 const struct aiScene *aiscn; 1.5 unsigned int proc_flags = aiProcess_JoinIdenticalVertices | 1.6 aiProcess_PreTransformVertices | aiProcess_Triangulate | 1.7 - aiProcess_SortByPType; 1.8 - 1.9 - if(verbose) { 1.10 - printf("scene: %s (%d meshes, %d lights)\n", fname, aiscn->mNumMeshes, aiscn->mNumLights); 1.11 - } 1.12 + aiProcess_GenNormals | aiProcess_SortByPType; 1.13 1.14 if(!(aiscn = aiImportFile(fname, proc_flags))) { 1.15 fprintf(stderr, "failed to load: %s\n", fname); 1.16 return -1; 1.17 } 1.18 1.19 + if(verbose) { 1.20 + printf("scene: %s (%d meshes, %d lights)\n", fname, aiscn->mNumMeshes, aiscn->mNumLights); 1.21 + } 1.22 + 1.23 scn->meshes = 0; 1.24 scn->lights = 0; 1.25 1.26 @@ -252,19 +252,19 @@ 1.27 struct light *lt = scn->lights; 1.28 int pass = 0; 1.29 1.30 + glEnable(GL_BLEND); 1.31 + glDepthFunc(GL_LEQUAL); 1.32 + 1.33 while(lt || pass == 0) { 1.34 struct mesh *m; 1.35 1.36 setup_light(lt); 1.37 1.38 - glEnable(GL_BLEND); 1.39 - 1.40 - if(pass > 0) { 1.41 + if(pass == 0) { 1.42 + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 1.43 + } else { 1.44 glBlendFunc(GL_SRC_ALPHA, GL_ONE); 1.45 glDepthMask(0); 1.46 - } else { 1.47 - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 1.48 - glDepthMask(1); 1.49 } 1.50 1.51 m = scn->meshes; 1.52 @@ -273,7 +273,11 @@ 1.53 m = m->next; 1.54 } 1.55 pass++; 1.56 + lt = lt->next; 1.57 } 1.58 + 1.59 + glDisable(GL_BLEND); 1.60 + glDepthMask(1); 1.61 } 1.62 1.63 static void setup_light(struct light *lt) 1.64 @@ -305,8 +309,6 @@ 1.65 glBindTexture(GL_TEXTURE_2D, m->mat.tex); 1.66 } 1.67 1.68 - /* TODO texture */ 1.69 - 1.70 glBindBuffer(GL_ARRAY_BUFFER, m->vert_buf); 1.71 glVertexPointer(3, GL_FLOAT, 0, 0); 1.72 glEnableClientState(GL_VERTEX_ARRAY);