Page 3 of 5 FirstFirst 12345 LastLast
Results 21 to 30 of 42

Thread: pascal and learning 3d

  1. #21
    This memory optimization gave me a slight headache today. Was trying to use dynamic array of singles as source for vbo data and result was trash. Later it turned out that there's no such problems with static array. Can I force dynamic array to be bit aligned(or whatever its the problem)? using 'packed array' didn't help and Id' rather have a buffer that can grow if needed.

  2. #22
    PGDCE Developer Carver413's Avatar
    Join Date
    Jun 2010
    Location
    Spokane,WA,Usa
    Posts
    206
    I have been using dynamic arrays with no problem, never had to use pack arrays, just arrays of pack records. what are you tring to pass ?

  3. #23
    turned out that I was dereferencing a pointer in a wrong way
    with static array it was just:
    glBufferData(GL_ARRAY_BUFFER,x,buffer,GL_STATIC_DR AW);
    and with dynamic should be:
    glBufferData(GL_ARRAY_BUFFER,x,@buffer^[0],GL_STATIC_DRAW);

    where 'buffer' is a pointer for that array type.

    ps: it liiveees!!
    Last edited by laggyluk; 01-12-2012 at 11:42 PM.

  4. #24
    PGDCE Developer Carver413's Avatar
    Join Date
    Jun 2010
    Location
    Spokane,WA,Usa
    Posts
    206
    there is no way the compiler would change the layout for dynamic vs static that would break the compatibilty of the two. my guess is that you are miscalculating the size some where and the data isn't making it to the final destination. Edit:guess Iwas too slow, so you got it, looks good.
    Last edited by Carver413; 02-12-2012 at 12:20 AM.

  5. #25
    Not sure if it's solved but I want to make a comment about record alignment. In the engine I wrote and used in the 2nd. PGD Challenge I didn't use records to store data that is used with OpenGL; I use vectors (ARRAY) instead. For example, to store xyz points I used something like:
    Code:
    CONST
      COOR_X = 0;
      COOR_Y = 1;
      COOR_Z = 2;
    TYPE
      Vector3D = ARRAY [0..2] OF glFloat;
    To access to each axis I use the CONST (i.e. Point[COOR_X], etc). This way I can use the "v" functions without alignment problems.
    No signature provided yet.

  6. #26
    yeah it works alright now

  7. #27
    I have a bunch of classes now, should I worry about writing destructors for them or memory will be freed autimatically when app terminates?

  8. #28
    PGDCE Developer Carver413's Avatar
    Join Date
    Jun 2010
    Location
    Spokane,WA,Usa
    Posts
    206
    when it comes to classes whatever you create you must destroy. you should get heap trace up and running if you don't already. check the output file often to check mem leaks as you go along. also make sure to free up any opengl stuff in your destructors.

  9. #29
    ok, thanks. list of leaks is so long that it doesn't fit on the screen

  10. #30
    PGDCE Developer Carver413's Avatar
    Join Date
    Jun 2010
    Location
    Spokane,WA,Usa
    Posts
    206
    I built my frame work using a custom linked list design. all things are connected so I worry little about mem leaks. I worked on it for over a year before I started checking for leaks and I wasn't really surprised that I had none. so much more is possible with such a design.

Page 3 of 5 FirstFirst 12345 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •