• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java GLUT类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.sun.opengl.util.GLUT的典型用法代码示例。如果您正苦于以下问题:Java GLUT类的具体用法?Java GLUT怎么用?Java GLUT使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



GLUT类属于com.sun.opengl.util包,在下文中一共展示了GLUT类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: renderPlacedMapEvent

import com.sun.opengl.util.GLUT; //导入依赖的package包/类
/**
     * Render {@link MapEvent} that is placed at fixed place (=not at the player).
     * @param gl
     * @param color what color should be map event drawn.
     * @param mapEvent map event to render.
     */
    private void renderPlacedMapEvent(GL gl, GlColor color, MapEvent mapEvent) {
        LogMapMark mapMark = mapEvent.getMark();
        Location position = mapMark.getLocation();

        if (logger.isLoggable(Level.FINE)) logger.fine(" MSG: " + mapMark.getMessage() + ", LOC: " + position);
//      gl.glEnable(GL.GL_BLEND);
//      gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);

        gl.glPushMatrix();
        {
            gl.glTranslated(position.x, position.y, position.z + SPHERE_RADIUS * 1.1);

            gl.glColor4d(color.r, color.g, color.b, color.a);
    //        glu.gluSphere(quadratic, SPHERE_RADIUS * 3, SPHERE_SLICES, SPHERE_STACKS);
            glu.gluCylinder(quadratic, SPHERE_RADIUS, SPHERE_RADIUS, 2*SPHERE_RADIUS, 4, 1);
        }
        gl.glPopMatrix();

        gl.glDisable(GL.GL_DEPTH_TEST);
        {
            gl.glColor3d(0, 0, 0);
            gl.glRasterPos3d(position.x, position.y, position.z);
            glut.glutBitmapString(GLUT.BITMAP_HELVETICA_12, mapEvent.getMessage());
            gl.glColor3d(1, 1, 1);
        }
        gl.glEnable(GL.GL_DEPTH_TEST);

//      gl.glDisable(GL.GL_BLEND);
    }
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:36,代码来源:UTAgentSubGLRenderer.java


示例2: VisualSignatureView

import com.sun.opengl.util.GLUT; //导入依赖的package包/类
public VisualSignatureView(Rectangle worldWindowRect) 
{
	super(worldWindowRect);

	GLCapabilities capabilities = new GLCapabilities();
	setCanvas(new GLCanvas(capabilities));

       // add a GLEventListener, which will get called when the
	// canvas is resized or needs a repaint
	getGLCanvas().addGLEventListener(this);
	
	linesSet = new TreeSet( new LineComparator() );
       
       //javax.swing.Timer timer = new javax.swing.Timer (10000, this); 
	//timer.start();
       
       GLUT glut = new GLUT();
	
	// precompute here for extra performance.
	for(int i = 0; i < MARKED_PORTS.length; ++i)
	{
		MARKED_PORTS_HEIGHT[i] = HEIGHT * ( 1.0 - Math.pow(MARKED_PORTS[i], 0.333333) / CUBE_ROOT_65535);
		MARKED_PORTS_HEIGHT_MINUS_12[i] = MARKED_PORTS_HEIGHT[i] - 12.0f; 
		MARKED_PORTS_AS_STRINGS[i] = Integer.toString(MARKED_PORTS[i]);
		MARKED_PORTS_AS_STRINGS_WIDTH[i] = 5*glut.glutBitmapLength( GLUT.BITMAP_HELVETICA_10, MARKED_PORTS_AS_STRINGS[i] );
		MARKED_PORTS_X[i] = PORT_AXIS_X_MINUS_20 - MARKED_PORTS_AS_STRINGS_WIDTH[i]; 
	}
	
	setName("VisualSignature");
}
 
开发者ID:chrislee35,项目名称:visualfirewall,代码行数:31,代码来源:VisualSignatureView.java


示例3: renderVerticalBitmapString

import com.sun.opengl.util.GLUT; //导入依赖的package包/类
public void renderVerticalBitmapString(GL gl, float x, float y, int bitmapHeight, int font, String string) 
{
	GLUT glut = new GLUT();
	char c;	
	
	for (int i = 0; i < string.length(); ++i) 
	{
		c = string.charAt(i);
		
		gl.glRasterPos2f(x, y+bitmapHeight*i);
		glut.glutBitmapCharacter(font, c);
	}

}
 
