Cube  Diff

Differences From Artifact [86ca5a8f24]:

To Artifact [7db200290d]:


75
76
77
78
79
80
81
82
83

84
85
86
87
88
89
90
91
92
93


94
95
96
97
98
99
100
101
102
103


104
105
106
107
108
109
110
75
76
77
78
79
80
81


82
83
84
85
86
87
88
89
90


91
92
93
94
95
96
97
98
99
100


101
102
103
104
105
106
107
108
109







-
-
+








-
-
+
+








-
-
+
+







bool
installtex(int tnum, OFIRI *IRI, int *xs, int *ys, bool clamp)
{
	@autoreleasepool {
		SDL_Surface *s =
		    IMG_Load(IRI.fileSystemRepresentation.UTF8String);
		if (s == NULL) {
			conoutf(
			    @"couldn't load texture %s", IRI.string.UTF8String);
			conoutf(@"couldn't load texture %@", IRI.string);
			return false;
		}

		if (s->format->BitsPerPixel != 24) {
			SDL_PixelFormat *format =
			    SDL_AllocFormat(SDL_PIXELFORMAT_RGB24);
			if (format == NULL) {
				conoutf(
				    @"texture cannot be converted to 24bpp: %s",
				    IRI.string.UTF8String);
				    @"texture cannot be converted to 24bpp: %@",
				    IRI.string);
				return false;
			}

			@try {
				SDL_Surface *converted =
				    SDL_ConvertSurface(s, format, 0);
				if (converted == NULL) {
					conoutf(@"texture cannot be converted "
					        @"to 24bpp: %s",
					    IRI.string.UTF8String);
					        @"to 24bpp: %@",
					    IRI.string);
					return false;
				}

				SDL_FreeSurface(s);
				s = converted;
			} @finally {
				SDL_FreeFormat(format);
131
132
133
134
135
136
137
138

139
140

141
142
143
144
145
146
147
130
131
132
133
134
135
136

137


138
139
140
141
142
143
144
145







-
+
-
-
+







			*xs /= 2;
			*ys /= 2;
		}

		void *scaledimg = s->pixels;

		if (*xs != s->w) {
			conoutf(@"warning: quality loss: scaling %s",
			conoutf(@"warning: quality loss: scaling %@",
			    IRI.string
			        .UTF8String); // for voodoo cards under linux
			    IRI.string); // for voodoo cards under linux
			scaledimg = alloc(*xs * *ys * 3);
			gluScaleImage(GL_RGB, s->w, s->h, GL_UNSIGNED_BYTE,
			    s->pixels, *xs, *ys, GL_UNSIGNED_BYTE, scaledimg);
		}

		if (gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, *xs, *ys, GL_RGB,
		        GL_UNSIGNED_BYTE, scaledimg))