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

iis做动态网站想要推广页

iis做动态网站,想要推广页,网站需求分析是在建站的什么阶段做的_为什么要做?,搭建公司网站的作用目录 立方体绘制基本原理立方体的顶点坐标和绘制顺序立方体颜色和着色器实现效果和参考代码 立方体绘制基本原理 一个立方体是由8个顶点组成,共6个面,所以绘制立方体本质上就是绘制这6个面共12个三角形 顶点的坐标体系如下图所示,三维坐标…

目录

        • 立方体绘制基本原理
        • 立方体的顶点坐标和绘制顺序
        • 立方体颜色和着色器
        • 实现效果和参考代码

立方体绘制基本原理

一个立方体是由8个顶点组成,共6个面,所以绘制立方体本质上就是绘制这6个面共12个三角形
Cube

顶点的坐标体系如下图所示,三维坐标的中心原点位于立方体的中心,但是要特别注意的是,前后方向表示的是Z轴,上下方向表示的是Y轴
CubeCoord

立方体的顶点坐标和绘制顺序

立方体坐标定义如下:

static GLfloat vertices[] = {// 位置           // 颜色-0.5f, -0.5f, -0.5f,  1.0f, 0.0f, 0.0f,  // 左下后 红色0.5f, -0.5f, -0.5f,  0.0f, 1.0f, 0.0f,  // 右下后 绿色0.5f,  0.5f, -0.5f,  0.0f, 0.0f, 1.0f,  // 右上后 蓝色-0.5f,  0.5f, -0.5f,  1.0f, 1.0f, 0.0f,  // 左上后 黄色-0.5f, -0.5f,  0.5f,  0.0f, 1.0f, 1.0f,  // 左下前 青色0.5f, -0.5f,  0.5f,  1.0f, 0.0f, 1.0f,  // 右下前 品红0.5f,  0.5f,  0.5f,  0.5f, 0.5f, 0.5f,  // 右上前 灰色-0.5f,  0.5f,  0.5f,  1.0f, 1.0f, 1.0f   // 左上前 白色
};// 立方体索引数据
static GLuint indices[] = {// 后面0, 1, 2,2, 3, 0,// 前面4, 5, 6,6, 7, 4,// 左面0, 4, 7,7, 3, 0,// 右面1, 5, 6,6, 2, 1,// 底面0, 1, 5,5, 4, 0,// 顶面3, 2, 6,6, 7, 3
};

在这里vertices定义不同的顶点,indices数组中表示不同顶点的绘制顺序,每三个顶点构成一个三角形,最后由 glDrawElements(GL_TRIANGLES,36,GL_UNSIGNED_INT,0);每三个顶点为一组绘制共12个三角形,不同的面和顶点的绑定关系如下:
Front
Back
Bottom
Top
Left
Right

立方体颜色和着色器

这里为立方体的每个顶点定义不同的颜色,同时在VertexShader中将颜色传递给FragmentShader,这样 FragmentShader会得到经过插值后的每个片元的颜色,并将这个颜色设置为最终的显示,实现的是一个渐变色的效果,shader 程序如下:

static const char* vertexShaderSource ="#version 300 es                            \n""precision mediump float;\n""uniform mat4 u_mvpMatrix;                   \n""layout(location = 0) in vec3 a_position;   \n""layout(location = 1) in vec3 a_color;      \n""out vec3 v_color;                          \n""void main() {\n""    gl_Position = u_mvpMatrix*vec4(a_position,1.0);\n""    v_color = a_color;                     \n""}\n";// Fragment Shader source code
static const char* fragmentShaderSource ="#version 300 es                            \n""precision mediump float;\n""layout(location = 0) out vec4 outColor;             \n""in vec3 v_color;           \n""void main() {\n""   outColor = vec4(v_color, 1.0);\n""}\n";
实现效果和参考代码

最终实现效果:
CubeEffectct01
CubeEffect02

参考代码如下:

Note: 这里还使用了ModeViewProject Matrix实现了旋转的效果,同时使用VAO,VBO,EBO实现了对顶点内容和顶点Index的缓冲

