Public feed #604033

Mine

public text v1 · immutable
Raw Edit
·published 2007-07-05 07:59 UTC
rendered paste body
	public void drawImage(int texture, int x, int y, GL gl, int width, int height)
	{
		x-=30;
		y+=35;    
		y=(int) Industria.this.getSize().getHeight() - y + 100 - height;
		gl.glBindTexture(gl.GL_TEXTURE_2D,texture);
		
	    gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_S, gl.GL_CLAMP);
	    gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_T, gl.GL_CLAMP);
	    gl.glTexParameterf(gl.GL_TEXTURE_2D,gl. GL_TEXTURE_MAG_FILTER,
	    		gl.GL_LINEAR);
	    gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, 
	    		gl.GL_LINEAR);
	    
	    gl.glTexEnvf(gl.GL_TEXTURE_ENV, gl.GL_TEXTURE_ENV_MODE, gl.GL_REPLACE);
	    gl.glEnable(gl.GL_TEXTURE_2D);
	    gl.glBegin(gl.GL_QUADS); 
	    gl.glEnable( gl.GL_BLEND );
	    gl.glBlendFunc( gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA );
	    gl.glEnable( gl.GL_ALPHA_TEST );
	    gl.glAlphaFunc( gl.GL_NOTEQUAL, 0.0f );

		float xdif=(float)(90.0/128.0);
		float ydif=(float)(90.0/128.0);
		gl.glTexCoord2f(0.0f, 0.0f); gl.glVertex3f(x, y, 0.0f);
		gl.glTexCoord2f(xdif, 0.0f); gl.glVertex3f(x+width, y, 0.0f);
		gl.glTexCoord2f(xdif, ydif); gl.glVertex3f(x+width, y+height, 0.0f);
		gl.glTexCoord2f(0.0f, ydif); gl.glVertex3f(x, y+height, 0.0f);
	    gl.glEnd();
	}



//This is where the textures are loaded into memory
				int width = cl.imgWidth[frame][type][flipped % 2];
				int height = cl.imgHeight[frame][type][flipped % 2];
				pxi = px - width / 2 + 45;
				pyi = py - height + 90;
				if(cl.texPointer[frame][type][flipped%2]==0)
				{
					int[] name=new int[1];
					gl.glGenTextures(1,name,0);
					gl.glBindTexture(gl.GL_TEXTURE_2D,name[0]);
					cl.texPointer[frame][type][flipped%2]=name[0];
					System.out.println("New Texture: "+name[0]);
					
					//gl.glPixelStorei(gl.GL_UNPACK_ALIGNMENT, 1);
					int power=2;
					for(int i=0;power<width||power<height;i++)
					{
						power*=2;
					}
//This is the important part:
				    gl.glTexImage2D(gl.GL_TEXTURE_2D, 0, gl.GL_RGBA8, power, 
			            power, 0, gl.GL_RGBA, gl.GL_UNSIGNED_BYTE, 
			            cl.imgBuffer[frame][type][flipped % 2]);//glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, texWidth, texHeight, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, texPixels) 
					System.out.println("drawImage 2");
					System.out.println("drawImage 3");
				}
				//drawImage(cl.imgBuffer[frame][type][flipped % 2], pxi, pyi - dif, gl, width, height);
				drawImage(cl.texPointer[frame][type][flipped % 2], pxi, pyi - dif, gl, width, height);