Files |  Tutorials |  Articles |  Links |  Home |  Team |  Forum |  Wiki |  Impressum

Aktuelle Zeit: Do Mär 28, 2024 20:54

Foren-Übersicht » English » English Programming Forum
Unbeantwortete Themen | Aktive Themen



Ein neues Thema erstellen Auf das Thema antworten  [ 9 Beiträge ] 
Autor Nachricht
 Betreff des Beitrags: glGetTexParameteriv
BeitragVerfasst: Sa Dez 04, 2010 12:09 
Offline
DGL Member
Benutzeravatar

Registriert: Fr Mai 28, 2010 13:28
Beiträge: 25
Wohnort: Ελλάδα -- Greece
Programmiersprache: Delphi, FreePascal
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....

_________________
Try to think first before you act....


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: glGetTexParameteriv
BeitragVerfasst: Sa Dez 04, 2010 12:18 
Offline
DGL Member
Benutzeravatar

Registriert: Do Dez 29, 2005 12:28
Beiträge: 2249
Wohnort: Düsseldorf
Programmiersprache: C++, C#, Java
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.

_________________
Yeah! :mrgreen:


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: glGetTexParameteriv
BeitragVerfasst: Sa Dez 04, 2010 13:15 
Offline
DGL Member
Benutzeravatar

Registriert: Fr Mai 28, 2010 13:28
Beiträge: 25
Wohnort: Ελλάδα -- Greece
Programmiersprache: Delphi, FreePascal
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...

_________________
Try to think first before you act....


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: glGetTexParameteriv
BeitragVerfasst: Sa Dez 04, 2010 13:36 
Offline
DGL Member
Benutzeravatar

Registriert: Do Dez 29, 2005 12:28
Beiträge: 2249
Wohnort: Düsseldorf
Programmiersprache: C++, C#, Java
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.

_________________
Yeah! :mrgreen:


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: glGetTexParameteriv
BeitragVerfasst: Sa Dez 04, 2010 13:46 
Offline
DGL Member
Benutzeravatar

Registriert: Fr Mai 28, 2010 13:28
Beiträge: 25
Wohnort: Ελλάδα -- Greece
Programmiersprache: Delphi, FreePascal
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....

_________________
Try to think first before you act....


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: glGetTexParameteriv
BeitragVerfasst: So Dez 05, 2010 07:38 
Offline
DGL Member
Benutzeravatar

Registriert: Fr Mai 28, 2010 13:28
Beiträge: 25
Wohnort: Ελλάδα -- Greece
Programmiersprache: Delphi, FreePascal
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...

_________________
Try to think first before you act....


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: glGetTexParameteriv
BeitragVerfasst: So Dez 05, 2010 09:24 
Offline
DGL Member
Benutzeravatar

Registriert: Fr Dez 11, 2009 08:02
Beiträge: 532
Programmiersprache: pascal (Delphi 7)
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;


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: glGetTexParameteriv
BeitragVerfasst: So Dez 05, 2010 09:33 
Offline
DGL Member
Benutzeravatar

Registriert: Fr Dez 11, 2009 08:02
Beiträge: 532
Programmiersprache: pascal (Delphi 7)
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;


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: glGetTexParameteriv
BeitragVerfasst: So Dez 05, 2010 16:58 
Offline
DGL Member
Benutzeravatar

Registriert: Fr Mai 28, 2010 13:28
Beiträge: 25
Wohnort: Ελλάδα -- Greece
Programmiersprache: Delphi, FreePascal
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 ...

_________________
Try to think first before you act....


Nach oben
 Profil  
Mit Zitat antworten  
Beiträge der letzten Zeit anzeigen:  Sortiere nach  
Ein neues Thema erstellen Auf das Thema antworten  [ 9 Beiträge ] 
Foren-Übersicht » English » English Programming Forum


Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 19 Gäste


Du darfst keine neuen Themen in diesem Forum erstellen.
Du darfst keine Antworten zu Themen in diesem Forum erstellen.
Du darfst deine Beiträge in diesem Forum nicht ändern.
Du darfst deine Beiträge in diesem Forum nicht löschen.
Du darfst keine Dateianhänge in diesem Forum erstellen.

Suche nach:
Gehe zu:  
cron
  Powered by phpBB® Forum Software © phpBB Group
Deutsche Übersetzung durch phpBB.de
[ Time : 0.049s | 17 Queries | GZIP : On ]