index 6c348baeef3d8a95551225db70058bc0b8c4c6db..3e578c8088d25b39612a400bded3946147606d2c 100644 (file)
--- a/src/engine/e_texture.pas
+++ b/src/engine/e_texture.pas
-(* 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
*
* 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
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * the Free Software Foundation, version 3 of the License ONLY.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
interface
uses
interface
uses
- GL, GLExt, SysUtils, e_log,
- ImagingTypes, Imaging, ImagingUtility;
+ {$INCLUDE ../nogl/noGLuses.inc}
+ SysUtils, e_log, ImagingTypes, Imaging, ImagingUtility;
type
GLTexture = record
type
GLTexture = record
implementation
uses
implementation
uses
- Classes, BinEditor, g_options, utils;
+ Classes, g_options, utils;
function AlignP2 (n: Word): Word;
function AlignP2 (n: Word): Word;
Exit;
end;
Exit;
end;
+ Texture := 0;
glGenTextures(1, @Texture);
tex.id := Texture;
glBindTexture(GL_TEXTURE_2D, Texture);
if (tex.glwidth <> tex.width) or (tex.glheight <> tex.height) then
glGenTextures(1, @Texture);
tex.id := Texture;
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
// texture blends with object background
- glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
// texture does NOT blend with object background
//glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
// texture does NOT blend with object background
//glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
glBindTexture(GL_TEXTURE_2D, 0);
glBindTexture(GL_TEXTURE_2D, 0);
+ // so driver will really upload the texture (this is *sometimes* required for buggy videodrivers)
+ glFlush();
+ glFinish();
+
Result := true;
end;
Result := true;
end;
if (img.width < 1) or (img.width > 32768) or (img.height < 1) or (img.height > 32768) then
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);
exit;
end;
//ConvertImage(img, ifA8R8G8B8);
imageSize := Width*Height*4;
GetMem(image, imageSize);
try
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
ii := image;
for y := height-1 downto 0 do
begin
InitImage(img);
if not LoadImageFromMemory(pData, dataSize, img) then
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
exit;
end;
try
InitImage(img);
if not LoadImageFromMemory(pData, dataSize, img) then
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
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);
exit;
end;
//ConvertImage(img, ifA8R8G8B8);
imageSize := img.width*img.height*4;
GetMem(image, imageSize);
try
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
ii := image;
for y := fY+fHeight-1 downto fY do
begin
end;
if fs = nil then
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;
exit;
end;
end;
if fs = nil then
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;
exit;
end;