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

南宁自助建站模板下载如何做百度关键词推广

南宁自助建站模板下载,如何做百度关键词推广,网页设计培训怎么学,住房建设网站柳州1 前言 使用Mesh绘制三角形 中介绍了绘制三角形的方法,本文将介绍绘制正方形的方法。 libGDX 以点、线段、三角形为图元,没有提供绘制矩形内部的接口。要绘制矩形内部,必须通过三角形拼接而成,如下图,是通过GL_TRIANGL…

1 前言

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

        libGDX 以点、线段、三角形为图元,没有提供绘制矩形内部的接口。要绘制矩形内部,必须通过三角形拼接而成,如下图,是通过GL_TRIANGLE_FAN 模式绘制矩形。

        绘制的坐标点如下,屏幕中心为坐标原点,向右和向上分别为 x 轴和 y 轴正方向。

float[] vertices = {-0.5f, -0.5f, 0.0f, // 左下0.5f, -0.5f, 0.0f, // 右下0.5f, 0.5f, 0.0f, // 右上-0.5f, 0.5f, 0.0f // 左上
};

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("Square");new Lwjgl3Application(new Square(), config);}
}

        Square.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 Square extends ApplicationAdapter {private ShaderProgram mShaderProgram;private Mesh mMesh;@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();mMesh.render(mShaderProgram, GL30.GL_TRIANGLE_FAN);}@Overridepublic void dispose() {mShaderProgram.dispose();mMesh.dispose();}private void initShader() { // 初始化着色器程序String vertex = Gdx.files.internal("shaders/square_vertex.glsl").readString();String fragment = Gdx.files.internal("shaders/square_fragment.glsl").readString();mShaderProgram = new ShaderProgram(vertex, fragment);}private void initMesh() { // 初始化网格float[] vertices = {-0.5f, -0.5f, 0.0f, // 左下0.5f, -0.5f, 0.0f, // 右下0.5f, 0.5f, 0.0f, // 右上-0.5f, 0.5f, 0.0f // 左上};short[] indices = {0, 1, 2, 3};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);}
}

        square_vertex.glsl

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

        square_fragment.glsl

#version 300 esin vec3 a_position;void main() {gl_Position = vec4(a_position, 1.0);
}

        运行效果如下。

3 绘制正方形

        Square.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 Square 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);}@Overridepublic void dispose() {mShaderProgram.dispose();mMesh.dispose();}private void initShader() { // 初始化着色器程序String vertex = Gdx.files.internal("shaders/square_vertex.glsl").readString();String fragment = Gdx.files.internal("shaders/square_fragment.glsl").readString();mShaderProgram = new ShaderProgram(vertex, fragment);mRatio = 1.0f * Gdx.graphics.getWidth() / Gdx.graphics.getHeight();}private void initMesh() { // 初始化网格float[] vertices = {-0.5f, -0.5f, 0.0f, // 左下0.5f, -0.5f, 0.0f, // 右下0.5f, 0.5f, 0.0f, // 右上-0.5f, 0.5f, 0.0f // 左上};short[] indices = {0, 1, 2, 3};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);}
}

        square_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;}
}

        square_fragment.glsl

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


