当前位置: 首页 > news >正文

建设一个网站的技术可行性研究开发软件的app下载

建设一个网站的技术可行性研究,开发软件的app下载,上海网站推广模板,wordpress修改我要注册链接1 前言 使用Mesh绘制三角形 中介绍了绘制三角形的方法,使用Mesh绘制矩形 中介绍了绘制矩形的方法,本文将介绍绘制圆形的方法。 libGDX 以点、线段、三角形为图元,没有提供绘制圆形的接口。要绘制圆形边框,必须通过割圆法逼近圆形&…

1 前言

        使用Mesh绘制三角形 中介绍了绘制三角形的方法,使用Mesh绘制矩形 中介绍了绘制矩形的方法,本文将介绍绘制圆形的方法。

        libGDX 以点、线段、三角形为图元,没有提供绘制圆形的接口。要绘制圆形边框,必须通过割圆法逼近圆形;要绘制圆形的内部,必须通过三角形逼近圆形,如下图,是通过 GL_TRIANGLE_FAN 模式逼近圆形。

2 绘制圆形

        DesktopLauncher.java

package com.zhyan8.game;import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;public class DesktopLauncher {public static void main (String[] arg) {Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();config.setForegroundFPS(60);config.setTitle("Circle");new Lwjgl3Application(new Circle(), config);}
}

        Circle.java

package com.zhyan8.game;import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL30;
import com.badlogic.gdx.graphics.Mesh;
import com.badlogic.gdx.graphics.VertexAttribute;
import com.badlogic.gdx.graphics.VertexAttributes.Usage;
import com.badlogic.gdx.graphics.glutils.ShaderProgram;public class Circle extends ApplicationAdapter {private ShaderProgram mShaderProgram;private Mesh mMesh;private float mRatio;@Overridepublic void create() {initShader();initMesh();}@Overridepublic void render() {Gdx.gl.glClearColor(0.455f, 0.725f, 1.0f, 1.0f);Gdx.gl.glClear(GL30.GL_COLOR_BUFFER_BIT);mShaderProgram.bind();mShaderProgram.setUniformf("u_wh_ratio", mRatio);mMesh.render(mShaderProgram, GL30.GL_TRIANGLE_FAN); // 绘制圆形内部// mMesh.render(mShaderProgram, GL30.GL_LINE_LOOP); // 绘制圆形框}@Overridepublic void dispose() {mShaderProgram.dispose();mMesh.dispose();}private void initShader() { // 初始化着色器程序String vertex = Gdx.files.internal("shaders/circle_vertex.glsl").readString();String fragment = Gdx.files.internal("shaders/circle_fragment.glsl").readString();mShaderProgram = new ShaderProgram(vertex, fragment);mRatio = 1.0f * Gdx.graphics.getWidth() / Gdx.graphics.getHeight();}private void initMesh() { // 初始化网格int num = 50;float[] vertices = getCircle(0f, 0f, 0.5f, num);short[] indices = getIndices(num);VertexAttribute vertexPosition = new VertexAttribute(Usage.Position, 3, "a_position");mMesh = new Mesh(true, vertices.length / 3, indices.length, vertexPosition);mMesh.setVertices(vertices);mMesh.setIndices(indices);}private float[] getCircle(float centerX, float centerY, float radius, int num) {float unit = (float)(2 * Math.PI / num);float[] coords = new float[num * 3];for (int i = 0; i < num; i++) {coords[i * 3] = (float)(centerX + radius * Math.cos(unit * i));coords[i * 3 + 1] = (float)(centerY + radius * Math.sin(unit * i));coords[i * 3 + 2] = 0;}return coords;}private short[] getIndices(int num) {short[] indices = new short[num];for (short i = 0; i < num; i++) {indices[i] = i;}return indices;}
}

        circle_vertex.glsl

#version 300 esin vec3 a_position;uniform float u_wh_ratio; // 屏幕宽高比void main() {gl_Position = vec4(a_position, 1.0);if (u_wh_ratio > 1.0) {gl_Position.x /= u_wh_ratio;} else {gl_Position.y *= u_wh_ratio;}
}

        circle_fragment.glsl

#version 300 es
precision mediump float; // 声明float型变量的精度为mediumpout vec4 fragColor;void main() {fragColor = vec4(1, 0, 0, 0);
}

http://www.yayakq.cn/news/63383/

相关文章:

  • 做网站下载功能百度做的网站国外可以打开吗
  • 网站建设公司需要具备承德网站推广
  • seo技术网站建设最近发生的重大军事新闻
  • 国外社交网站设计欣赏网站建设需放在哪个科目
  • 浙江银安建设有限公司网站wordpress企业主题模板
  • 网站结构形式有哪些女教师遭网课入侵直播
  • 建设企业网站公积金2_网站建设的一般步骤包含哪些?
  • 西安高端网站制作app定制开发大概多少钱
  • 黄山企业网站建设网络推广内容策划
  • 住房和城乡建设部网站事故快报长春seo主管
  • 网站运营繁忙百度注册
  • 南桥做网站河北石家庄的大学
  • 网站有没有做等级测评怎么查看长网页网站
  • 钓鱼网站制作的报告报社网站建设之思考
  • DW建设网站过程中出现的问题外贸网站建设要求
  • 网站建设培训相关资料怎样做有趣的视频网站
  • 临沂网站优化公司有那种网站么
  • 垂直电商网站建设可以免费开发app的软件
  • 如何将别人的网站作为自己的网站制作 东莞
  • 商城网站建设视频怎么用jsp做网站
  • 邯郸网站制作公司如何制作软件程序
  • 南庄网站开发如何找有需求做网站的公司
  • 区域网站怎么做云服务器可以建网站吗
  • 怎样为网站做推广书签制作 小学生的手工书签
  • 国外做仿牌网站有搜索引擎作弊的网站
  • 百度网页链接长春seo推广
  • 一起做网站吧网站开发网站开发公司哪家好
  • 虚拟主机发布网站吗家庭网站建设
  • 签证网站建设wordpress英文主题破解版
  • 做网站包含什么职位怎样用网站做淘宝客