开发者ID:chrislee35,项目名称:visualfirewall,代码行数:15,代码来源:IDSAlarmView.java


示例4: axis

import com.sun.opengl.util.GLUT; //导入依赖的package包/类
public void axis(GL gl, double length) {
	
	GLUT glut = new GLUT();
	
	// draw a z-axis, with cone at end
	gl.glPushMatrix();
		gl.glBegin(GL.GL_LINES);
			gl.glVertex3d(0, 0, 0);
			gl.glVertex3d(0, 0, length);
		gl.glEnd();
		gl.glTranslated(0, 0, length - 0.2);
		glut.glutWireCone(0.04, 0.2, 12, 9);
	gl.glPopMatrix();
}
 
开发者ID:sddaniels,项目名称:wongs-wiivenge,代码行数:15,代码来源:DrawableObject.java


示例5: drawText

import com.sun.opengl.util.GLUT; //导入依赖的package包/类
private void drawText(GL gl, float x, float y, String text) {
	
	GLUT glut = new GLUT();
	
	// "shadow"
	gl.glColor4d(0, 0, 0, 0.8);
	gl.glRasterPos2f(x - 0.2f, y - 0.2f);
	glut.glutBitmapString(GLUT.BITMAP_HELVETICA_18, text);
	
	// text
	gl.glColor4d(1, 1, 1, 0.8);
	gl.glRasterPos2f(x, y);
	glut.glutBitmapString(GLUT.BITMAP_HELVETICA_18, text);
}
 
开发者ID:sddaniels,项目名称:wongs-wiivenge,代码行数:15,代码来源:GLCallbacks.java


示例6: renderInfo

import com.sun.opengl.util.GLUT; //导入依赖的package包/类
/**
     * Render info about agent (in most cases event messages) and its name.
     * TODO: Ugly code, refactor
     * @param gl
     * @param color What color should be used to render info.
     * @param location position of agent
     */
    private void renderInfo(GL gl, GlColor color, Location location) {
        // get text
        List<String> infos = new ArrayList<String>(agent.getAssociatedInfo());
        infos.add(0, '*' + agent.getName() + '*');

        Location topHead = new Location(location);
        topHead = new Location(topHead.x, topHead.y, topHead.z + 2 * SPHERE_RADIUS * 1.1);

        Location top2d = GLTools.getScreenCoordinates(gl, glu, topHead, null);

        int lineGap = 12;
        int font = GLUT.BITMAP_HELVETICA_10;

        int maxWidth = 0;
        for (String line : infos) {
            int lineWidth = glut.glutBitmapLength(font, line);
            if (lineWidth > maxWidth) {
                maxWidth = lineWidth;
            }
        }

        // update starting  position
        top2d = new Location(top2d.x - maxWidth / 2, top2d.y + (infos.size() - 1) * lineGap);        

        GlColor textColor = color.getMixedWith(new GlColor(0, 0, 0), 80);

        gl.glColor3d(textColor.r, textColor.g, textColor.b);
        for (int i = 0; i < infos.size(); i++) {
            String text = infos.get(i);
            if (i == 0) {
                gl.glColor3d(color.r, color.g, color.b);
            } else {
                gl.glColor3d(textColor.r, textColor.g, textColor.b);
//                gl.glColor3d(0, 0, 0);
            }
            Location textPos = GLTools.getWorldCoordinates(gl, glu, top2d, null);
            gl.glRasterPos3d(textPos.x, textPos.y, textPos.z);
            glut.glutBitmapString(font, text);

            top2d = top2d.setY(top2d.y - lineGap);
        }
    }
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:50,代码来源:UTAgentSubGLRenderer.java


示例7: outputText

