在三维空间中移动物体,我的最直接的想法就是改变物体的坐标,这也是我弄懂一些三维空间中坐标关系后的唯一抓手,这也是之前经常导入模型确显示不了的根本问题,毕竟三维模型不由我控制,不过得实话实说,我真心控制不了,对 3dmax 真是一知半解,有机会一定要加强一下。
感觉频繁的创建、删除顶点缓存,是否太过浪费资源,耗费保贵的时间呢?所以,在官方网站一顿狂查乱猜,终于找到这么个有点靠谱的家伙来帮帮忙,大家研究后,发现它只能更新其中一部分顶点的坐标,而不能把整体进行偏移,这个可能真的不适合用于移动物体时,对整体坐标的一致偏移量增减了。
换个角度......
写博客就这点好,边写着,边像是有人在看一样,思路总会源源不断地涌现出来!
N久后,
是否可以移动坐标原点呢?
但坐标原点移动了,其它物体也有了偏 移量的增减,这也是行不通的。
简单地说,我能和GPU交互的,只是给这一堆数据,这堆数据看似杂乱,但都是从实际的三维坐标系中取出来的物体的顶点的实际坐标,且我要求3D美工把物体中心放在坐标原点,一是,初始不需要任何偏移;二是,导进来,我就钉死这个物体在屏幕中心,必何我能看到它,这也是N久以来“血”的教训的结果;
有些东西确实不需要强制这样或那样,但没有约定,就会出现多种可能,我没那么多时间去解决这些可能性,因为我的目标不在那里,所以我需要排除这些干挠因素,直奔主题,那么有些实践得来的方法,虽然在明眼人看来有些愚蠢,但对我来说,是解决问题的良药,至少是目前来说。
好啦,还是没有好办法,那我还是用同样,在明眼人看来是愚蠢的方法来做我需要完成的事情,也许以后会发现新大陆,但至少目前来说,我只能在这块在我看来肥沃的土地上种我的菜,打我的粮,就这么简单。
复杂的事情,简单处理,虽然稍显愚蠢,但目前的条件下能达到目的,就是明智之举!您说不是吗?!
如您确实看不过眼儿了,真心欢迎指教,谢谢了先。
Name
glBufferSubData — 更新缓存对象数据存储的一部分 update a subset of a buffer object's data store
C Specification
void glBufferSubData( |
GLenum target, |
GLintptr offset, | |
GLsizeiptr size, | |
const GLvoid * data) ; |
Parameters
target
-
Specifies the target buffer object. The symbolic constant must beGL_ARRAY_BUFFER
orGL_ELEMENT_ARRAY_BUFFER
. offset
-
Specifies the offset into the buffer object's data store where data replacement will begin, measured in bytes. size
-
Specifies the size in bytes of the data store region being replaced. data
-
Specifies a pointer to the new data that will be copied into the data store.
Description
glBufferSubData
redefines some or all of the data store for the buffer object currently bound to target
. Data starting at byte offset offset
and
extending for size
bytes is copied to the data store from the memory pointed to by data
. An error is thrown if offset
and size
together
define a range beyond the bounds of the buffer object's data store.
Notes
When replacing the entire data store, consider using glBufferSubData
rather than completely recreating the data store with glBufferData
. This avoids the cost of reallocating the data store.
Consider using multiple buffer objects to avoid stalling the rendering pipeline during data store updates. If any rendering in the pipeline makes reference to data in the buffer object being updated by glBufferSubData
, especially
from the specific region being updated, that rendering must drain from the pipeline before the data store can be updated.
Clients must align data elements consistent with the requirements of the client platform, with an additional base-level requirement that an offset within a buffer to a datum comprising N be a multiple of N.
Errors
GL_INVALID_ENUM
is generated if target
is not GL_ARRAY_BUFFER
or GL_ELEMENT_ARRAY_BUFFER
.
GL_INVALID_VALUE
is generated if offset
or size
is negative, or if together they define
a region of memory that extends beyond the buffer object's allocated data store.
GL_INVALID_OPERATION
is generated if the reserved buffer object name 0 is bound to target
.
See Also
Copyright
Copyright 2005 Addison-Wesley. This material may be distributed subject to the terms and conditions set forth in the Open Publication License, v 1.0, 8 June 1999. http://opencontent.org/openpub/.