• Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at \$59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.

Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!

#ActualFreOzgur

Posted 30 January 2013 - 07:45 AM

Actually, It's not an OpenGL question.

This is how I draw things in OpenGL:

glEnableClientState (GL_VERTEX_ARRAY);
glEnableClientState (GL_NORMAL_ARRAY);
glEnableClientState (GL_TEXTURE_COORD_ARRAY);
glVertexPointer(3, GL_FLOAT, sizeof(VertexBuffer), obj->m_vertices[0].vertex);
glTexCoordPointer(2, GL_FLOAT, sizeof(VertexBuffer), obj->m_vertices[0].texCoord);
glNormalPointer(GL_FLOAT, sizeof(VertexBuffer), obj->m_vertices[0].normal);
glDrawElements (GL_TRIANGLES, obj->indicesCount, GL_UNSIGNED_INT, obj->indices);					glDisableClientState (GL_VERTEX_ARRAY);
glDisableClientState (GL_NORMAL_ARRAY);
glDisableClientState (GL_TEXTURE_COORD_ARRAY);

As you see here, I don't use any memcpy..

And this is how I have to draw in DirectX: (Pseudo)

D3DVERTEX *ptr = NULL;
D3DUSAGE_WRITEONLY,
0,
D3DPOOL_MANAGED,
&vertex_buffer,
NULL);
vertex_buffer->Lock(0, 0, (void**)&ptr, 0);
vertex_buffer->Unlock();

As you see here, I have to use a "memcpy" each frame.. Why each frame, because I can't keep my LPDIRECT3DVERTEXBUFFER9 object..

I just want to hold my vertex data in my own vertex buffer class (VertexBuffer), and be able to use it in both OpenGL and DirectX, without copying the data each frame..

I don't know DirectX much.. I'm a newbie.

(BTW, sorry for my bad English)

#6FreOzgur

Posted 30 January 2013 - 07:44 AM

Actually, It's not an OpenGL question.

This is how I draw things in OpenGL:

glEnableClientState (GL_VERTEX_ARRAY);
glEnableClientState (GL_NORMAL_ARRAY);
glEnableClientState (GL_TEXTURE_COORD_ARRAY);
glVertexPointer(3, GL_FLOAT, sizeof(VertexBuffer), obj->m_vertices[0].vertex);
glTexCoordPointer(2, GL_FLOAT, sizeof(VertexBuffer), obj->m_vertices[0].texCoord);
glNormalPointer(GL_FLOAT, sizeof(VertexBuffer), obj->m_vertices[0].normal);
glDrawElements (GL_TRIANGLES, obj->indicesCount, GL_UNSIGNED_INT, obj->indices);					glDisableClientState (GL_VERTEX_ARRAY);
glDisableClientState (GL_NORMAL_ARRAY);
glDisableClientState (GL_TEXTURE_COORD_ARRAY);

As you see here, I don't use any memcpy..

And this is how I have to draw in DirectX: (Pseudo)

D3DVERTEX *ptr = NULL;app.getDevice()->CreateVertexBuffer(sizeof(quad),
D3DUSAGE_WRITEONLY,
0,
D3DPOOL_MANAGED,
&vertex_buffer,
NULL);
vertex_buffer->Lock(0, 0, (void**)&ptr, 0);
vertex_buffer->Unlock();

As you see here, I have to use a "memcpy" each frame.. Why each frame, because I can't keep my LPDIRECT3DVERTEXBUFFER9 object..

I just want to hold my vertex data in my own vertex buffer class (VertexBuffer), and be able to use it in both OpenGL and DirectX, without copying the data each frame..

I don't know DirectX much.. I'm a newbie.

(BTW, sorry for my bad English)

#5FreOzgur

Posted 30 January 2013 - 07:44 AM

Actually, It's not an OpenGL question.

This is how I draw things in OpenGL:

glEnableClientState (GL_VERTEX_ARRAY);
glEnableClientState (GL_NORMAL_ARRAY);
glEnableClientState (GL_TEXTURE_COORD_ARRAY);
glVertexPointer(3, GL_FLOAT, sizeof(VertexBuffer), obj->m_vertices[0].vertex);
glTexCoordPointer(2, GL_FLOAT, sizeof(VertexBuffer), obj->m_vertices[0].texCoord);
glNormalPointer(GL_FLOAT, sizeof(VertexBuffer), obj->m_vertices[0].normal);
glDrawElements (GL_TRIANGLES, obj->indicesCount, GL_UNSIGNED_INT, obj->indices);					glDisableClientState (GL_VERTEX_ARRAY);	glDisableClientState (GL_NORMAL_ARRAY);
glDisableClientState (GL_TEXTURE_COORD_ARRAY);

As you see here, I don't use any memcpy..

And this is how I have to draw in DirectX: (Pseudo)

D3DVERTEX *ptr = NULL;app.getDevice()->CreateVertexBuffer(sizeof(quad),
D3DUSAGE_WRITEONLY,
0,
D3DPOOL_MANAGED,
&vertex_buffer,
NULL);
vertex_buffer->Lock(0, 0, (void**)&ptr, 0);
vertex_buffer->Unlock();

As you see here, I have to use a "memcpy" each frame.. Why each frame, because I can't keep my LPDIRECT3DVERTEXBUFFER9 object..

I just want to hold my vertex data in my own vertex buffer class (VertexBuffer), and be able to use it in both OpenGL and DirectX, without copying the data each frame..

I don't know DirectX much.. I'm a newbie.

(BTW, sorry for my bad English)

#4FreOzgur

Posted 19 January 2013 - 08:48 PM

Actually, It's not an OpenGL question.

