编码的 3D 游戏
3D 培训
我写的 3D 游戏培训编程
glUseProgram(m_programSkyBox.Program);
glGenBuffers(1, &skyBoxVertexBuffer);
glBindBuffer(GL_ARRAY_BUFFER, skyBoxVertexBuffer);
float vertices[24] = {
-1.0, -1.0, 1.0,
1.0, -1.0, 1.0,
-1.0, 1.0, 1.0,
1.0, 1.0, 1.0,
-1.0, -1.0, -1.0,
1.0, -1.0, -1.0,
-1.0, 1.0, -1.0,
1.0, 1.0, -1.0,
};
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
glGenBuffers(1, &skyBoxIndexBuffer);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, skyBoxIndexBuffer);
GLubyte indices[14] = {0, 1, 2, 3, 7, 1, 5, 4, 7, 6, 2, 4, 0, 1};
绘图 skybox:
glClearColor(0.5f, 0.5f, 0.5f, 1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glUseProgram(m_programSkyBox.Program);
glDisable(GL_DEPTH_TEST); // skybox should be drawn behind anything else
glBindTexture(GL_TEXTURE_CUBE_MAP, m_textures.Cubemap);
glBin
- 2022-07-02 11:39:51下载
- 积分:1
Android 绘制吃豆子小人及图片自动变换显示功能
Android 绘制吃豆子小人,同时与之搭配的还有图片自动变换显示的功能。
Paint paint = new Paint();//创建画笔对象
canvas.drawColor(Color.BLACK);//绘制背景
canvas.drawBitmap(bmpMan, centerX-radius, centerY-radius, null);//绘制吃豆小人
paint.setColor(Color.BLACK); //设置画笔颜色
paint.setAntiAlias(true);
RectF oval = new RectF(centerX-radius-1,centerY-radius-2,centerX-radius-1+2*radius+2,centerY-radius-2+2*radius+4);
canvas.drawArc(oval, 360-angle+90*direction, 2*angle, true, paint); //绘制扇形实现张嘴闭嘴
if(System.currentTimeMillis()-timeStamp > 5000){//如果时间间隔超过5秒
timeStamp = System.currentTimeMillis(); //重新记录时间
currPhoto = (currPhoto+1)%bmpPhotos.length; //更换照片
}
canvas.drawBitmap(bmpPhotos[currPhoto], 80, 40, null);//绘制照片
super.onDraw(canvas);
- 2022-05-16 13:25:29下载
- 积分:1