changeset 785 | ac538f1a629e |
parent 780 | f45b0e513dfd |
child 788 | 00720357601f |
784:b203147d91b5 | 785:ac538f1a629e |
---|---|
289 Surface2Tex^.h:= surf^.h; |
289 Surface2Tex^.h:= surf^.h; |
290 |
290 |
291 if (surf^.format^.BytesPerPixel = 3) then mode:= GL_RGB else |
291 if (surf^.format^.BytesPerPixel = 3) then mode:= GL_RGB else |
292 if (surf^.format^.BytesPerPixel = 4) then mode:= GL_RGBA else |
292 if (surf^.format^.BytesPerPixel = 4) then mode:= GL_RGBA else |
293 begin |
293 begin |
294 TryDo(false, 'Surface2Tex: BytePerPixel not in [3, 4', false); |
294 TryDo(false, 'Surface2Tex: BytePerPixel not in [3, 4]', true); |
295 Surface2Tex^.id:= 0; |
295 Surface2Tex^.id:= 0; |
296 exit |
296 exit |
297 end; |
297 end; |
298 |
298 |
299 glGenTextures(1, @Surface2Tex^.id); |
299 glGenTextures(1, @Surface2Tex^.id); |
321 glTexImage2D(GL_TEXTURE_2D, 0, mode, surf^.w, surf^.h, 0, mode, GL_UNSIGNED_BYTE, surf^.pixels); |
321 glTexImage2D(GL_TEXTURE_2D, 0, mode, surf^.w, surf^.h, 0, mode, GL_UNSIGNED_BYTE, surf^.pixels); |
322 |
322 |
323 if SDL_MustLock(surf) then |
323 if SDL_MustLock(surf) then |
324 SDL_UnlockSurface(surf); |
324 SDL_UnlockSurface(surf); |
325 |
325 |
326 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
326 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
327 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR) |
327 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST) |
328 end; |
328 end; |
329 |
329 |
330 procedure FreeTexture(tex: PTexture); |
330 procedure FreeTexture(tex: PTexture); |
331 begin |
331 begin |
332 glDeleteTextures(1, @tex^.id); |
332 glDeleteTextures(1, @tex^.id); |