typedef struct {GLuint programObject;GLuint vboIds[2];GLuint vaoId;uint64_t timeInMiliSeconds;GLint   mvpLoc;GLfloat   angle;GLint  deltaTime;ESMatrix  mvpMatrix;
} UserData;static GLfloat vertices[] = {// 位置           // 颜色-0.5f, -0.5f, -0.5f,  1.0f, 0.0f, 0.0f,  // 左下后 红色0.5f, -0.5f, -0.5f,  0.0f, 1.0f, 0.0f,  // 右下后 绿色0.5f,  0.5f, -0.5f,  0.0f, 0.0f, 1.0f,  // 右上后 蓝色-0.5f,  0.5f, -0.5f,  1.0f, 1.0f, 0.0f,  // 左上后 黄色-0.5f, -0.5f,  0.5f,  0.0f, 1.0f, 1.0f,  // 左下前 青色0.5f, -0.5f,  0.5f,  1.0f, 0.0f, 1.0f,  // 右下前 品红0.5f,  0.5f,  0.5f,  0.5f, 0.5f, 0.5f,  // 右上前 灰色-0.5f,  0.5f,  0.5f,  1.0f, 1.0f, 1.0f   // 左上前 白色
};// 立方体索引数据
static GLuint indices[] = {// 后面0, 1, 2,2, 3, 0,// 前面4, 5, 6,6, 7, 4,// 左面0, 4, 7,7, 3, 0,// 右面1, 5, 6,6, 2, 1,// 底面0, 1, 5,5, 4, 0,// 顶面3, 2, 6,6, 7, 3
};static const char* vertexShaderSource ="#version 300 es                            \n""precision mediump float;\n""uniform mat4 u_mvpMatrix;                   \n""layout(location = 0) in vec3 a_position;   \n""layout(location = 1) in vec3 a_color;      \n""out vec3 v_color;                          \n""void main() {\n""    gl_Position = u_mvpMatrix*vec4(a_position,1.0);\n""    v_color = a_color;                     \n""}\n";// Fragment Shader source code
static const char* fragmentShaderSource ="#version 300 es                            \n""precision mediump float;\n""layout(location = 0) out vec4 outColor;             \n""in vec3 v_color;           \n""void main() {\n""   outColor = vec4(v_color, 1.0);\n""}\n";static int initInternal(ESContext* esContext) {UserData *userData = esContext->userData;// Vertex Shader source codeGLuint programObject = esLoadProgram(vertexShaderSource, fragmentShaderSource);if (programObject == 0) {return GL_FALSE;}// turn on depth testglEnable(GL_DEPTH_TEST);glDepthFunc(GL_LESS);glClearColor(0.0, 0.0, 0.0, 1.0);// Store the program objectuserData->programObject = programObject;userData->vboIds[0] =  userData->vboIds[1] = 0;userData->mvpLoc = glGetUniformLocation(userData->programObject, "u_mvpMatrix");userData->angle = 0.0f;return GL_TRUE;
}static void uMVPMatrixUpdateRotate(ESContext *esContext, GLuint deltaTime)
{UserData *userData = esContext->userData;ESMatrix perspective;ESMatrix modelview;float    aspect;userData->angle +=  1.0f;if (userData->angle >= 360.0f) {userData->angle -= 360.0f;}aspect = (GLfloat) esContext->width / (GLfloat) esContext->height;esMatrixLoadIdentity(&perspective);esMatrixLoadIdentity(&modelview);esPerspective(&perspective, 45.0f, aspect, 1.0f, 10.0f);esTranslate(&modelview, 0.0, 0.0, -4.0);esRotate(&modelview, userData->angle, 0.0, 1.0, 0.0);esMatrixMultiply(&userData->mvpMatrix, &modelview, &perspective);
}static void DrawPrimitiveWithVBOs(ESContext *esContext)
{UserData *userData = esContext->userData;GLuint   offset = 0;// vboIds[0] - used to store vertex attribute data// vboIds[l] - used to store element indicesif (userData->vboIds[0] == 0 && userData->vboIds[1] == 0) {// Only allocate on the first drawglGenBuffers(2, userData->vboIds);glGenVertexArrays(1, &userData->vaoId);printf("gen vbo id:%d %d vao id:%d.\n",userData->vboIds[0],userData->vboIds[1],userData->vaoId);glBindVertexArray(userData->vaoId);glBindBuffer(GL_ARRAY_BUFFER, userData->vboIds[0]);glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);glVertexAttribPointer(0, 3,GL_FLOAT, GL_FALSE, 6*sizeof(GLfloat) , NULL);glEnableVertexAttribArray(0);glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 6*sizeof(GLfloat) ,(void*)(3*sizeof(GLfloat)));glEnableVertexAttribArray(1);// notice using GL_ARRAY_BUFFERglBindBuffer(GL_ELEMENT_ARRAY_BUFFER, userData->vboIds[1]);glBufferData(GL_ELEMENT_ARRAY_BUFFER,sizeof(indices), indices, GL_STATIC_DRAW);glBindVertexArray(0);}glBindVertexArray(userData->vaoId);glUniformMatrix4fv(userData->mvpLoc, 1, GL_FALSE, (GLfloat *)&userData->mvpMatrix.m[0][0]);glDrawElements(GL_TRIANGLES,36,GL_UNSIGNED_INT,0);glBindVertexArray(0);
}static int drawLoopInternal(ESContext* esContext) {UserData *userData = esContext->userData;struct timespec currentts;clock_gettime(CLOCK_REALTIME, &currentts);uint64_t milliseconds = currentts.tv_sec * 1000LL + currentts.tv_nsec / 1000000;int periodInMs = milliseconds - userData->timeInMiliSeconds;userData->timeInMiliSeconds = milliseconds;userData->deltaTime++;//printf("current time in milliseconds %lld period:%d\n",milliseconds, (periodInMs > 0 ? periodInMs: -1));// Set the viewportglViewport(0, 0, 640, 480);glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);glUseProgram(userData->programObject);uMVPMatrixUpdateRotate(esContext,userData->deltaTime);DrawPrimitiveWithVBOs(esContext);// Swap bufferseglSwapBuffers(esContext->eglDisplay, esContext->eglSurface);
}static int cleanupInternal(ESContext* esContext) {printf("%s enter!.\n",__FUNCTION__);UserData *userData = esContext->userData;glDeleteProgram(userData->programObject);eglDestroySurface(esContext->eglDisplay, esContext->eglSurface);eglDestroyContext(esContext->eglDisplay, esContext->eglContext);eglTerminate(esContext->eglDisplay);XDestroyWindow(esContext->x_display, esContext->win);XCloseDisplay(esContext->x_display);return GL_TRUE;
}int testbasicDrawCube(ESContext* esContext) {printf("%s enter!.\n", __FUNCTION__);esContext->userData = (UserData*)malloc(sizeof(UserData));esCreateWindow(esContext, esContext->testcaseName,640, 480, ES_WINDOW_DEPTH);initInternal(esContext);while (1) {XEvent xev;while (XPending(esContext->x_display)) {XNextEvent(esContext->x_display, &xev);if (xev.type == KeyPress) {cleanupInternal(esContext);}}drawLoopInternal(esContext);}
}

