Texture import com sun opengl util texture Texture

  • Slides: 24
Download presentation

Texture import com. sun. opengl. util. texture; *. Texture tree; //declare a texture var

Texture import com. sun. opengl. util. texture; *. Texture tree; //declare a texture var public void Init (GLAuto. Drawable arg 0){ try { GL gl = arg 0. get. GL(); // get the GL object String Filename=“Tree. gif”; // the File. Name to open tree=Texture. IO. new. Texture(new File( File. Name ), True); } catch (GLException e) { e. print. Stack. Trace(); } catch (IOException e) { e. print. Stack. Trace(); } } 1/26/2022 7

Texture tree. bind(); //bind the texture , tells open. GL that we dill with

Texture tree. bind(); //bind the texture , tells open. GL that we dill with this texture now gl. Begin (GL. GL_QUADS; ( gl. Tex. Coord 2 f(0. 0 f, 0. 0 f); // give the texture coordinates to bind gl. Vertex 3 f(30. 0 f, 30. 0 f ); // the vertex gl. Tex. Coord 2 f(1. 0 f, 0. 0 f); // give the texture coordinates to bind gl. Vertex 3 f(30. 0 f, 40. 0 f); // the vertex gl. Tex. Coord 2 f(1. 0 f, 1. 0 f); // give the texture coordinates to bind gl. Vertex 3 f(30. 0 f, 5. 0 f, 40. 0 f); // the vertex gl. Tex. Coord 2 f(0. 0 f, 1. 0 f); // give the texture coordinates to bind gl. Vertex 3 f(30. 0 f, 5. 0 f, 30. 0 f); // the vertex Gl. gl. End(); 1/26/2022 9

Texture Wrapping ? ? ( איך הטקסטורה מתנהגת 1, 1) ( חורגים מ s

Texture Wrapping ? ? ( איך הטקסטורה מתנהגת 1, 1) ( חורגים מ s , t) אם n הפיקסל האחרון בטקסטורה יחזור על עצמו - GL. GL_CLAMP הטקסטורה תחזור על עצמה - GL. GL_REPEAT הגדרה n Tree. gl. Tex. Parameteri ( GL. GL_TEXTURE_2 D, GL. GL_TEXTURE_WRAP_T, GL. GL_REPEAT ) Tree. gl. Tex. Parameteri( GL. GL_TEXTURE_2 D, GL. GL_TEXTURE_WRAP_S, GL. GL_CLAMP ) 1/26/2022 11

Texture Filtering L_NEARIST n . הטקסל הכי קרוב לפיקסל יצויר GL_LINEAR n ממוצע משוקלל

Texture Filtering L_NEARIST n . הטקסל הכי קרוב לפיקסל יצויר GL_LINEAR n ממוצע משוקלל של הטקסלים הקרובים לפיקסל יצויר Tree. set. Tex. Parameteri (GL. GL_TEXTURE_MAG_FILTER, GL. GL_REPEAT; ( Tree. set. Tex. Parameteri (GL. GL_TEXTURE_MIN_FILTER, GL. GL_REPEAT; ( 1/26/2022 13

Texture Mip. Maps 1/26/2022 15

Texture Mip. Maps 1/26/2022 15

Texture 1/26/2022 שקיפות 21

Texture 1/26/2022 שקיפות 21

Texture שקיפות בדיקת אלפה n אפשור וביטול הבדיקה gl. Enable(GL. GL_ALPHA_TEST ) gl. Disable(

Texture שקיפות בדיקת אלפה n אפשור וביטול הבדיקה gl. Enable(GL. GL_ALPHA_TEST ) gl. Disable( GL. GL_ALPHA_TEST ) הגדרת הפונקציה לפיה בודקים את הערך n gl. Alpha. Func( GLenum func , GLclampf ref) ערכים אפשריים n GL_NEVER Never accept GL_ALWAYS Always accept GL_LESS Accept if fragment alpha < ref GL_LEQUAL Accept if fragment alpha <= ref GL_EQUAL Accept if fragment alpha = ref GL_GEQUAL Accept if fragment alpha >= ref GL_GREATER Accept if fragment alpha > ref GL_NOTEQUAL Accept if fragment alpha not equal to ref 1/26/2022 22

Texture שקיפות // do not draw the transparent parts of the texture gl. Enable(GL.

Texture שקיפות // do not draw the transparent parts of the texture gl. Enable(GL. GL_BLEND); gl. Blend. Func (GL. GL_SRC_ALPHA, GL. GL_ONE_MINUS_SRC_ALPHA); // don't show source alpha parts in the destination // determine which areas of the polygon are to be rendered gl. Enable(GL. GL_ALPHA_TEST); gl. Alpha. Func(GL. GL_GREATER, 0); // only render if alpha > 0 1/26/2022 23

Open. GL ? שאלות 1/26/2022 24

Open. GL ? שאלות 1/26/2022 24