Changeset 269
- Timestamp:
- Jan 23, 2011, 6:46:02 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/font.cpp
r259 r269 89 89 data->height = data->img->h / 16; 90 90 91 GLuint format = data->img->format->Amask ? GL_RGBA : GL_RGB; 92 int planes = data->img->format->Amask ? 4 : 3; 93 94 int w = PotUp(data->img->w); 95 int h = PotUp(data->img->h); 96 97 uint8_t *pixels = (uint8_t *)data->img->pixels; 98 if (w != data->img->w || h != data->img->h) 99 { 100 uint8_t *tmp = (uint8_t *)malloc(planes * w * h); 101 for (int line = 0; line < data->img->h; line++) 102 memcpy(tmp + planes * w * line, 103 pixels + planes * data->img->w * line, 104 planes * data->img->w); 105 pixels = tmp; 106 } 107 91 108 glGenTextures(1, &data->texture); 92 109 glBindTexture(GL_TEXTURE_2D, data->texture); 93 110 94 glTexImage2D(GL_TEXTURE_2D, 0, 4, data->img->w, data->img->h, 0,95 GL_RGBA, GL_UNSIGNED_BYTE, data->img->pixels);111 glTexImage2D(GL_TEXTURE_2D, 0, planes, w, h, 0, 112 format, GL_UNSIGNED_BYTE, pixels); 96 113 97 114 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 98 115 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 99 116 117 if (pixels != data->img->pixels) 118 free(pixels); 100 119 SDL_FreeSurface(data->img); 101 120 data->img = NULL; -
trunk/src/tileset.cpp
r259 r269 84 84 data->nh = data->img->h / h; 85 85 data->ntiles = data->nw * data->nh; 86 data->tx = (float)w / data->img->w;87 data->ty = (float)h / data->img->h;86 data->tx = (float)w / PotUp(data->img->w); 87 data->ty = (float)h / PotUp(data->img->h); 88 88 89 89 drawgroup = DRAWGROUP_BEFORE; … … 113 113 int planes = data->img->format->Amask ? 4 : 3; 114 114 115 int w = PotUp(data->img->w); 116 int h = PotUp(data->img->h); 117 118 uint8_t *pixels = (uint8_t *)data->img->pixels; 119 if (w != data->img->w || h != data->img->h) 120 { 121 uint8_t *tmp = (uint8_t *)malloc(planes * w * h); 122 for (int line = 0; line < data->img->h; line++) 123 memcpy(tmp + planes * w * line, 124 pixels + planes * data->img->w * line, 125 planes * data->img->w); 126 pixels = tmp; 127 } 128 115 129 glGenTextures(1, &data->texture); 116 130 glBindTexture(GL_TEXTURE_2D, data->texture); 117 131 118 glTexImage2D(GL_TEXTURE_2D, 0, planes, data->img->w, data->img->h, 0,119 format, GL_UNSIGNED_BYTE, data->img->pixels);132 glTexImage2D(GL_TEXTURE_2D, 0, planes, w, h, 0, 133 format, GL_UNSIGNED_BYTE, pixels); 120 134 121 135 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 122 136 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 123 137 138 if (pixels != data->img->pixels) 139 free(pixels); 124 140 SDL_FreeSurface(data->img); 125 141 data->img = NULL;
Note: See TracChangeset
for help on using the changeset viewer.