[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] 2D OpenGL vs. Canvas



On Mon, 19 Jan 2004 11:04:34 +0100
Anders Hellerup Madsen <sslug@sslug> wrote:

> 
> Er det ikke præcis derfor man skal lade være med at bruge 3D libraries
> 
> til at lave 2D ting? SDL har f.eks. et flag man kan angive til blit 
> funktionerne om at det skal vente på vertical refresh.

OpenGL har overladt dette til OS'et. X -vsyns. M$W er deten driver
option. OS X ???

> Jeg er ikke selv overdrevent god til OpenGL, 

heller ikke jeg men det hjælper da på det :)

> men mit indtryk er at det
> altså ikke er til 2D applikationer det udmærker sig bedst. F.eks. er
> det da halvbesværligt at bruge en simpel PutPixel funktion. Hvis jeg
> har taget totalt fejl her så undskylder jeg selvfølgelig - jeg ved
> sikkert bare ikke bedre.

Det er ved hjælp af OpenGL muligt at uploade sine textures til
hardwaren. Så det går hurtigt !!!

   GLuint textID[1];
   glGenTextures(1, &textID[0]);
   glBindTexture( GL_TEXTURE_2D, &textID[0]);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);   
   glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA,
              GL_UNSIGNED_BYTE, &image);

   // ... Senere i programmet...
   glEnable( GL_TEXTURE_2D );
   glBindTexture( GL_TEXTURE_2D, &textID[0]);
   glBegin( GL_QUADS );
      glTexCoord2i(0, 0); glVertex2i(...);
      glTexCoord2i(0, 1); glVertex2i(...);
      glTexCoord2i(1, 1); glVertex2i(...);
      glTexCoord2i(1, 0); glVertex2i(...);
   glEnd();  
   glDisable( GL_TEXTURE_2D );
   

Jeg er helt klart blevet overbevist. Men ja det virker noget mere
besværligt ved første øjekast... men det handler nok mere om at man ikke
rigtig ved hvad man gør og hvorfor (sådan er det for mig i
hvertilfælde). Men jo mere man får arbejdet med det så ændre det sig...
display lists er en stor hjælp også.

(John =;-)


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 22:43 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *