Mercurial > hg > forks > bilotrip-mj12
comparison src/main.c @ 44:f0073a47c31d
Fix various warnings.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 06 Aug 2013 00:04:37 +0300 |
parents | 5770a4c85961 |
children | d85542c96791 |
comparison
equal
deleted
inserted
replaced
43:d00b967c48f2 | 44:f0073a47c31d |
---|---|
1402 } | 1402 } |
1403 | 1403 |
1404 | 1404 |
1405 void stbi_flip_y(int w, int h, int comp, stbi_uc *data) | 1405 void stbi_flip_y(int w, int h, int comp, stbi_uc *data) |
1406 { | 1406 { |
1407 size_t y, i, stride = w * comp; | 1407 int y; |
1408 size_t i, stride = w * comp; | |
1408 uint8 *out = data; | 1409 uint8 *out = data; |
1409 | 1410 |
1410 for (y = 0; y < (h>>1); ++y) { | 1411 for (y = 0; y < (h>>1); ++y) { |
1411 stbi_uc *p1 = out + y * stride; | 1412 stbi_uc *p1 = out + y * stride; |
1412 stbi_uc *p2 = out + (h-1-y) * stride; | 1413 stbi_uc *p2 = out + (h-1-y) * stride; |
1453 } | 1454 } |
1454 | 1455 |
1455 | 1456 |
1456 GLuint LoadTexture(const char* pFilename, int invert) | 1457 GLuint LoadTexture(const char* pFilename, int invert) |
1457 { | 1458 { |
1458 if(!load_textures) return; | 1459 if(!load_textures) return 0; |
1459 | 1460 |
1460 if (strcmp(pFilename,"") == 0) return 99999; | 1461 if (strcmp(pFilename,"") == 0) return 99999; |
1461 printf(" - LoadTexture(\"%s\")", pFilename); | 1462 printf(" - LoadTexture(\"%s\")", pFilename); |
1462 GLuint tex_2d; | 1463 GLuint tex_2d; |
1463 unsigned char *data; | 1464 unsigned char *data; |
1524 /* scan scene's materials for textures */ | 1525 /* scan scene's materials for textures */ |
1525 for (unsigned int m=0; m<scene->mNumMaterials; m++) | 1526 for (unsigned int m=0; m<scene->mNumMaterials; m++) |
1526 { | 1527 { |
1527 int texIndex = 0; | 1528 int texIndex = 0; |
1528 aiReturn texFound = AI_SUCCESS; | 1529 aiReturn texFound = AI_SUCCESS; |
1529 | |
1530 aiString path; // filename | 1530 aiString path; // filename |
1531 | 1531 |
1532 while (texFound == AI_SUCCESS) | 1532 while (texFound == AI_SUCCESS) |
1533 { | 1533 { |
1534 texFound = scene->mMaterials[m]->GetTexture(aiTextureType_DIFFUSE, texIndex, &path); | 1534 texFound = scene->mMaterials[m]->GetTexture(aiTextureType_DIFFUSE, texIndex, &path); |
1535 GLuint texnum = LoadTexture(path.data, 0); | 1535 textureIdMap[path.data] = LoadTexture(path.data, 0); |
1536 textureIdMap[path.data] = texnum; | |
1537 texIndex++; | 1536 texIndex++; |
1538 } | 1537 } |
1539 } | 1538 } |
1540 //return success; | 1539 |
1541 return true; | 1540 return true; |
1542 } | 1541 } |
1543 | 1542 |
1544 GLuint LoadShader(const char* pFilename) | 1543 GLuint LoadShader(const char* pFilename) |
1545 { | 1544 { |
1698 aiString texPath; //contains filename of texture | 1697 aiString texPath; //contains filename of texture |
1699 | 1698 |
1700 if(AI_SUCCESS == mtl->GetTexture(aiTextureType_DIFFUSE, texIndex, &texPath)) | 1699 if(AI_SUCCESS == mtl->GetTexture(aiTextureType_DIFFUSE, texIndex, &texPath)) |
1701 { | 1700 { |
1702 //bind texture | 1701 //bind texture |
1703 GLuint texId = textureIdMap.at(texPath.data); | 1702 GLuint texId = (GLuint) textureIdMap.at(texPath.data); |
1704 if (texId != 99999) glBindTexture(GL_TEXTURE_2D, texId); | 1703 if (texId != 99999) glBindTexture(GL_TEXTURE_2D, texId); |
1705 } | 1704 } |
1706 | 1705 |
1707 set_float4(c, 0.8f, 0.8f, 0.8f, 1.0f); | 1706 set_float4(c, 0.8f, 0.8f, 0.8f, 1.0f); |
1708 if(AI_SUCCESS == aiGetMaterialColor(mtl, AI_MATKEY_COLOR_DIFFUSE, &diffuse)) | 1707 if(AI_SUCCESS == aiGetMaterialColor(mtl, AI_MATKEY_COLOR_DIFFUSE, &diffuse)) |