本文整理汇总了Java中com.jogamp.opengl.glu.GLU.createGLU方法的典型用法代码示例。如果您正苦于以下问题:Java GLU.createGLU方法的具体用法?Java GLU.createGLU怎么用?Java GLU.createGLU使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jogamp.opengl.glu.GLU
的用法示例。
在下文中一共展示了GLU.createGLU方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRealWorldPointFromWindowPoint
import com.jogamp.opengl.glu.GLU; //导入方法依赖的package包/类
@Override
public GamaPoint getRealWorldPointFromWindowPoint(final Point windowPoint) {
int realy = 0;// GL y coord pos
final double[] wcoord = new double[4];
final int x = (int) windowPoint.getX(), y = (int) windowPoint.getY();
final GLU glu = GLU.createGLU(gl);
realy = viewport[3] - y;
glu.gluUnProject(x, realy, 0.1, mvmatrix, 0, projmatrix, 0, viewport, 0, wcoord, 0);
final GamaPoint v1 = new GamaPoint(wcoord[0], wcoord[1], wcoord[2]);
glu.gluUnProject(x, realy, 0.9, mvmatrix, 0, projmatrix, 0, viewport, 0, wcoord, 0);
final GamaPoint v2 = new GamaPoint(wcoord[0], wcoord[1], wcoord[2]);
final GamaPoint v3 = v2.minus(v1).normalized();
final float distance =
(float) (camera.getPosition().getZ() / GamaPoint.dotProduct(new GamaPoint(0.0, 0.0, -1.0), v3));
final GamaPoint worldCoordinates = camera.getPosition().plus(v3.times(distance));
return new GamaPoint(worldCoordinates.x, worldCoordinates.y);
}
示例2: MakeFullScreenQuad
import com.jogamp.opengl.glu.GLU; //导入方法依赖的package包/类
void MakeFullScreenQuad(GL2 gl) {
GLU glu = GLU.createGLU(gl);
g_quadDisplayList = gl.glGenLists(1);
gl.glNewList(g_quadDisplayList, GL2.GL_COMPILE);
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glPushMatrix();
gl.glLoadIdentity();
glu.gluOrtho2D(0.0f, 1.0f, 0.0f, 1.0f);
gl.glBegin(GL2.GL_QUADS);
{
gl.glVertex2f(0.0f, 0.0f);
gl.glVertex2f(1.0f, 0.0f);
gl.glVertex2f(1.0f, 1.0f);
gl.glVertex2f(0.0f, 1.0f);
}
gl.glEnd();
gl.glPopMatrix();
gl.glEndList();
}
示例3: beginPicking
import com.jogamp.opengl.glu.GLU; //导入方法依赖的package包/类
/**
* First pass prepare select buffer for select mode by clearing it, prepare openGL to select mode and tell it where
* should draw object by using gluPickMatrix() method
*
* @return if returned value is true that mean the picking is enabled
*/
@Override
public void beginPicking() {
final GLU glu = GLU.createGLU();
// 1. Selecting buffer
selectBuffer.clear(); // prepare buffer for new objects
gl.glSelectBuffer(selectBuffer.capacity(), selectBuffer);
// Pass below is very similar to refresh method in GLrenderer
// 2. Take the viewport attributes,
final int viewport[] = new int[4];
gl.glGetIntegerv(GL.GL_VIEWPORT, viewport, 0);
// 3. Prepare openGL for rendering in select mode
gl.glRenderMode(GL2.GL_SELECT);
/*
* The application must redefine the viewing volume so that it renders only a small area around the place where
* the mouse was clicked. In order to do that it is necessary to set the matrix mode to GL_PROJECTION.
* Afterwards, the application should push the current matrix to save the normal rendering mode settings. Next
* initialise the matrix
*/
openGL.matrixMode(GL2.GL_PROJECTION);
gl.glPushMatrix();
gl.glLoadIdentity();
/*
* Define the viewing volume so that rendering is done only in a small area around the cursor. gluPickMatrix
* method restrict the area where openGL will drawing objects
*
*/
glu.gluPickMatrix(camera.getMousePosition().x, viewport[3] - camera.getMousePosition().y, 4, 4, viewport, 0);
// FIXME Why do we have to call updatePerspective() here ?
updatePerspective();
openGL.matrixMode(GL2.GL_MODELVIEW);
}
示例4: display
import com.jogamp.opengl.glu.GLU; //导入方法依赖的package包/类
@Override
public void display(GLAutoDrawable arg0) {
GLU glu = GLU.createGLU(m_kGL);
g_numGeoPasses = 0;
m_kGL.glMatrixMode(GL2.GL_MODELVIEW);
m_kGL.glLoadIdentity();
glu.gluLookAt(g_pos[0], g_pos[1], g_pos[2], g_pos[0], g_pos[1], 0, 0, 1, 0);
m_kGL.glRotatef(g_rot[0], 1, 0, 0);
m_kGL.glRotatef(g_rot[1], 0, 1, 0);
m_kGL.glTranslatef(g_bbTrans[0], g_bbTrans[1], g_bbTrans[2]);
m_kGL.glScalef(g_bbScale, g_bbScale, g_bbScale);
switch (g_mode) {
case DUAL_PEELING_MODE:
RenderDualPeeling(m_kGL);
break;
case F2B_PEELING_MODE:
RenderFrontToBackPeeling(m_kGL);
break;
case WEIGHTED_AVERAGE_MODE:
RenderAverageColors(m_kGL);
break;
case WEIGHTED_SUM_MODE:
RenderWeightedSum(m_kGL);
break;
}
/* Call swapBuffers to render on-screen: */
arg0.swapBuffers();
}
示例5: reshape
import com.jogamp.opengl.glu.GLU; //导入方法依赖的package包/类
@Override
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
GL2 gl = drawable.getGL().getGL2();
if (g_imageWidth != width || g_imageHeight != height) {
g_imageWidth = width;
g_imageHeight = height;
DeleteDualPeelingRenderTargets(gl);
InitDualPeelingRenderTargets(gl);
DeleteFrontPeelingRenderTargets(gl);
InitFrontPeelingRenderTargets(gl);
DeleteAccumulationRenderTargets(gl);
InitAccumulationRenderTargets(gl);
}
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
GLU glu = GLU.createGLU(gl);
glu.gluPerspective(FOVY, (float) g_imageWidth / (float) g_imageHeight, ZNEAR, ZFAR);
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glViewport(0, 0, g_imageWidth, g_imageHeight);
}
示例6: init
import com.jogamp.opengl.glu.GLU; //导入方法依赖的package包/类
public void init(GLAutoDrawable canvas) {
scena = "joc";
PRIMA_CULOARE = culoareRandom();
CULOAREA_DOI = culoareRandom();
CULOAREA_TREI = culoareRandom();
culoriAlese[0] = "alb";
culoriAlese[1] = "alb";
culoriAlese[2] = "alb";
nrIncercari = 0;
GL2 gl = canvas.getGL().getGL2();
for (int i = 0; i < 15; i++) {
for (int j = 0; j < 3; j++) {
incercari[i][j] = "gri";
corect[i][j] = "gri";
}
}
// Create a new GLU object.
glu = GLU.createGLU();
glut = new GLUT();
texture1 = new TextureHandler(gl, glu, "texture1.jpg", true);
texture2 = new TextureHandler(gl, glu, "texture2.jpg", true);
text = "Trebuie sa alegi 3 culori!";
// Setting the clear color -- the color which will be used to erase the canvas.
gl.glClearColor(0, 0.5f, 0.5f, 0);
// Selecting the modelview matrix.
gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
// Activate the GL_LINE_SMOOTH state variable. Other options include
// GL_POINT_SMOOTH and GL_POLYGON_SMOOTH.
gl.glEnable(GL.GL_LINE_SMOOTH);
gl.glEnable(GL2.GL_POLYGON_SMOOTH);
// Activate the GL_BLEND state variable. Means activating blending.
gl.glEnable(GL.GL_BLEND);
// Set the blend function. For antialiasing it is set to GL_SRC_ALPHA for the source
// and GL_ONE_MINUS_SRC_ALPHA for the destination pixel.
gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
// Control GL_LINE_SMOOTH_HINT by applying the GL_DONT_CARE behavior.
// Other behaviours include GL_FASTEST or GL_NICEST.
gl.glHint(GL.GL_LINE_SMOOTH_HINT, GL.GL_DONT_CARE);
// Uncomment the following two lines in case of polygon antialiasing
gl.glEnable(GL2.GL_POLYGON_SMOOTH);
gl.glHint(GL2.GL_POLYGON_SMOOTH_HINT, GL.GL_NICEST);
}
示例7: doSelectionRun
import com.jogamp.opengl.glu.GLU; //导入方法依赖的package包/类
private void doSelectionRun(final GLAutoDrawable drawable) {
GL2 gl = drawable.getGL().getGL2();
GLU glu = GLU.createGLU();
IntBuffer buffer = Buffers.newDirectIntBuffer(512);
int hits, n, first = -1;
float z, zmin = Float.POSITIVE_INFINITY;
int[] viewport = new int[4];
gl.glGetIntegerv(GL.GL_VIEWPORT, viewport, 0);
gl.glSelectBuffer(512, buffer);
gl.glRenderMode(GL2.GL_SELECT);
gl.glInitNames();
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glPushMatrix();
gl.glLoadIdentity();
glu.gluPickMatrix(selX, viewport[3] - selY, 1.0, 1.0, viewport, 0);
glu.gluPerspective(60.0, (float)viewport[2] / viewport[3], 1, 100000.0);
// draw graph
renderScene(drawable.getGL().getGL2());
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glPopMatrix();
gl.glFlush();
hits = gl.glRenderMode(GL2.GL_RENDER);
// log.info("Selection run, got " + hits + " hits!");
for(int i = 0; i < hits; ++i) {
n = buffer.get();
z = (float) (buffer.get() & 0xffffffffL) / 0x7ffffff;
buffer.get();
// discard unnecessary stuff
//buffer.position(buffer.position() + n);
for(int j=0; j<n-1; ++j)
buffer.get();
n = buffer.get();
if(z < zmin) {
zmin = z;
first = n;
}
log.info("Buffer: " + n + ", min distance: " + z);
}
synchronized (aCam) {
aCam.selectedObj = objectNameMap.get(first);
selectionRun = false;
aCam.notify();
}
}
示例8: getPixelWidthAndHeightOfWorld
import com.jogamp.opengl.glu.GLU; //导入方法依赖的package包/类
public double[] getPixelWidthAndHeightOfWorld() {
final GLU glu = GLU.createGLU(gl);
final double[] coord = new double[4];
glu.gluProject(getEnvWidth(), 0, 0, mvmatrix, 0, projmatrix, 0, viewport, 0, coord, 0);
return coord;
}