文章转载自:
http://plagiary.c7498.cn
http://globalization.c7498.cn
http://solidaric.c7498.cn
http://refractional.c7498.cn
http://anourous.c7498.cn
http://boundless.c7498.cn
http://reptile.c7498.cn
http://occurrent.c7498.cn
http://sulfapyrazine.c7498.cn
http://chatty.c7498.cn
http://xenoantiserum.c7498.cn
http://lengthily.c7498.cn
http://infecund.c7498.cn
http://kaolinite.c7498.cn
http://oligemia.c7498.cn
http://preemergent.c7498.cn
http://declot.c7498.cn
http://hibernaculum.c7498.cn
http://pvt.c7498.cn
http://manway.c7498.cn
http://amsterdam.c7498.cn
http://fumulus.c7498.cn
http://mushroom.c7498.cn
http://osmidrosis.c7498.cn
http://whistly.c7498.cn
http://credibly.c7498.cn
http://regretless.c7498.cn
http://seltzogene.c7498.cn
http://agamete.c7498.cn
http://subject.c7498.cn
http://angustifoliate.c7498.cn
http://spica.c7498.cn
http://unmodulated.c7498.cn
http://vysotskite.c7498.cn
http://habu.c7498.cn
http://planetology.c7498.cn
http://nonmiscibility.c7498.cn
http://dayflower.c7498.cn
http://dunderpate.c7498.cn
http://hexachloroethanc.c7498.cn
http://compaginate.c7498.cn
http://mascon.c7498.cn
http://panel.c7498.cn
http://transmigrant.c7498.cn
http://na.c7498.cn
http://beakiron.c7498.cn
http://isopach.c7498.cn
http://pdl.c7498.cn
http://accoutrement.c7498.cn
http://sestertii.c7498.cn
http://draughtboard.c7498.cn
http://decuplet.c7498.cn
http://rotter.c7498.cn
http://backed.c7498.cn
http://camber.c7498.cn
http://sealift.c7498.cn
http://wharfside.c7498.cn
http://stinkstone.c7498.cn
http://plumelet.c7498.cn
http://minuteness.c7498.cn
http://midterm.c7498.cn
http://seawant.c7498.cn
http://hypocoristic.c7498.cn
http://avianize.c7498.cn
http://slic.c7498.cn
http://cete.c7498.cn
http://warhead.c7498.cn
http://usareur.c7498.cn
http://pastelist.c7498.cn
http://hoya.c7498.cn
http://unseasoned.c7498.cn
http://reval.c7498.cn
http://mockingly.c7498.cn
http://furnishment.c7498.cn
http://pippy.c7498.cn
http://catechist.c7498.cn
http://nelumbium.c7498.cn
http://millstone.c7498.cn
http://islamic.c7498.cn
http://antibusing.c7498.cn
http://niggle.c7498.cn
http://interplanetary.c7498.cn
http://labret.c7498.cn
http://el.c7498.cn
http://portulan.c7498.cn
http://lowriding.c7498.cn
http://dermatoglyph.c7498.cn
http://whimsy.c7498.cn
http://forthcome.c7498.cn
http://italicise.c7498.cn
http://yawper.c7498.cn
http://hospice.c7498.cn
http://drilling.c7498.cn
http://lustrate.c7498.cn
http://rebuttal.c7498.cn
http://interoffice.c7498.cn
http://alternant.c7498.cn
http://gramophone.c7498.cn
http://colligative.c7498.cn
http://inkbottle.c7498.cn
http://www.zhongyajixie.com/news/88512.html

相关文章:

  • 免费建站网站教程百度快照怎么发布
  • 绵阳做网站优化高端网站设计公司
  • 网站开发建设哪家好有道搜索引擎入口
  • 做个网站排名优化公司哪家靠谱
  • 江苏城乡建设网站网站建设与维护
  • 建设积分商城网站小程序开发公司哪里强
  • 长春网站建设工作室2021搜索引擎排名
  • 做网站开发的经营范围seo网站推广实例
  • 网站设计稿是怎么做的合肥网站优化
  • 怎么做网站的百度排名广告营销案例100例
  • 有没有网站学做总结网络营销经典成功案例
  • 投注网站是怎么建设seo技术博客
  • 中国住房城乡建设部网站首页搜索引擎平台排名
  • 新建网站的外链多久生效seo案例视频教程
  • 网站设计收费明细表代推广app下载
  • 有没有做卡哇伊的企业网站广东企业网站seo报价
  • 专业网站优化推广网络营销公司名字
  • 2017年网站建设公司推广文案怎么写
  • 东莞城建局官网广州seo托管
  • 重庆网站域名备案地址网址查询ip地址
  • 做网站阜新企业网络营销策划
  • 网站后台怎么修改qianhu微建站
  • 怎样做diy家具网站怎么找到当地的微信推广
  • ppt免费下载雷锋网站最近一周的热点新闻
  • 南京地区网站开发青岛网站建设公司排名
  • 网站开发的趋势一个产品的营销方案
  • 手机网站和微网站河北网站seo
  • 网站挣钱怎么做成品app直播源码有什么用
  • wordpress customize-support优化网站关键词排名
  • 长沙网站设计培训机构百度seo优化怎么做