Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Multidimentional vector/Multidimentional runtime-allocated array of vertexes  (Read 956 times)

0 Members and 1 Guest are viewing this topic.

Vovosunt

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
I'm currently using a vertexArray for the tile map in my game.
However it is very bothersome and confusing to calculate the offsets in the array (it's basically a 4d array).
I've tried using nested vectors (vector<vector<vector<Vertex> > > verts) and dynamically allocated array (starting with Vector*** verts and so on) but when I pass either into the draw function like this
((Vertex*)&verts[0],*number of vertexes*, sf::Quads) my app crashes...

I'm pretty sure it's due to the fact that vectors/allocated arrays are not contiguous... can I do this in some other way?  :(
« Last Edit: November 11, 2012, 02:52:45 pm by Laurent »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
4D? What does it represent??

You have to use a one-dimensional array if you want the data to be contiguous, yes. If calculating the offsets is not trivial, then write it in a reusable function so that you just have to do it once. Or even better: wrap your 4D array in a class with operator overloading.
Laurent Gomila - SFML developer