DGL
https://delphigl.com/forum/

glGetTexParameteriv
https://delphigl.com/forum/viewtopic.php?f=19&t=9624
Seite 1 von 1

Autor:  azrael11 [ Sa Dez 04, 2010 12:09 ]
Betreff des Beitrags:  glGetTexParameteriv

i try this

Code:
var
   w1,h1: PGLint;

begin
  glTranslatef(x,y,z);
  glScalef(xScale,yScale,zScale);
  glRotatef(xAngle, 1, 0, 0);
  glRotatef(yAngle, 0, 1, 0);
  glRotatef(zAngle, 0, 0, 1);

  glBindTexture(GL_TEXTURE_2D, WhatTex);  // Bind the Texture to the object
  glGetTexParameteri( GL_TEXTURE_2D,GL_TEXTURE_WIDTH,w1);
  glGetTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_HEIGHT,h1);
  glBindTexture(GL_TEXTURE_2D, texBox);  // Bind new Texture to the object
  // now i want to use the
  glTexSubImage2D( ) //command so i copy then whattex in the tex box

i have two problems
First; gltexsubimage2d want integer width and height and i have PGLInt so i get an error
Second; i cant copy the image ....
Help....

Thanks....

Autor:  Coolcat [ Sa Dez 04, 2010 12:18 ]
Betreff des Beitrags:  Re: glGetTexParameteriv

A PGLInt is a pointer to an GLInt....and a pointer has to point somewhere...
Code:
var w1,h1: GLint;

// ...

glGetTexParameteri( GL_TEXTURE_2D,GL_TEXTURE_WIDTH,@w1);
glGetTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_HEIGHT,@h1);


Note that glTexSubImage2D does require that the texture has already sufficient size. The size of a texture is initially zero! In contrast to that glTexImage2D does delete the texture buffer and create a new one with correct size.

glTexSubImage2D and glTexImage2D do read from main memory, not from another texture. If you want to copy a texture you might want to use a Framebuffer-Object and render a Fullscreen-Quad. That's faster because you don't have to download and upload the texture to graphics memory again.

Autor:  azrael11 [ Sa Dez 04, 2010 13:15 ]
Betreff des Beitrags:  Re: glGetTexParameteriv

Coolcat hat geschrieben:
A PGLInt is a pointer to an GLInt....and a pointer has to point somewhere...
Code:
var w1,h1: GLint;

// ...

glGetTexParameteri( GL_TEXTURE_2D,GL_TEXTURE_WIDTH,@w1);
glGetTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_HEIGHT,@h1);


Note that glTexSubImage2D does require that the texture has already sufficient size. The size of a texture is initially zero! In contrast to that glTexImage2D does delete the texture buffer and create a new one with correct size.

glTexSubImage2D and glTexImage2D do read from main memory, not from another texture. If you want to copy a texture you might want to use a Framebuffer-Object and render a Fullscreen-Quad. That's faster because you don't have to download and upload the texture to graphics memory again.


ok i see what you mean...
Now i get this results from the w1 and h1
w1 = 0 my pic is 450 width
h1 = -1234354 my pic is 350 height

What is that? .......

So you say that i must put the image to the memory and how can i call the image with glTexSubImage2D ?

Thanks for your help...

Autor:  Coolcat [ Sa Dez 04, 2010 13:36 ]
Betreff des Beitrags:  Re: glGetTexParameteriv

Zitat:
ok i see what you mean...
Now i get this results from the w1 and h1
w1 = 0 my pic is 450 width
h1 = -1234354 my pic is 350 height

GL_TEXTURE_WIDTH and GL_TEXTURE_HEIGHT are no valid parameters for glGetTexParameter.
You have to use glGetTexLevelParameter instead:
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, @w1);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, @h1);


Zitat:
So you say that i must put the image to the memory and how can i call the image with glTexSubImage2D?

Note that I used C++-Syntax since I have no idea how to create a dynamic array in Delphi. Note also that you might use another internal texture format. In that case replace GL_RGBA with GL_RGB or whatever you use. You will also have to adapt the array size.
Code:
glBindTexture(GL_TEXTURE_2D, WhatTex);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, @w1);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, @h1);
GLubyte* data = new GLubyte[w1*h1*4]; // dynamic array of type GLubyte and size w1*h1*4
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); // copy texture into main memory

glBindTexture(GL_TEXTURE_2D, texBox);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w1, h1, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); // upload texture to graphics memory
delete[] data; // delete array


As already said, a framebuffer object is MUCH faster, since the bus between graphics card and main memory is relatively slow.

Autor:  azrael11 [ Sa Dez 04, 2010 13:46 ]
Betreff des Beitrags:  Re: glGetTexParameteriv

Coolcat hat geschrieben:
Zitat:

As already said, a framebuffer object is MUCH faster, since the bus between graphics card and main memory is relatively slow.


I know that but i have to deal with at least 20000 textures so image the amount of the memory....

As i say before THANK YOU very much for your help....

Autor:  azrael11 [ So Dez 05, 2010 07:38 ]
Betreff des Beitrags:  Re: glGetTexParameteriv

Coolcat hat geschrieben:
Zitat:
GLubyte* data = new GLubyte[w1*h1*4]; // dynamic array of type GLubyte and size w1*h1*4


I dont understand how to convert this line in delphi format

Any helph Please...

Autor:  sharkman [ So Dez 05, 2010 09:24 ]
Betreff des Beitrags:  Re: glGetTexParameteriv

Zitat:
Code:
GLubyte* data = new GLubyte[w1*h1*4]; // dynamic array of type GLubyte and size w1*h1*4


i suppose it does this:
Code:
var DataArr: array of GLuByte;
  Data: PGLuByte;
begin
  //...
  SetLength(DataArr, w1*h1*4);
  Data:= @DataArr;
  //...
end;

Autor:  sharkman [ So Dez 05, 2010 09:33 ]
Betreff des Beitrags:  Re: glGetTexParameteriv

oops. an array is already a pointer. So in my code, there would be a pointer too much

this should be better:
Code:
var Data: array of GluByte;
begin
  //...
  SetLength(Data, w1*h1*4);
  //...
end;

Autor:  azrael11 [ So Dez 05, 2010 16:58 ]
Betreff des Beitrags:  Re: glGetTexParameteriv

sharkman hat geschrieben:
oops. an array is already a pointer. So in my code, there would be a pointer too much

this should be better:
Code:
var Data: array of GluByte;
begin
  //...
  SetLength(Data, w1*h1*4);
  //...
end;


Thank you my friend it works :D ...

Seite 1 von 1 Alle Zeiten sind UTC + 1 Stunde
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/