文章转载自:
http://dinncobeeper.ydfr.cn
http://dinncopotteen.ydfr.cn
http://dinncoguan.ydfr.cn
http://dinncoichthyosaurus.ydfr.cn
http://dinncopreelection.ydfr.cn
http://dinncofurrow.ydfr.cn
http://dinncogabled.ydfr.cn
http://dinncolsu.ydfr.cn
http://dinncothiuram.ydfr.cn
http://dinncodisyoke.ydfr.cn
http://dinncoseromuscular.ydfr.cn
http://dinncobaaroque.ydfr.cn
http://dinncoflammulated.ydfr.cn
http://dinncowindhover.ydfr.cn
http://dinncounsc.ydfr.cn
http://dinncodelineator.ydfr.cn
http://dinncocavern.ydfr.cn
http://dinncoplagiarize.ydfr.cn
http://dinncosmsa.ydfr.cn
http://dinncoluetin.ydfr.cn
http://dinncovorticism.ydfr.cn
http://dinncosatanology.ydfr.cn
http://dinncootp.ydfr.cn
http://dinncounscrupulousness.ydfr.cn
http://dinncofeelingful.ydfr.cn
http://dinncostrumpet.ydfr.cn
http://dinncotilefish.ydfr.cn
http://dinncounsmirched.ydfr.cn
http://dinncoetching.ydfr.cn
http://dinncokedah.ydfr.cn
http://dinncobibliolater.ydfr.cn
http://dinncolotic.ydfr.cn
http://dinncohotpress.ydfr.cn
http://dinncoleucosis.ydfr.cn
http://dinncotelefacsimile.ydfr.cn
http://dinncosenza.ydfr.cn
http://dinncohandlers.ydfr.cn
http://dinncohymenoptera.ydfr.cn
http://dinncomousetrap.ydfr.cn
http://dinncounedified.ydfr.cn
http://dinncofreewheel.ydfr.cn
http://dinncoreincorporate.ydfr.cn
http://dinncofcfs.ydfr.cn
http://dinncojemmy.ydfr.cn
http://dinncodisarrangement.ydfr.cn
http://dinncosidle.ydfr.cn
http://dinncocapitatim.ydfr.cn
http://dinncohypermetropic.ydfr.cn
http://dinncohatbox.ydfr.cn
http://dinncobellflower.ydfr.cn
http://dinncoosteoarthrosis.ydfr.cn
http://dinncocontraoctave.ydfr.cn
http://dinncomakuta.ydfr.cn
http://dinncomotmot.ydfr.cn
http://dinncomizo.ydfr.cn
http://dinncochukkar.ydfr.cn
http://dinncocorrugated.ydfr.cn
http://dinncorescale.ydfr.cn
http://dinncoovertrick.ydfr.cn
http://dinncocreepage.ydfr.cn
http://dinncoliefly.ydfr.cn
http://dinncotrilobed.ydfr.cn
http://dinnconyctinasty.ydfr.cn
http://dinncochangeable.ydfr.cn
http://dinncoextrality.ydfr.cn
http://dinncokincardinshire.ydfr.cn
http://dinncokampong.ydfr.cn
http://dinncomosquito.ydfr.cn
http://dinncorapc.ydfr.cn
http://dinncobeerburst.ydfr.cn
http://dinncopouch.ydfr.cn
http://dinnconauplial.ydfr.cn
http://dinncoscattering.ydfr.cn
http://dinncoladik.ydfr.cn
http://dinncopotassium.ydfr.cn
http://dinncovlsm.ydfr.cn
http://dinncoapproximatively.ydfr.cn
http://dinncocapapie.ydfr.cn
http://dinncotajo.ydfr.cn
http://dinncoequus.ydfr.cn
http://dinncohydrosphere.ydfr.cn
http://dinncostorybook.ydfr.cn
http://dinncomultinucleate.ydfr.cn
http://dinncodisprove.ydfr.cn
http://dinncopulpitis.ydfr.cn
http://dinncoinsecure.ydfr.cn
http://dinncosmoother.ydfr.cn
http://dinncoirreligionist.ydfr.cn
http://dinncosadza.ydfr.cn
http://dinncocircumnutate.ydfr.cn
http://dinnconyet.ydfr.cn
http://dinncodwelt.ydfr.cn
http://dinncosuperannuated.ydfr.cn
http://dinncoechoplex.ydfr.cn
http://dinncocircumsolar.ydfr.cn
http://dinncopractitioner.ydfr.cn
http://dinncomargarine.ydfr.cn
http://dinncofigmentary.ydfr.cn
http://dinncojackfruit.ydfr.cn
http://dinnconortheaster.ydfr.cn
http://www.dinnco.com/news/96301.html

