为立方体的每一面分配颜色
Assign color to each side of a cube OpenFrameworks
我正在寻找一种方法来绘制一个立方体与独特的颜色每边。目前,我使用以下w = width, h = height和d = depth的顶点和索引数据:
GLfloat vdata[8][3] = {
{-w, -h, -d}, {-w, h, -d},
{w, h, -d}, {w, -h, -d},
{-w, -h, d}, {w, -h, d},
{-w, h, d}, {w, h, d}
};
GLint indices[6][4] = {
{3, 2, 1, 0},
{3, 5, 4, 0},
{3, 5, 7, 2},
{0, 4, 6, 1},
{1, 2, 7, 6},
{5, 4, 6, 7}
};
我有点确定,我可以每面画四个顶点来实现我所追求的,但我宁愿不采取绘制所有这些额外顶点的性能打击。贴图纹理会更有意义吗?
每个面使用4个顶点是正确的方法。为什么你认为会有一个相关的"性能打击"?纹理化很可能会导致更大的性能损失。
相关文章:
- 将数组的地址分配给变量并删除
- vector.resize()中的分配错误
- 如果C++类在类方法中具有动态分配,但没有构造函数/析构函数或任何非静态成员,那么它仍然是POD类型吗
- Win32编译器选项和内存分配
- 函数中堆分配的效果与缺少堆分配的情况
- 将"打开的CV图像"中的"颜色"转换为整数格式
- 使用动态分配的数组会导致代码分析发出虚假的C6386缓冲区溢出警告
- 多个文件的内存分配错误"在抛出 'std :: bad_alloc' what (): std :: bad_alloc 的实例后终止调用" [C++]
- 获取字符串的长度并将其分配给数组
- 将地址分配给本地指针后,公共对象的变量将消失
- 递归模板化函数不能分配给具有常量限定类型"const tt &"的变量"state"
- 如何在内核C++中使用1920x1080x16M图形或类似的16M颜色?(VGA)
- 如何在24位SDL_Surface上设置像素的颜色
- 有没有一种方法可以使用placement new将堆叠对象分配给分配的内存
- 我在二维向量中是否正确分配了内存
- 正在尝试重载二进制搜索树分配运算符
- GlobalAlloc而不是其他分配方法
- 自定义先决条件对移动分配运算符有效吗
- QPainter,为文本部分分配不同的颜色
- 为立方体的每一面分配颜色