azrael11
08-03-2015, 02:29 PM
Hi, long time to show my presence here....
To many problems....
Btw...
I try to add stream image to material library in glscene 1.3 for delphi 7.
Everything seems to work fine when i save the image to file and and add it to material library.
vars
strm: Tstream;
i: integer;
img: TImageData;
ext: string;
//
MyArchiveManager:= TGLSArchiveManager.Create(MainForm);
MyArchiveManager.Archives.Add.Name:= 'name1';
MyArchiveManager.Archives[0].LoadFromFile(ProgramPath + Media_Path + 'loading.zlib');
for i:= 0 to MyArchiveManager.Archives[0].ContentList.Count - 1 do
begin
if (i> 0) and (i< 8) then
begin
strm:= MyArchiveManager.Archives[0].GetContent('loading/' + Loading_Materials[i] + '.png');
InitImage(img); //Initiliazation of image Vampire Image Library
ext:= DetermineStreamFormat(strm); //Determine if the file has proper ext
if ext<> '' then
begin
LoadImageFromStream(strm,img); //Load the image from stream and put in img
ConvertImage(img,ifA8Gray8); //convert it to gray
SaveImageToStream(ext,strm,img); // save the gray image to old stream again
//SaveImageToFile(ProgramPath + 'media\' + Loading_Materials[i] + '_grey.png',img);
AddMaterial(Matlib_Loading,strm,Loading_Materials[i] + '_grey',false,''); //false= not to glow the image... // see below for the procedure
//AddMaterial(MatLib_Loading,ProgramPath + 'media\' + Loading_Materials[i] + '_grey.png',Loading_Materials[i] + '_grey');
end;
//SysUtils.DeleteFile(ProgramPath + 'media\' + Loading_Materials[i] + '_grey.png');
FreeImage(img); //Free and nil img
FreeAndNil(strm); //Free and nil the stream...
end;
end;
But when i Use the stream then i get this error "Assertion Failure".
Something i miss here... but i can't find... what...
The full error is.. "Assertion Failure in GLTexture.pas in line 923..
And if i continue run the program by pressing ok in message then shows me
the image in white box and continue without errors...
function AddMaterial(aMatLib: TGlMaterialLibrary; aStreamName: TStream; aMaterialName: string; Glow: Boolean; GlowColor: String): TGlLibMaterial; overload;
var
i: integer;
begin
if Glow= False then
begin
result := aMatLib.Materials.Add;
with result do
begin
with Material do
begin
MaterialOptions := [moIgnoreFog, moNoLighting];
Texture.Disabled := false;
Texture.TextureMode:= tmModulate;
BlendingMode := bmTransparency;
with FrontProperties do
begin
Ambient.SetColor(1, 1, 1, 1);
Diffuse.SetColor(1, 1, 1, 1);
Emission.SetColor(1, 1, 1, 1);
Specular.SetColor(1, 1, 1, 1);
end;
Texture.ImageClassName := 'TGLCompositeImage';
aStreamName.Position:= 0; //This is what is missing
TGLCompositeImage(Texture.Image).LoadFromStream(aS treamName);
end;
Name:= aMaterialName
end;
end
else
begin
result := aMatLib.Materials.Add;
with result do
begin
with Material do
begin
MaterialOptions := [moIgnoreFog, moNoLighting];
Texture.Disabled := false;
Texture.TextureMode:= tmAdd;
BlendingMode := bmTransparency;
with FrontProperties do
begin
Ambient.SetColor(0, 0, 0, 1);
if GlowColor= 'red' then
Diffuse.SetColor(0.255, 0, 0, 1)
else if GlowColor= 'pink' then
Diffuse.SetColor(0.255, 0, 0.255, 1)
else if GlowColor= 'white' then
Diffuse.SetColor(0.255, 0.255, 0.255, 1)
else if GlowColor= 'blue' then
Diffuse.SetColor(0, 0, 0.255, 1)
else if GlowColor= 'black' then
Diffuse.SetColor(0, 0, 0, 1)
else if GlowColor= 'green' then
Diffuse.SetColor(0.030, 0.170, 0.30, 1)
else if GlowColor= 'orange' then
Diffuse.SetColor(0.255, 0.170, 0.030, 1)
else if GlowColor= 'brown' then
Diffuse.SetColor(0.180, 0.100, 0, 1)
else if GlowColor= 'yellow' then
Diffuse.SetColor(0.255, 0.255, 0, 1)
else if GlowColor= 'lime' then
Diffuse.SetColor(0, 0.255, 0, 1)
else if GlowColor= 'teal' then
Diffuse.SetColor(0.120, 0.160, 0.140, 1)
else if GlowColor= 'darkgray' then
Diffuse.SetColor(0.100, 0.100, 0.100, 1)
else if GlowColor= 'lightgray' then
Diffuse.SetColor(0.200, 0.200, 0.200, 1);
Emission.SetColor(0, 0, 0, 1);
Specular.SetColor(0, 0, 0, 1);
end;
Texture.ImageClassName := 'TGLCompositeImage';
aStreamName.Position:= 0; //This is what is missing
TGLCompositeImage(Texture.Image).LoadFromStream(aS treamName);
end;
Name:= aMaterialName + '_gl';
end;
end;
end;
To many problems....
Btw...
I try to add stream image to material library in glscene 1.3 for delphi 7.
Everything seems to work fine when i save the image to file and and add it to material library.
vars
strm: Tstream;
i: integer;
img: TImageData;
ext: string;
//
MyArchiveManager:= TGLSArchiveManager.Create(MainForm);
MyArchiveManager.Archives.Add.Name:= 'name1';
MyArchiveManager.Archives[0].LoadFromFile(ProgramPath + Media_Path + 'loading.zlib');
for i:= 0 to MyArchiveManager.Archives[0].ContentList.Count - 1 do
begin
if (i> 0) and (i< 8) then
begin
strm:= MyArchiveManager.Archives[0].GetContent('loading/' + Loading_Materials[i] + '.png');
InitImage(img); //Initiliazation of image Vampire Image Library
ext:= DetermineStreamFormat(strm); //Determine if the file has proper ext
if ext<> '' then
begin
LoadImageFromStream(strm,img); //Load the image from stream and put in img
ConvertImage(img,ifA8Gray8); //convert it to gray
SaveImageToStream(ext,strm,img); // save the gray image to old stream again
//SaveImageToFile(ProgramPath + 'media\' + Loading_Materials[i] + '_grey.png',img);
AddMaterial(Matlib_Loading,strm,Loading_Materials[i] + '_grey',false,''); //false= not to glow the image... // see below for the procedure
//AddMaterial(MatLib_Loading,ProgramPath + 'media\' + Loading_Materials[i] + '_grey.png',Loading_Materials[i] + '_grey');
end;
//SysUtils.DeleteFile(ProgramPath + 'media\' + Loading_Materials[i] + '_grey.png');
FreeImage(img); //Free and nil img
FreeAndNil(strm); //Free and nil the stream...
end;
end;
But when i Use the stream then i get this error "Assertion Failure".
Something i miss here... but i can't find... what...
The full error is.. "Assertion Failure in GLTexture.pas in line 923..
And if i continue run the program by pressing ok in message then shows me
the image in white box and continue without errors...
function AddMaterial(aMatLib: TGlMaterialLibrary; aStreamName: TStream; aMaterialName: string; Glow: Boolean; GlowColor: String): TGlLibMaterial; overload;
var
i: integer;
begin
if Glow= False then
begin
result := aMatLib.Materials.Add;
with result do
begin
with Material do
begin
MaterialOptions := [moIgnoreFog, moNoLighting];
Texture.Disabled := false;
Texture.TextureMode:= tmModulate;
BlendingMode := bmTransparency;
with FrontProperties do
begin
Ambient.SetColor(1, 1, 1, 1);
Diffuse.SetColor(1, 1, 1, 1);
Emission.SetColor(1, 1, 1, 1);
Specular.SetColor(1, 1, 1, 1);
end;
Texture.ImageClassName := 'TGLCompositeImage';
aStreamName.Position:= 0; //This is what is missing
TGLCompositeImage(Texture.Image).LoadFromStream(aS treamName);
end;
Name:= aMaterialName
end;
end
else
begin
result := aMatLib.Materials.Add;
with result do
begin
with Material do
begin
MaterialOptions := [moIgnoreFog, moNoLighting];
Texture.Disabled := false;
Texture.TextureMode:= tmAdd;
BlendingMode := bmTransparency;
with FrontProperties do
begin
Ambient.SetColor(0, 0, 0, 1);
if GlowColor= 'red' then
Diffuse.SetColor(0.255, 0, 0, 1)
else if GlowColor= 'pink' then
Diffuse.SetColor(0.255, 0, 0.255, 1)
else if GlowColor= 'white' then
Diffuse.SetColor(0.255, 0.255, 0.255, 1)
else if GlowColor= 'blue' then
Diffuse.SetColor(0, 0, 0.255, 1)
else if GlowColor= 'black' then
Diffuse.SetColor(0, 0, 0, 1)
else if GlowColor= 'green' then
Diffuse.SetColor(0.030, 0.170, 0.30, 1)
else if GlowColor= 'orange' then
Diffuse.SetColor(0.255, 0.170, 0.030, 1)
else if GlowColor= 'brown' then
Diffuse.SetColor(0.180, 0.100, 0, 1)
else if GlowColor= 'yellow' then
Diffuse.SetColor(0.255, 0.255, 0, 1)
else if GlowColor= 'lime' then
Diffuse.SetColor(0, 0.255, 0, 1)
else if GlowColor= 'teal' then
Diffuse.SetColor(0.120, 0.160, 0.140, 1)
else if GlowColor= 'darkgray' then
Diffuse.SetColor(0.100, 0.100, 0.100, 1)
else if GlowColor= 'lightgray' then
Diffuse.SetColor(0.200, 0.200, 0.200, 1);
Emission.SetColor(0, 0, 0, 1);
Specular.SetColor(0, 0, 0, 1);
end;
Texture.ImageClassName := 'TGLCompositeImage';
aStreamName.Position:= 0; //This is what is missing
TGLCompositeImage(Texture.Image).LoadFromStream(aS treamName);
end;
Name:= aMaterialName + '_gl';
end;
end;
end;