comparison Renderer/Engine/TextureHash.cc @ 1205:b8adf4e95e96 draft

add createStringFont()
author Takao YONAMINE <e095763@ie.u-ryukyu.ac.jp>
date Thu, 21 Jul 2011 18:56:08 +0900
parents 5abf0ce8c71c
children
comparison
equal deleted inserted replaced
1197:726098b89619 1205:b8adf4e95e96
22 { 22 {
23 free(table); 23 free(table);
24 } 24 }
25 25
26 int 26 int
27 TextureHash::hash_function(const char *key) 27 TextureHash::hash_function(const unsigned char *key)
28 { 28 {
29 //float value = 0.0; 29 //float value = 0.0;
30 int value = 0; 30 int value = 0;
31 31
32 for (int i = 0; key[i]; i++) { 32 for (int i = 0; key[i]; i++) {
37 } 37 }
38 38
39 int 39 int
40 TextureHash::hash_regist(const char* key, int &id) 40 TextureHash::hash_regist(const char* key, int &id)
41 { 41 {
42 int hash = hash_function(key); 42 int hash = hash_function((const unsigned char*)key);
43 for (int i = 0; ; i++) { 43 for (int i = 0; ; i++) {
44 if (table[hash].tx_id == -1) { 44 if (table[hash].tx_id == -1) {
45 table[hash].key = (char*)key; 45 table[hash].key = (char*)key;
46 id = id_count++; 46 id = id_count++;
47 return -1; 47 return -1;
56 } 56 }
57 57
58 int 58 int
59 TextureHash::sg_hash_regist(const char* key, int &id) 59 TextureHash::sg_hash_regist(const char* key, int &id)
60 { 60 {
61 int hash = hash_function(key); 61 int hash = hash_function((const unsigned char*)key);
62 62
63 for (int i = 0; ; i++) { 63 for (int i = 0; ; i++) {
64 if (table[hash].tx_id == -1) { 64 if (table[hash].tx_id == -1) {
65 table[hash].key = (char*)key; 65 table[hash].key = (char*)key;
66 table[hash].tx_id = id; 66 table[hash].tx_id = id;
76 76
77 int 77 int
78 TextureHash::get_sgid(const char* key) 78 TextureHash::get_sgid(const char* key)
79 { 79 {
80 80
81 int hash = hash_function(key); 81 int hash = hash_function((const unsigned char*)key);
82 for (int i = 0; ; i++) { 82 for (int i = 0; ; i++) {
83 if (table[hash].tx_id == -1) { 83 if (table[hash].tx_id == -1) {
84 return -1; 84 return -1;
85 85
86 } else if (strcmp(key, table[hash].key) == 0 86 } else if (strcmp(key, table[hash].key) == 0