?
So, hatte gestern Zeit das zu testen.
Lag wirklich am NULL. Läuft jetzt wunderbar :). Danke derweil.
Jetzt hab ich noch eine kleine Frage, für die ich mich fast schäme.. aber ich hab mich nie so richtig damit beschäftigt, wie der Compiler bzw Computer Klassen im Speicher anlegt.
Derzeit haue ich ähnlich wie bei Nehe TextureCoords und Vertices in 2 versch. Vertexbuffer. Ich würde das aber gerne in einem Buffer haben. jetzt ist mir nur unklar, wie groß die ELemente sind, die zwischen den einzelnen Objekten liegen. Heisst, ich bekomme nix angezeigt.
Vllt bin ich auch einfach mal wieder blind...
/** \brief This struct defines a Vertex.
* \ingroup Rendering
*/
struct dtVertex
{
/// \brief Constructor
dtVertex() : x(0), y(0), z(0) {}
/** \brief Settings Constructor
* \param _x The X-Coord
* \param _y The Y-Coord
* \param _z The Z-Coord
*/
dtVertex(f32 _x, f32 _y, f32 _z) : x(_x), y(_y), z(_z) {}
/** \brief Copy Constructor
* \param c A reference to an existing dtVertex-Instance which is copied.
*/
dtVertex(const dtVertex& c) : x(c.x), y(c.y), z(c.z) {}
/// \brief X-Position
f32 x;
/// \brief Y-Position
f32 y;
/// \brief Z-Position
f32 z;
/// \brief Conversion to GLfloat*
operator const GLfloat*() { return (const GLfloat*)this; }
};
/** \brief This struct defines a Texturecoord.
* \ingroup Rendering
*/
struct dtTextureCoord
{
/// \brief Constructor
dtTextureCoord() : s(0), t(0) {};
/** \brief Setting Constructor
* \param _s The S-Coordinate of the Texture
* \param _t The T-Coordinate of the Texture
*/
dtTextureCoord(f32 _s, f32 _t) : s(_s), t(_t) {}
/** \brief Copy Constructor
* \param c A reference to an existing dtTextureCoord-Instance which is copied.
*/
dtTextureCoord(const dtTextureCoord& c) : s(c.s), t(c.t) {}
/// \brief S-Coordinate
f32 s;
/// \brief T-Coordinate
f32 t;
/// \brief Conversion to GLfloat*
operator GLfloat*() { return (GLfloat*)this; }
};
/** \brief This struct defines a Color.
* \ingroup Rendering
*/
struct dtColor
{
/// \brief Constructor
dtColor() : r(1.0f), g(1.0f), b(1.0f), a(1.0f) {};
/** \brief Setting Constructor
* \param _r The Value of the Red Component
* \param _g The Value of the Green Component
* \param _b The Value of the Blue Component
* \param _a The Alpha Value
*/
dtColor(f32 _r, f32 _g, f32 _b, f32 _a = 1.0f) : r(_r), g(_g), b(_b), a(_a) {}
/** \brief Copy Constructor.
* \param c A reference to an existing dtColor-Instance which is copied.
*/
dtColor(const dtColor& c) : r(c.r), g(c.g), b(c.b), a(c.a) {}
/// \brief Red
f32 r;
/// \brief Green
f32 g;
/// \brief Blue
f32 b;
/// \brief Alpha
f32 a;
/// \brief Conversion to GLfloat*
operator GLfloat*() { return (GLfloat*)this; }
};
/** \brief This struct defines a Vertexbuffer.
* \ingroup Rendering
*
*
* A Vertexbuffer holds a count of Vertices, MaterialColor and Texturecoords.
*/
struct dtVertexBuffer
{
/// \brief Constructor
dtVertexBuffer()
: count(0), point(NULL), texturecoord(NULL), color(NULL), mode(dtDM_TRIANGLE),
vboVertId(0), vboColorId(0), vboTextureId(0)
{}
/// \brief Deconstructor, deletes all subarrays.
~dtVertexBuffer() { dtDelete(point); dtDelete(texturecoord); dtDelete(color); }
/// \brief A pointer to arrays of Vertices.
dtVertex *point;
/// \brief A pointer to arrays of Texture Coords.
dtTextureCoord *texturecoord;
/// \brief A pointer to arrays of Colors.
dtColor *color;
/// \brief The count of arrays in each member.
u32 count;
/// \brief The mode how to draw this. Defaults to dtDM_TRIANGLE.
dtDrawMode mode;
u32 vboVertId;
u32 vboColorId;
u32 vboTextureId;
};
Also, ein Zeiger auf einen Vertexbuffer enthält u.a. 3 Zeiger die je 4 Bytes groß sind (Windows, MSVC). Die Zeiger zeigen jeweils auf ein Objekt, das sizeof(Objekt)*count groß ist. Mal als Beispiel wie ich mir das gedacht hab:
dtVertexBuffer* buffer = new dtVertexBuffer;
buffer->point = new dtVertex[4];
buffer->texturecoords = new dtTextureCoords[4];
buffer->color = new dtColor[4];
Man würde wie gesagt buffer dann mitsamt den Zeigern in den AGP-Memory werfen...
Oder funzt das nicht so wie ich mir das vorstelle?
rya.