import com.sun.opengl.util.GLUT; //导入依赖的package包/类
void outputText(GL gl, int x, int y, String text)
{
	gl.glRasterPos2f(x, y);
	glut.glutBitmapString(GLUT.BITMAP_HELVETICA_18, text);
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:6,代码来源:Demo3D.java


示例8: display

import com.sun.opengl.util.GLUT; //导入依赖的package包/类
/**
 * Display event
 */
public void display(GLAutoDrawable GLAutoDrawable)
{
	final GL gl = GLAutoDrawable.getGL();
	
	gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);	//Clear the buffers
	gl.glLoadIdentity();											//Reset the view
	
	gl.glRotatef(xRotation, 1.0f, 0.0f, 0.0f);
	gl.glRotatef(yRotation, 0.0f, 1.0f, 0.0f);
	gl.glTranslatef(-xListenerPos, -yListenerPos, -zListenerPos);
	
	// clear
	gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
	gl.glClearColor(0.4f, 0.6f, 1.0f, 0.0f);
	
	gl.glEnable(GL.GL_TEXTURE_2D);
	gl.glBindTexture(GL.GL_TEXTURE_2D, texture);
	
	// draw geometry
	drawGeometry(gl, walls);
	drawGeometry(gl, rotatingMesh);
	drawGeometry(gl, doorList[0]);
	drawGeometry(gl, doorList[1]);
	drawGeometry(gl, doorList[2]);
	drawGeometry(gl, doorList[3]);
	
	gl.glDisable(GL.GL_TEXTURE_2D);
	
	// draw sound objects
	for(int object = 0; object < objects.length; object++)
	{
		FloatBuffer directOcclusion = newFloatBuffer(SIZEOF_FLOAT);
		FloatBuffer reverbOcclusion = newFloatBuffer(SIZEOF_FLOAT);
		directOcclusion.put(0, 1.0f);
		reverbOcclusion.put(0, 1.0f);
		
		// set colour baced on direct occlusion
		objects[object].channel.get3DOcclusion(directOcclusion, reverbOcclusion);
		float intensity = 1.0f - directOcclusion.get(0);
		
		gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL);
		gl.glPushMatrix();
		gl.glTranslatef(objects[object].xPos, objects[object].yPos, objects[object].zPos);
		
		gl.glPushAttrib(GL.GL_LIGHTING_BIT);
		
		intensity *= 0.75f;
		float[] color = new float[]{intensity, intensity, 0.0f, 0.0f};
		gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_DIFFUSE, color, 0);
		intensity *= 0.5f;
		float[] ambient = new float[]{intensity, intensity, 0.0f, 0.0f};
		gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT, ambient, 0);
		
		gl.glRotatef(accumulatedTime * 200.0f, 0.0f, 1.0f, 0.0f);
		new GLUT().glutSolidTorus(0.15f, 0.6f, 8, 16);
		gl.glPopAttrib();
		gl.glPopMatrix();
	}
	
	timerFunc();
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:65,代码来源:Geometry_.java


示例9: drawAxis

import com.sun.opengl.util.GLUT; //导入依赖的package包/类
void drawAxis(GL gl)
{
	/////////////// Draw top and bottom boundaries //////////////////
	gl.glColor3f(BG_RGB[0] + 0.1f, BG_RGB[1] + 0.1f, BG_RGB[2] + 0.1f);
	gl.glPointSize(1.0f);
	
	gl.glBegin(GL.GL_LINES);
       gl.glVertex2d(0.0f, HEIGHT - 1);
	gl.glVertex2d(WIDTH, HEIGHT - 1);
	gl.glEnd();
	
	gl.glBegin(GL.GL_LINES);
       gl.glVertex2d(0.0f, 0.0f);
	gl.glVertex2d(WIDTH, 0.0f);
	gl.glEnd();
	/////////////////////////////////////////////////////////////////
	
	
	
	//if(DEBUG)System.out.println("VisualSignatureView: drawAxis() called");
	GLUT glut = new GLUT();
	
	gl.glColor3f(AXIS_RGB[0], AXIS_RGB[1], AXIS_RGB[2]);
	gl.glPointSize(5.0f);
	
	gl.glBegin(GL.GL_LINES);
       gl.glVertex2d(PORT_AXIS_X, 0.0f);
	gl.glVertex2d(PORT_AXIS_X, HEIGHT);
	gl.glEnd();
	
	
	for(int i = 0; i < MARKED_PORTS.length; ++i)
	{
		//double tmpHeight = 1.0 - Math.pow(MARKED_PORTS[i], .3333) / CUBE_ROOT_65535;
		//tmpHeight *= HEIGHT;
		
		gl.glBegin(GL.GL_LINES);
        gl.glVertex2d(PORT_AXIS_X_MINUS_10, (float)MARKED_PORTS_HEIGHT[i]);
		gl.glVertex2d(PORT_AXIS_X_PLUS_10, (float)MARKED_PORTS_HEIGHT[i]);
		gl.glEnd();
		
		///////////////////////////////////////////////////////////
		
		if(isMaximized)
		{
			//int width = glut.glutBitmapLength( GLUT.BITMAP_HELVETICA_10, MARKED_PORTS_AS_STRINGS[i] );
			
			gl.glRasterPos2f((float)MARKED_PORTS_X[i], (float)MARKED_PORTS_HEIGHT_MINUS_12[i]);
			//Take a string and make it a bitmap, put it in the 'gl' passed over and pick
			//the GLUT font, then provide the string to show
			glut.glutBitmapString(GLUT.BITMAP_HELVETICA_10, MARKED_PORTS_AS_STRINGS[i]);
		}
	}
	
	gl.glBegin(GL.GL_LINES);
       gl.glVertex2d(ADDR_AXIS_X, 0.0f);
	gl.glVertex2d(ADDR_AXIS_X, HEIGHT);
	gl.glEnd();
	
	if(isMaximized)
	{
		gl.glRasterPos2f(ADDR_AXIS_X_PLUS_20, HIGH_ADDR_HEIGHT);
		glut.glutBitmapString(GLUT.BITMAP_HELVETICA_10, "255.255.255.255");
		
		gl.glRasterPos2f(ADDR_AXIS_X_PLUS_20, LOW_ADDR_HEIGHT);
		glut.glutBitmapString(GLUT.BITMAP_HELVETICA_10, "0.0.0.0" );
	}
}
 
开发者ID:chrislee35,项目名称:visualfirewall,代码行数:69,代码来源:VisualSignatureView.java


示例10: display

import com.sun.opengl.util.GLUT; //导入依赖的package包/类
public void display(GLAutoDrawable drawable) 
{
	if(DEBUG)System.out.println("PongView: display() called");

	long inTime = System.currentTimeMillis();
	
	// System.out.println ("display()");
	
	GL gl = getGLCanvas().getGL();
	GLU glu = new GLU();

	// is there a pending world window change?
	if (worldWindowChanged)
		resetWorldWindow(gl, glu);

	//calls gl compiled drawStaticGraphics
	gl.glCallList(1);		
		
	drawICMPChart(gl);	
	
	GLUT glut = new GLUT();
	
	//update and draw every ball
	updateDisplaySimul(gl, glut);
}
 
开发者ID:chrislee35,项目名称:visualfirewall,代码行数:26,代码来源:PongView.java


示例11: display

import com.sun.opengl.util.GLUT; //导入依赖的package包/类
@Override
    public void display(GLAutoDrawable glAutoDrawable) {
       // System.out.println("MER.display " + time + " " + this.mapEvent.getMessage());

        GL gl = glAutoDrawable.getGL();

        gl.glPushMatrix();

        gl.glTranslated(location.x, location.y, location.z + 60 * 1.1);

        // display small
  //      gl.glEnable(GL.GL_BLEND);
        gl.glBlendFunc(GL.GL_SRC_ALPHA,GL.GL_ONE_MINUS_SRC_ALPHA);



        GlColor color = new GlColor(entity.getColor(), 0.5);
        gl.glColor4d(color.r, color.g, color.b, color.a);

        GLUquadric quadratic = glu.gluNewQuadric();
        glu.gluSphere(quadratic, SPHERE_RADIUS, SPHERE_SLICES, SPHERE_STACKS);

        gl.glPopMatrix();

        gl.glDisable(GL.GL_DEPTH_TEST);
        gl.glColor3d(1,1,1);
        gl.glRasterPos3d(location.x, location.y, location.z);
        glut.glutBitmapString(GLUT.BITMAP_HELVETICA_12, this.mapEvent.getMessage());
        gl.glEnable(GL.GL_DEPTH_TEST);

//        gl.glDisable(GL.GL_BLEND);
    }
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:33,代码来源:MapEventRenderer.java



注:本文中的com.sun.opengl.util.GLUT类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SmartPersistenceUnitInfo类代码示例发布时间:2022-05-23
下一篇:
Java Bindings类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap