本文整理匯總了Java中javax.media.opengl.GL2.glTexCoord2f方法的典型用法代碼示例。如果您正苦於以下問題:Java GL2.glTexCoord2f方法的具體用法?Java GL2.glTexCoord2f怎麽用?Java GL2.glTexCoord2f使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.media.opengl.GL2
的用法示例。
在下文中一共展示了GL2.glTexCoord2f方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: glRender
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void glRender(GLRenderContext glc)
{
GL2 gl2 = glc.gl2;
gl2.glBegin(GL2.GL_QUADS);
{
gl2.glNormal3f(0, 0, 1);
gl2.glTexCoord2f(0, 1);
gl2.glVertex3f(left, up,0);
gl2.glNormal3f(0, 0, 1);
gl2.glTexCoord2f(0, 0);
gl2.glVertex3f(left, down, 0);
gl2.glNormal3f(0, 0, 1);
gl2.glTexCoord2f(1, 0);
gl2.glVertex3f(right, down, 0);
gl2.glNormal3f(0, 0, 1);
gl2.glTexCoord2f(1, 1);
gl2.glVertex3f(right, up, 0);
}
gl2.glEnd();
}
示例2: createVertex
import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
* Creates a single colour mapped vertex.
*
* @param gl The GL context
* @param N The number of points in the X direction
* @param M The number of points in the Z direction
* @param stepSizeX The size of each quad in the patch
* @param stepSizeY The size of each quad in the patch
* @param X The index along the X direction
* @param Y The index along the Z direction (Y in the data)
*/
private void createVertex( final GL2 gl, final int N, final int M,
final double stepSizeX, final double stepSizeY, final int X, final int Y )
{
final double x = X * stepSizeX;
final double z = Y * stepSizeY;
double y = this.data[Y][X];
if( this.autoScale )
y *= 1d/(this.max-this.min);
if( this.renderType == HeightMapType.TEXTURED )
gl.glTexCoord2f( (float)(x / N), (float)(z / M) );
else
{
final float[] c = this.colour;
if( this.colourMap != null )
this.colourMap.apply( (float)(this.data[Y][X] * 1d/(this.max-this.min)), c );
gl.glColor3f( c[0], c[1], c[2] );
}
gl.glVertex3d( x, y, z );
}
示例3: draw
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void draw(GL2 gl, float height) {
if(blendTexture == null) {
Environment environment = Environment.getInstance();
String texPath = environment.getString(EnvVariable.SCREENSHOT_BLEND_TEXTURE);
try {
blendTexture = TextureIO.newTexture(new File(texPath), false);
} catch (GLException | IOException e) {
Logger.getInstance().warning("Texture " + texPath + " not found!");
}
}
if(active && state != null && blendTexture != null) {
TextureCoords texCoords = blendTexture.getImageTexCoords();
FloatVector3D[] vertices = state.getBoundingBox().getCornersCounterClockwise();
blendTexture.bind(gl);
gl.glBegin(GL2.GL_QUADS);
gl.glTexCoord2f(texCoords.right(), texCoords.top());
gl.glVertex3f(vertices[0].getX(), vertices[0].getY(), 0);
gl.glTexCoord2f(texCoords.left(), texCoords.top());
gl.glVertex3f(vertices[1].getX(), vertices[1].getY(), 0);
gl.glTexCoord2f(texCoords.left(), texCoords.bottom());
gl.glVertex3f(vertices[2].getX(), vertices[2].getY(), 0);
gl.glTexCoord2f(texCoords.right(), texCoords.bottom());
gl.glVertex3f(vertices[3].getX(), vertices[3].getY(), 0);
gl.glEnd();
}
// Draw next layer.
if (this.hasNextLayer()) {
this.getNextLayer().draw(gl, height + HEIGHT_GAP);
}
}
示例4: render
import javax.media.opengl.GL2; //導入方法依賴的package包/類
public void render(GL2 gl) {
// Create the credits texture if not done yet:
if(creditsTexture == null) {
createTexture();
}
if(creditsTexture != null) {
// Activate alpha:
gl.glEnable(GL2.GL_BLEND);
gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA);
// Bind the texture for use:
creditsTexture.bind(gl);
// The textures 2D-coordinates:
TextureCoords texCoords = creditsTexture.getImageTexCoords();
// Backup current matrix:
gl.glPushMatrix();
gl.glLoadIdentity();
// Apply transformation:
gl.glRotatef(rotation, 1, 0, 0);
gl.glTranslatef(0, -2, position);
gl.glRotatef(-90, 1, 0, 0);
// Draw vertices and pass uv-coords.
gl.glBegin(GL2.GL_QUADS);
gl.glTexCoord2f(texCoords.right(), texCoords.top());
gl.glVertex3f(CREDITS_PANE_WIDTH/2, CREDITS_PANE_HEIGHT/2, 0);
gl.glTexCoord2f(texCoords.left(), texCoords.top());
gl.glVertex3f(-CREDITS_PANE_WIDTH/2, CREDITS_PANE_HEIGHT/2, 0);
gl.glTexCoord2f(texCoords.left(), texCoords.bottom());
gl.glVertex3f(-CREDITS_PANE_WIDTH/2, -CREDITS_PANE_HEIGHT/2, 0);
gl.glTexCoord2f(texCoords.right(), texCoords.bottom());
gl.glVertex3f(CREDITS_PANE_WIDTH/2, -CREDITS_PANE_HEIGHT/2, 0);
gl.glEnd();
// Restore matrix:
gl.glPopMatrix();
}
}
示例5: draw
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void draw(GL2 gl, float height) {
// Update and fetch texture.
if (adapter.toDraw()) {
adapter.bindTexture(gl);
Texture tex = adapter.getTexture();
if (tex != null) {
gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA);
tex.bind(gl);
TextureCoords texCoords = tex.getImageTexCoords();
FloatBoundingBox box = adapter.getDrawBox();
FloatVector3D upperLeft = box.getUpperLeft();
FloatVector3D upperRight = box.getUpperRight();
FloatVector3D lowerLeft = box.getLowerLeft();
FloatVector3D lowerRight = box.getLowerRight();
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
gl.glOrthof(-1, 1,
-1, 1,
-10000, 10000);
gl.glDisable(GL2.GL_DEPTH_TEST);
gl.glMatrixMode(GL2.GL_MODELVIEW);
// Lift the x-y-pane up:
gl.glTranslatef(0, 0, height);
// Draw texture.
gl.glBegin(GL2.GL_QUADS);
gl.glTexCoord2f(texCoords.left(), texCoords.top());
gl.glVertex3f(upperLeft.getX(), upperLeft.getY(), 0.0f);
gl.glTexCoord2f(texCoords.left(), texCoords.bottom());
gl.glVertex3f(lowerLeft.getX(), lowerLeft.getY(), 0.0f);
gl.glTexCoord2f(texCoords.right(), texCoords.bottom());
gl.glVertex3f(lowerRight.getX(), lowerRight.getY(), 0.0f);
gl.glTexCoord2f(texCoords.right(), texCoords.top());
gl.glVertex3f(upperRight.getX(), upperRight.getY(), 0.0f);
gl.glEnd();
}
}
// Draw next layer if available.
if (this.hasNextLayer()) {
this.getNextLayer().draw(gl, height + HEIGHT_GAP);
}
}
示例6: draw
import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
* Draws all tiles available for the current view. Also all OpenGL-specific
* work in the adapter must be performed here. To accomplish this
* <code>performGLCalls()</code> is called.
*/
@Override
public void draw(GL2 gl, float height) {
if (adapter != null) {
// Create outstanding textures.
adapter.performGLCalls(gl);
Collection<GLResource> toDraw = adapter.getGLResources();
for (GLResource current : toDraw) {
// Get texture.
Texture tex = adapter.getTexture(current.getKey());
// Bind texture.
if (tex != null) {
tex.bind(gl);
// Vertices to draw.
FloatBoundingBox box = current.getBox();
FloatVector3D[] vertices = box.getCornersCounterClockwise();
// Tex coords.
TextureCoords texCoords = tex.getImageTexCoords();
// Backup the current Model-View-Matrix:
gl.glPushMatrix();
// Lift the x-y-pane up:
gl.glTranslatef(0, 0, height);
// Draw vertices and pass tex coords.
gl.glBegin(GL2.GL_QUADS);
gl.glTexCoord2f(texCoords.right(), texCoords.top());
gl.glVertex3f(vertices[0].getX(), vertices[0].getY(), 0);
gl.glTexCoord2f(texCoords.left(), texCoords.top());
gl.glVertex3f(vertices[1].getX(), vertices[1].getY(), 0);
gl.glTexCoord2f(texCoords.left(), texCoords.bottom());
gl.glVertex3f(vertices[2].getX(), vertices[2].getY(), 0);
gl.glTexCoord2f(texCoords.right(), texCoords.bottom());
gl.glVertex3f(vertices[3].getX(), vertices[3].getY(), 0);
gl.glEnd();
// Restore the old matrix:
gl.glPopMatrix();
}
}
}
// Draw next layer.
if (this.hasNextLayer()) {
this.getNextLayer().draw(gl, height + HEIGHT_GAP);
}
}
示例7: draw
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void draw(GL2 gl, float height) {
// If not done yet, invoke the adapters initialization:
if(!adapterInitialized) {
adapter.performGLInit(gl);
adapterInitialized = true;
}
// Perform all the necessary OpenGL-stuff:
adapter.performGLCalls(gl);
// Update and fetch texture.
Texture tex = adapter.getTexture(CopyrightAdapter.COPYRIGHT_TEXTURE_KEY);
if (tex != null) {
gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA);
tex.bind(gl);
TextureCoords texCoords = tex.getImageTexCoords();
FloatBoundingBox box = adapter.getDrawBox();
if(box != null) {
FloatVector3D upperLeft = box.getUpperLeft();
FloatVector3D upperRight = box.getUpperRight();
FloatVector3D lowerLeft = box.getLowerLeft();
FloatVector3D lowerRight = box.getLowerRight();
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
gl.glOrthof(-1, 1,
-1, 1,
-10000, 10000);
gl.glDisable(GL2.GL_DEPTH_TEST);
gl.glMatrixMode(GL2.GL_MODELVIEW);
// Lift the x-y-pane up:
gl.glTranslatef(0, 0, height);
// Draw texture.
gl.glBegin(GL2.GL_QUADS);
gl.glTexCoord2f(texCoords.left(), texCoords.top());
gl.glVertex3f(upperLeft.getX(), upperLeft.getY(), 0.0f);
gl.glTexCoord2f(texCoords.left(), texCoords.bottom());
gl.glVertex3f(lowerLeft.getX(), lowerLeft.getY(), 0.0f);
gl.glTexCoord2f(texCoords.right(), texCoords.bottom());
gl.glVertex3f(lowerRight.getX(), lowerRight.getY(), 0.0f);
gl.glTexCoord2f(texCoords.right(), texCoords.top());
gl.glVertex3f(upperRight.getX(), upperRight.getY(), 0.0f);
gl.glEnd();
}
}
// Draw next layer.
if (this.hasNextLayer()) {
this.getNextLayer().draw(gl, height + HEIGHT_GAP);
}
}
示例8: draw
import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
* Draws all Wikipedia-POIs available for the current view. Also all
* OpenGL-specific work in the adapter must be performed here.
*/
@Override
public void draw(GL2 gl, float height) {
WikipediaManager wikiManager = (WikipediaManager) ResourceMaster.getInstance().getResourceManager("Wikipedia");
if (wikiManager.isEnabled() && adapter != null && gl != null) {
// Check if the adapter was already initialized.
// This must be done from the OpenGl-thread:
if (!adapterInitialized) {
adapter.performGLInit(gl);
}
// Do further processing in the OpenGL-context:
adapter.performGLCalls(gl);
// Get the texture querying with the default key:
Texture texture = adapter
.getTexture(WikipediaAdapter.WIKIPEDIA_TEXTURE_KEY);
if (texture != null) {
// The textures 2D-coordinates:
TextureCoords texCoords = texture.getImageTexCoords();
gl.glEnable(GL2.GL_BLEND);
gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA);
// Bind the texture for use with every marker to draw:
texture.bind(gl);
// Iterate all markers already converted into GL-coordinates:
Collection<GLResource> glResources = adapter.getGLResources();
for (GLResource current : glResources) {
// Vertices to draw:
FloatBoundingBox box = current.getBox();
FloatVector3D[] vertices = box.getCornersCounterClockwise();
// Backup the current Model-View-Matrix:
gl.glPushMatrix();
// Lift the x-y-pane up:
gl.glTranslatef(0, 0, height);
// Draw vertices and pass uv-coords.
gl.glBegin(GL2.GL_QUADS);
gl.glTexCoord2f(texCoords.right(), texCoords.top());
gl.glVertex3f(vertices[0].getX(), vertices[0].getY(), 0);
gl.glTexCoord2f(texCoords.left(), texCoords.top());
gl.glVertex3f(vertices[1].getX(), vertices[1].getY(), 0);
gl.glTexCoord2f(texCoords.left(), texCoords.bottom());
gl.glVertex3f(vertices[2].getX(), vertices[2].getY(), 0);
gl.glTexCoord2f(texCoords.right(), texCoords.bottom());
gl.glVertex3f(vertices[3].getX(), vertices[3].getY(), 0);
gl.glEnd();
// Restore the old matrix:
gl.glPopMatrix();
}
}
}
// Draw next layer.
if (this.hasNextLayer()) {
this.getNextLayer().draw(gl, height + HEIGHT_GAP);
}
}
示例9: draw
import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
* Draws all POIs available for the current view. Also all OpenGL-specific
* work in the adapter must be performed here.
*/
@Override
public void draw(GL2 gl, float height) {
if (adapter != null && gl != null) {
// Check if the adapter was already initialized.
// This must be done from the OpenGl-thread:
if (!adapterInitialized) {
adapter.performGLInit(gl);
}
// Do further processing in the OpenGL-context:
adapter.performGLCalls(gl);
// Get the texture querying with the default key:
Texture texture = adapter
.getTexture(MarkerAdapter.MARKER_TEXTURE_KEY);
if (texture != null) {
// The textures 2D-coordinates:
TextureCoords texCoords = texture.getImageTexCoords();
gl.glEnable(GL2.GL_BLEND);
gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA);
// Bind the texture for use with every marker to draw:
texture.bind(gl);
// Iterate all markers already converted into GL-coordinates:
Collection<GLResource> glResources = adapter.getGLResources();
for (GLResource current : glResources) {
// Vertices to draw:
FloatBoundingBox box = current.getBox();
FloatVector3D[] vertices = box.getCornersCounterClockwise();
// Backup the current Model-View-Matrix:
gl.glPushMatrix();
// Lift the x-y-pane up:
gl.glTranslatef(0, 0, height);
// Draw vertices and pass uv-coords.
gl.glBegin(GL2.GL_QUADS);
gl.glTexCoord2f(texCoords.right(), texCoords.top());
gl.glVertex3f(vertices[0].getX(), vertices[0].getY(), 0);
gl.glTexCoord2f(texCoords.left(), texCoords.top());
gl.glVertex3f(vertices[1].getX(), vertices[1].getY(), 0);
gl.glTexCoord2f(texCoords.left(), texCoords.bottom());
gl.glVertex3f(vertices[2].getX(), vertices[2].getY(), 0);
gl.glTexCoord2f(texCoords.right(), texCoords.bottom());
gl.glVertex3f(vertices[3].getX(), vertices[3].getY(), 0);
gl.glEnd();
// Restore the old matrix:
gl.glPopMatrix();
}
}
}
// Draw next layer.
if (this.hasNextLayer()) {
this.getNextLayer().draw(gl, height + HEIGHT_GAP);
}
}
示例10: draw
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void draw(GL2 gl, float height) {
if(!texturesLoaded) {
loadTextures();
}
GLState glState = (GLState) StateManager.getInstance().getState(StateType.GLState);
FloatBoundingBox bbox = glState.getBoundingBox();
FloatVector3D current = bbox.getUpperLeft();
TextureCoords texCoords = texUpperLeft.getImageTexCoords();
texUpperLeft.enable(gl);
texUpperLeft.bind(gl);
gl.glBegin(GL2.GL_QUADS);
gl.glTexCoord2f(texCoords.right(), texCoords.top());
gl.glVertex3f(current.getX() + TEXSIZE, current.getY(), layerDist);
gl.glTexCoord2f(texCoords.left(), texCoords.top());
gl.glVertex3f(current.getX(), current.getY(), layerDist);
gl.glTexCoord2f(texCoords.left(), texCoords.bottom());
gl.glVertex3f(current.getX(), current.getY() - TEXSIZE, layerDist);
gl.glTexCoord2f(texCoords.right(), texCoords.bottom());
gl.glVertex2f(current.getX() + TEXSIZE, current.getY() - TEXSIZE);
gl.glEnd();
current = bbox.getLowerRight();
texCoords = texLowerRight.getImageTexCoords();
texLowerRight.enable(gl);
texLowerRight.bind(gl);
gl.glBegin(GL2.GL_QUADS);
gl.glTexCoord2f(texCoords.right(), texCoords.top());
gl.glVertex3f(current.getX(), current.getY() + TEXSIZE, layerDist);
gl.glTexCoord2f(texCoords.left(), texCoords.top());
gl.glVertex3f(current.getX() - TEXSIZE, current.getY() + TEXSIZE, layerDist);
gl.glTexCoord2f(texCoords.left(), texCoords.bottom());
gl.glVertex3f(current.getX() - TEXSIZE, current.getY(), layerDist);
gl.glTexCoord2f(texCoords.right(), texCoords.bottom());
gl.glVertex2f(current.getX(), current.getY());
gl.glEnd();
DrawableLayer nextLayer = getNextLayer();
if(nextLayer != null) {
nextLayer.draw(gl, height + HEIGHT_GAP);
}
}
示例11: draw
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void draw(GL2 gl, float height) {
// If not done yet, invoke the adapters initialization:
if(!adapterInitialized) {
adapter.performGLInit(gl);
}
// Perform all the necessary OpenGL-stuff:
adapter.performGLCalls(gl);
// Update and fetch texture.
Texture tex = adapter.getTexture(CompassAdapter.COMPASS_TEXTURE_KEY);
if (tex != null) {
gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA);
tex.bind(gl);
TextureCoords texCoords = tex.getImageTexCoords();
FloatBoundingBox box = adapter.getDrawBox();
FloatVector3D upperLeft = box.getUpperLeft();
FloatVector3D upperRight = box.getUpperRight();
FloatVector3D lowerLeft = box.getLowerLeft();
FloatVector3D lowerRight = box.getLowerRight();
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
gl.glOrthof(-1, 1,
-1, 1,
-10000, 10000);
gl.glDisable(GL2.GL_DEPTH_TEST);
gl.glMatrixMode(GL2.GL_MODELVIEW);
// Lift the x-y-pane up:
gl.glTranslatef(0, 0, height);
// Draw texture.
gl.glBegin(GL2.GL_QUADS);
gl.glTexCoord2f(texCoords.left(), texCoords.top());
gl.glVertex3f(upperLeft.getX(), upperLeft.getY(), 0.0f);
gl.glTexCoord2f(texCoords.left(), texCoords.bottom());
gl.glVertex3f(lowerLeft.getX(), lowerLeft.getY(), 0.0f);
gl.glTexCoord2f(texCoords.right(), texCoords.bottom());
gl.glVertex3f(lowerRight.getX(), lowerRight.getY(), 0.0f);
gl.glTexCoord2f(texCoords.right(), texCoords.top());
gl.glVertex3f(upperRight.getX(), upperRight.getY(), 0.0f);
gl.glEnd();
}
// Draw next layer.
if (this.hasNextLayer()) {
this.getNextLayer().draw(gl, height + HEIGHT_GAP);
}
}
示例12: draw
import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
* Draws all POIs available for the current view. Also all OpenGL-specific
* work in the adapter must be performed here.
*/
@Override
public void draw(GL2 gl, float height) {
if (adapter != null && gl != null) {
// Check if the adapter was already initialized.
// This must be done from the OpenGl-thread:
if (!adapterInitialized) {
adapter.performGLInit(gl);
}
// Do further processing in the OpenGL-context:
adapter.performGLCalls(gl);
// We want to use textures alpha-channel:
gl.glEnable(GL2.GL_BLEND);
gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA);
// Iterate all markers already converted into GL-coordinates:
Collection<GLResource> glResources = adapter.getGLResources();
for (GLResource current : glResources) {
Texture texture = adapter
.getTexture(current.getKey());
if(texture != null) {
// The textures 2D-coordinates:
TextureCoords texCoords = texture.getImageTexCoords();
// Bind the texture for use with every marker to draw:
texture.bind(gl);
// Vertices to draw:
FloatBoundingBox box = current.getBox();
FloatVector3D[] vertices = box.getCornersCounterClockwise();
// Backup the current Model-View-Matrix:
gl.glPushMatrix();
// Lift the x-y-pane up:
gl.glTranslatef(0, 0, height);
// Draw vertices and pass uv-coords.
gl.glBegin(GL2.GL_QUADS);
gl.glTexCoord2f(texCoords.right(), texCoords.top());
gl.glVertex3f(vertices[0].getX(), vertices[0].getY(), 0);
gl.glTexCoord2f(texCoords.left(), texCoords.top());
gl.glVertex3f(vertices[1].getX(), vertices[1].getY(), 0);
gl.glTexCoord2f(texCoords.left(), texCoords.bottom());
gl.glVertex3f(vertices[2].getX(), vertices[2].getY(), 0);
gl.glTexCoord2f(texCoords.right(), texCoords.bottom());
gl.glVertex3f(vertices[3].getX(), vertices[3].getY(), 0);
gl.glEnd();
// Restore the old matrix:
gl.glPopMatrix();
}
}
}
// Draw next layer.
if (this.hasNextLayer()) {
this.getNextLayer().draw(gl, height + HEIGHT_GAP);
}
}