TEXTURE CSE 410. Add Texture to Polygon glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D,texid); // here texid corresponds a bitmap image. glNormal3f(1.0,0.0,0.0);

Slides:



Advertisements
Similar presentations
Hofstra University1 Texture Motivation: to model realistic objects need surface detail: wood grain, stone roughness, scratches that affect shininess, grass,
Advertisements

1 Understanding of OpenGL TA: Dong Hyun Jeong Instructor : Dr. Kalpathi Subramanian Texture Mapping.
TEXTURE MAPPING JEFF CHASTINE 1. TEXTURE MAPPING Applying an image (or a texture ) to geometry 2D images (rectangular) 3D images (volumetric – such as.
OpenGL Texture Mapping
CH6 Texture. Before coding … 1/2 Prepare all texture images you need. BMP file is a good choice If you want to use TIFF file, maybe try this.
Texture Mapping OpenGl and Implementation Details CS
GLSL Applications: 2 of 2 Patrick Cozzi University of Pennsylvania CIS Spring 2011.
Hofstra University1 Texture Motivation: to model realistic objects need surface detail: wood grain, stone roughness, scratches that affect shininess, grass,
ADDITIONAL TIPS Multi-texture Slides. Here is a link Workflow: /**************In texture parameter set up******/ call glActiveTextureARB(/*pick texture.
1 Lecture 12 Texture Mapping uploading of the texture to the video memory the application of the texture onto geometry.
Computer Graphics (Fall 2004) COMS 4160, Lecture 11: OpenGL 2
OpenGL Texture Mapping April 16, Angel: Interactive Computer Graphics 3E © Addison-Wesley 2002 Basic Stragegy Three steps to applying a texture.
CS 4731: Computer Graphics Lecture 17: Texturing Emmanuel Agu.
CSE (Notre Dame) Computer Graphics Lecture 16 A Simple Draw Image Example More Texture Mapping Simple OpenGL Image Library (SOIL) Transparency &
Texture Mapping A way of adding surface details Two ways can achieve the goal:  Surface detail polygons: create extra polygons to model object details.
Texturing in OpenGL Lab #7. Creating Textures glEnable ( GL_TEXTURE_2D ); GLuint myTex; glGenTextures ( 1, (GLuint*) &myTex ); glBindTexture ( GL_TEXTURE_2D,
Texture Mapping. To add surface details… World of Warcraft, Blizzard Inc. More polygons (slow and hard to handle small details) Less polygons but with.
Computer Graphics Texture Mapping Eriq Muhammad Adams
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
2IV60 Computer Graphics set 10: Texture mapping Jack van Wijk TU/e.
2002 by Jim X. Chen: 1 Texture Lab At each rendered pixel, selected texels are used either to substitute for or to scale.
Lecture 8: Texture Mapping 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 718,  ex 2271
Module 04 – Texture mapping, Texture filtering, Lighting and Blending Module 04 Texture mapping, Texture filtering, Lighting and Blending.
Texture Mapping. Introduction What is Texture Mapping? Types of Texture Mapping –1D, 2D and 3D SDL and OpenGL.
Texture Mapping. Example Mappings Mapping Techniques Consider the problem of rendering a sphere in the examples The geometry is very simple - a sphere.
Texturing A picture is worth a thousand words. Texturing Texturing is the art of doing this with any picture to any model.  (This is Opus the Penguin.
Texture Mapping Course: Computer Graphics Presented by Fan Chen
Computer Graphics Ben-Gurion University of the Negev Fall 2012.
ECSE-4750 Computer Graphics Fall 2004 Prof. Michael Wozny TA. Abhishek Gattani TA. Stephen
CS380 LAB IV OpenGL Jonghyeob Lee Reference1. [OpenGL course slides by Rasmus Stenholt] Reference2. [
Lecture 27: Texture Mapping Li Zhang Spring 2008
And Some Extra Information From
Texture Mapping. 2 Motivation A typical modern graphics card can handle 10s of millions of polygons a second. How many individual blades of grass are.
OpenGL Texture Mapping. 2 Objectives Introduce the OpenGL texture functions and options.
CG1 Labs Wei Li. Back Face Culling // enable back-face culling glEnable( GL_CULL_FACE ); // orientation of front-facing polygons glFrontFace( GL_CCW );
Texture Mapping in OpenGL. Texture Mapping Imaging we are “pasting” a picture onto a model  Which part of the picture will be pasted onto which part.
Texture Mapping Drawing Pictures on Polygons. Texture Mapping.
TEXTURES & OTHER GOODIES Computer Graphics. glTexCoord2f(...); + =
Computer Science Term 1, 2006 Tutorial 2 Assignment 3 – The Virtual World.
2 COEN Computer Graphics I Evening’s Goals n Discuss displaying and reading image primitives n Describe texture mapping n Discuss OpenGL modes and.
October 9, 2002Serguei A. Mokhov, 1 COMP471 – Computer Graphics OpenGL: Texture Mapping.
CH8 Frame Buffer Object 1. Introduction Name OpenGL :Frame Buffer Object DirectX:Render Target Usage Render to Texture 2.
Texture Mapping. 2 3 Loading Textures void glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border,
OpenGL Programming Guide : Texture Mapping Yoo jin wook Korea Univ. Computer Graphics Lab.
CH6 Texture. Pixel pipeline Vertex pipeline Course Map Transformation & Lighting Primitive assembly Viewport culling & clipping Texture blending Per Fragment.
Texture Mapping. checker.c Texture-Mapped Squares.
1 Graphics CSCI 343, Fall 2015 Lecture 25 Texture Mapping.
CH6 Texture.
Details of Texture Mapping Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, December 1, 2003.
CH6 Texture. Pixel pipeline Vertex pipeline Course Map Transformation & Lighting Primitive assembly Viewport culling & clipping Texture blending Per Fragment.
MP3 Frequently Asked Questions (IN OFFICE HOURS).
CH6 Texture. Before coding … 1/2 Prepare all texture images you need. BMP file is a good choice If you want to load other format, you can try the FreeImage.
CPSC 591/691 Lab Assignment: Attribute-Based Texture Mapping Based on the paper: X-Toon: An extended toon shader Barla et al, NPAR ‘06 PDF + video here:
Texture Mapping CEng 477 Introduction to Computer Graphics.
Texture Mapping Fall, 2016.
Texture Mapping 고려대학교 컴퓨터 그래픽스 연구실 kucg.korea.ac.kr.
Texture Mapping We can improve the realism of graphics models by mapping a texture pattern (image) onto the modeled object surface. We refer to this technique.
OpenGL Texture Mapping
texturing a parametric surface
Advanced Graphics Algorithms Ying Zhu Georgia State University
Advanced Graphics Algorithms Ying Zhu Georgia State University
OpenGL Texture Mapping
Computer Graphics, Lee Byung-Gook, Dongseo Univ.
Assignment 3b Q&A.
Lecture 21: Texture mapping Li Zhang Spring 2010
3D Game Programming Texture Mapping
Computer Graphics Practical Lesson 6
OpenGL Texture Mapping
Programming Textures Lecture 15 Fri, Sep 28, 2007.
CS 480/680 (Fall 2018) Part 2: Texture Loading
Presentation transcript:

TEXTURE CSE 410

Add Texture to Polygon glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D,texid); // here texid corresponds a bitmap image. glNormal3f(1.0,0.0,0.0); glBegin(GL_POLYGON); glTexCoord2f(0,0); glVertex3f(47.5,7.3,-1.5); glTexCoord2f(1,0); glVertex3f(47.5,7.3,1.5); glTexCoord2f(1,1); glVertex3f(47.5,12.5,1.5); glTexCoord2f(0,1); glVertex3f(47.5,12.5,-1.5); glEnd(); glDisable(GL_TEXTURE_2D); z y x

Add Texture To Cylinder GLUquadricObj* IDquadric; glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texid); // here texid corresponds a bitmap image. gluQuadricNormals(IDquadric,GLU_SMOOTH); // One normal is generated for every vertex of a quadric. gluQuadricTexture(IDquadric, GLU_TRUE); //if texturing is desired for quadrics gluCylinder(IDquadric, base,top,height, slices, stacks); glDisable(GL_TEXTURE_2D);

Add Texture To Sphere GLUquadricObj* IDquadric; glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texid); gluQuadricNormals(IDquadric,GLU_SMOOTH); gluQuadricTexture(IDquadric, GLU_TRUE); gluSphere(IDquadric,Radius,slice,stack); glDisable(GL_TEXTURE_2D);

Initilization Functions For each texture image declare a global variable as follows GLuint texid; Within Init() call a function say func(), which loads bitmap images.

Func() void func(void) { texid =LoadBitmap("bkg1.bmp"); /*here bkg1.bmp is the bitmap image to be used as texture, texid is global varible declared to uniquely identify this particular image*/ b =LoadBitmap("b.bmp"); stone = LoadBitmap("stone.bmp"); walltile = LoadBitmap("walltile.bmp"); checktile = LoadBitmap("checktile.bmp"); road = LoadBitmap("road.bmp"); brick = LoadBitmap("brick.bmp"); tiles = LoadBitmap("tiles.bmp"); c = LoadBitmap("c.bmp"); a = LoadBitmap("a.bmp"); }

LoadBitmap() int num_texture = -1; int LoadBitmap(char *filename) { int i, j=0; FILE *l_file; unsigned char *l_texture; BITMAPFILEHEADER fileheader; BITMAPINFOHEADER infoheader; RGBTRIPLE rgb; num_texture++; if( (l_file = fopen(filename, "rb"))==NULL) return (-1); fread(&fileheader, sizeof(fileheader), 1, l_file); fseek(l_file, sizeof(fileheader), SEEK_SET); fread(&infoheader, sizeof(infoheader), 1, l_file); l_texture = (byte *) malloc(infoheader.biWidth * infoheader.biHeight * 4); memset(l_texture, 0, infoheader.biWidth * infoheader.biHeight * 4);

for (i=0; i < infoheader.biWidth*infoheader.biHeight; i++) { fread(&rgb, sizeof(rgb), 1, l_file); l_texture[j+0] = rgb.rgbtRed; l_texture[j+1] = rgb.rgbtGreen; l_texture[j+2] = rgb.rgbtBlue; l_texture[j+3] = 255; j += 4; } fclose(l_file); glBindTexture(GL_TEXTURE_2D, num_texture); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); // glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glTexImage2D(GL_TEXTURE_2D, 0, 4, infoheader.biWidth, infoheader.biHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, l_texture); gluBuild2DMipmaps(GL_TEXTURE_2D, 4, infoheader.biWidth, infoheader.biHeight, GL_RGBA, GL_UNSIGNED_BYTE, l_texture); free(l_texture); return (num_texture); }