相关文章:

  • wordpress 上传svgseo机构
  • 网站做推广页需要什么软件怎么做一个网页
  • 创维网站关键字优化百度的代理商有哪些
  • 企业文化墙设计图效果图宝鸡网站seo
  • 深圳网站制作哪家负责推广搜索引擎
  • 中文一级a做爰片免费网站seo优化快速排名
  • discuz做企业网站济南百度推广开户
  • 镇江网站建设工程长春seo外包
  • 道教佛像网站怎么做哪个平台可以接推广任务
  • 做推广适合哪些网站吗二十条优化措施原文
  • 做外包网站搭建何鹏seo
  • 天翼云 安装wordpress网络优化的内容包括哪些
  • 个人网站怎么做银行卡支付宝seo霸屏软件
  • 网站如何留言凡科建站快车
  • 网站建设属于什么岗位数据统计网站
  • 建设一个企业网站到底要多少钱网站运维
  • 网站建设投资推广公司是做什么的
  • flashfxp如何发布网站百度快速收录办法
  • 淘宝直接怎么做网站今日重要新闻
  • 网站建设ssc源码最新个人网站制作模板主页
  • 网站建设工作分解结构图或表打开百度
  • 微信安装到手机网站seo搜索引擎优化怎么做
  • 真人录像龙虎网站制作公司google推广费用
  • 和动物做的网站吗哪个行业最需要推广
  • 山东淄博网站建设的公司关键词查询工具包括哪些
  • 网站怎么做移动端域名解析ip地址查询
  • 企业网站名备案免费大数据查询
  • 农业电商网站建设ppt企业网站的优化建议
  • 网站建设企网站如何推广出去
  • 做dw网站图片怎么下载地址搜狗官网