X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fengine%2Fe_texture.pas;h=c99d4eb3c070a626230b842232744487eec605dd;hb=af1787819fb852141cfca39a570927c0d48ddb6a;hp=c0e6f990dc88ece1edfa033b5e44f1e6893bafdb;hpb=ef67a1b1cbdbde85e1a562ef2dda50824f32db21;p=d2df-sdl.git diff --git a/src/engine/e_texture.pas b/src/engine/e_texture.pas index c0e6f99..c99d4eb 100644 --- a/src/engine/e_texture.pas +++ b/src/engine/e_texture.pas @@ -1,4 +1,4 @@ -(* Copyright (C) DooM 2D:Forever Developers +(* Copyright (C) Doom 2D: Forever Developers * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,7 +23,12 @@ unit e_texture; interface uses - GL, GLExt, SysUtils, e_log, +{$IFDEF USE_NANOGL} + nanoGL, +{$ELSE} + GL, GLExt, +{$ENDIF} + SysUtils, e_log, ImagingTypes, Imaging, ImagingUtility; type @@ -54,7 +59,7 @@ function LoadTextureImg (var img: TImageData; var Texture: GLTexture; var pWidth implementation uses - Classes, BinEditor, g_options, utils; + Classes, g_options, utils; function AlignP2 (n: Word): Word; @@ -108,7 +113,7 @@ begin glBindTexture(GL_TEXTURE_2D, Texture); if (tex.glwidth <> tex.width) or (tex.glheight <> tex.height) then - e_WriteLog(Format('NPOT: %u is %ux%u; gl is %ux%u; u=%f; v=%f', [tex.id, Width, Height, tex.glwidth, tex.glheight, tex.u, tex.v]), MSG_NOTIFY); + e_WriteLog(Format('NPOT: %u is %ux%u; gl is %ux%u; u=%f; v=%f', [tex.id, Width, Height, tex.glwidth, tex.glheight, tex.u, tex.v]), TMsgType.Notify); // texture blends with object background glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); @@ -162,6 +167,10 @@ begin glBindTexture(GL_TEXTURE_2D, 0); + // so driver will really upload the texture (this is *sometimes* required for buggy videodrivers) + glFlush(); + glFinish(); + Result := true; end; @@ -181,7 +190,7 @@ begin if (img.width < 1) or (img.width > 32768) or (img.height < 1) or (img.height > 32768) then begin - e_WriteLog('Error loading texture: invalid image dimensions', MSG_WARNING); + e_WriteLog('Error loading texture: invalid image dimensions', TMsgType.Warning); exit; end; //ConvertImage(img, ifA8R8G8B8); @@ -192,7 +201,7 @@ begin imageSize := Width*Height*4; GetMem(image, imageSize); try - // it's slow, but i don't care for now + // it is slow, but i don't care for now ii := image; for y := height-1 downto 0 do begin @@ -230,7 +239,7 @@ begin InitImage(img); if not LoadImageFromMemory(pData, dataSize, img) then begin - e_WriteLog('Error loading texture: unknown image format', MSG_WARNING); + e_WriteLog('Error loading texture: unknown image format', TMsgType.Warning); exit; end; try @@ -256,13 +265,13 @@ begin InitImage(img); if not LoadImageFromMemory(pData, dataSize, img) then begin - e_WriteLog('Error loading texture: unknown image format', MSG_WARNING); + e_WriteLog('Error loading texture: unknown image format', TMsgType.Warning); exit; end; try if (img.width < 1) or (img.width > 32768) or (img.height < 1) or (img.height > 32768) then begin - e_WriteLog('Error loading texture: invalid image dimensions', MSG_WARNING); + e_WriteLog('Error loading texture: invalid image dimensions', TMsgType.Warning); exit; end; //ConvertImage(img, ifA8R8G8B8); @@ -274,7 +283,7 @@ begin imageSize := img.width*img.height*4; GetMem(image, imageSize); try - // it's slow, but i don't care for now + // it is slow, but i don't care for now ii := image; for y := fY+fHeight-1 downto fY do begin @@ -317,7 +326,7 @@ begin end; if fs = nil then begin - e_WriteLog('Texture "'+filename+'" not found', MSG_WARNING); + e_WriteLog('Texture "'+filename+'" not found', TMsgType.Warning); exit; end; @@ -353,7 +362,7 @@ begin end; if fs = nil then begin - e_WriteLog('Texture "'+filename+'" not found', MSG_WARNING); + e_WriteLog('Texture "'+filename+'" not found', TMsgType.Warning); exit; end;