This is how I draw things in OpenGL:
glEnableClientState (GL_VERTEX_ARRAY);	glEnableClientState (GL_NORMAL_ARRAY);	glEnableClientState (GL_TEXTURE_COORD_ARRAY);		glVertexPointer(3, GL_FLOAT, sizeof(VertexBuffer), obj->m_vertices[0].vertex);	glTexCoordPointer(2, GL_FLOAT, sizeof(VertexBuffer), obj->m_vertices[0].texCoord);	glNormalPointer(GL_FLOAT, sizeof(VertexBuffer), obj->m_vertices[0].normal);			glDrawElements (GL_TRIANGLES, obj->indicesCount, GL_UNSIGNED_INT, obj->indices);					glDisableClientState (GL_VERTEX_ARRAY);	glDisableClientState (GL_NORMAL_ARRAY);	glDisableClientState (GL_TEXTURE_COORD_ARRAY);

As you see here, I don't use any memcpy..

And this is how I have to draw in DirectX: (Pseudo)
D3DVERTEX *ptr = NULL;app.getDevice()->CreateVertexBuffer(sizeof(quad),                                    D3DUSAGE_WRITEONLY,                                    0,                                    D3DPOOL_MANAGED,                                    &vertex_buffer,                                    NULL);vertex_buffer->Lock(0, 0, (void**)&ptr, 0);memcpy((void*)ptr, (void*)vetices_of_quad, sizeof(vetices_of_quad));vertex_buffer->Unlock();

As you see here, I have to use a "memcpy" each frame.. Why each frame, because I can't keep my LPDIRECT3DVERTEXBUFFER9 object..

I just want to hold my vertex data in my own vertex buffer class (VertexBuffer), and be able to use it in both OpenGL and DirectX, without copying the data each frame..

I don't know DirectX much.. I'm a newbie.

(BTW, sorry for my bad English)

#3FreOzgur

Posted 19 January 2013 - 08:48 PM

Actually, It's not an OpenGL question.

This is how I draw things in OpenGL:
glEnableClientState (GL_VERTEX_ARRAY);	glEnableClientState (GL_NORMAL_ARRAY);	glEnableClientState (GL_TEXTURE_COORD_ARRAY);		glVertexPointer(3, GL_FLOAT, sizeof(VertexBuffer), obj->m_vertices[0].vertex);	glTexCoordPointer(2, GL_FLOAT, sizeof(VertexBuffer), obj->m_vertices[0].texCoord);	glNormalPointer(GL_FLOAT, sizeof(VertexBuffer), obj->m_vertices[0].normal);			glDrawElements (GL_TRIANGLES, obj->indicesCount, GL_UNSIGNED_INT, obj->indices);					glDisableClientState (GL_VERTEX_ARRAY);	glDisableClientState (GL_NORMAL_ARRAY);	glDisableClientState (GL_TEXTURE_COORD_ARRAY);

As you see here, I don't use any memcpy..

And this is how I have to draw in DirectX: (Pseudo)
D3DVERTEX *ptr = NULL;app.getDevice()->CreateVertexBuffer(sizeof(quad),                                    D3DUSAGE_WRITEONLY,                                    0,                                    D3DPOOL_MANAGED,                                    &vertex_buffer,                                    NULL);vertex_buffer->Lock(0, 0, (void**)&ptr, 0);memcpy((void*)ptr, (void*)vetices_of_quad, sizeof(vetices_of_quad));vertex_buffer->Unlock();

As you see here, I have to use a "memcpy" each frame.. Why each frame, because I can't keep my LPDIRECT3DVERTEXBUFFER9 object..

I just want to hold my vertex data in my own vertex buffer class (VertexBuffer), and be able to use it in both OpenGL and DirectX, without copying the data each frame..

I don't know DirectX much.. I'm a newbie.

(BTW, sorry for my bad English)

#2FreOzgur

Posted 19 January 2013 - 08:48 PM

Actually, It's not an OpenGL question.

This is how I draw things in OpenGL:
glEnableClientState (GL_VERTEX_ARRAY);	glEnableClientState (GL_NORMAL_ARRAY);	glEnableClientState (GL_TEXTURE_COORD_ARRAY);		glVertexPointer(3, GL_FLOAT, sizeof(VertexBuffer), obj->m_vertices[0].vertex);	glTexCoordPointer(2, GL_FLOAT, sizeof(VertexBuffer), obj->m_vertices[0].texCoord);	glNormalPointer(GL_FLOAT, sizeof(VertexBuffer), obj->m_vertices[0].normal);			glDrawElements (GL_TRIANGLES, obj->indicesCount, GL_UNSIGNED_INT, obj->indices);					glDisableClientState (GL_VERTEX_ARRAY);	glDisableClientState (GL_NORMAL_ARRAY);	glDisableClientState (GL_TEXTURE_COORD_ARRAY);

As you see here, I don't use any memcpy..

And this is how I have to draw in DirectX: (Pseudo)
D3DVERTEX *ptr = NULL;app.getDevice()->CreateVertexBuffer(sizeof(quad),                                    D3DUSAGE_WRITEONLY,                                    0,                                    D3DPOOL_MANAGED,                                    &vertex_buffer,                                    NULL);vertex_buffer->Lock(0, 0, (void**)&ptr, 0);memcpy((void*)ptr, (void*)vetices_of_quad, sizeof(vetices_of_quad));vertex_buffer->Unlock();

As you see here, I have to use a "memcpy" each frame.. Why each frame, because I can't keep my LPDIRECT3DVERTEXBUFFER9 object..

I just want to hold my vertex data in my own vertex buffer class (VertexBuffer), and be able to use it in both OpenGL and DirectX, without copying the data each frame..

I don't know DirectX much.. I'm a newbie.