| View previous topic :: View next topic |
| Author |
Message |
Ghoti
Joined: 31 Dec 2005 Posts: 288
|
Posted: Sat Sep 16, 2006 7:28 am Post subject: How to correctly align vertices? |
|
|
Hi folks,
I'm trying to draw an object correctly, i don't really get it correct and i guess it is because i have not aligned the vertices because i really dont know exactly how to do it. How someone can explain them a little bit.
All the vertices are stored this way:
| Code: | typedef struct { float u, v;
unsigned int color;
float x, y, z; } ObjVertexB; // vertex to render
typedef struct { unsigned int iNumberOfVertices;
ObjVertexB *Vertices; } ObjStrip;
typedef struct _MeshB { unsigned int iNumberOfStrips;
ObjStrip *Strips; } MeshB; | so my mesh has strips and those strips have the vertices however this way the vertices are not aligned.
i create them using this code:
| Code: | tmpObj->iNumberOfStrips = tmpStrips;
tmpObj->Strips = (ObjStrip*)malloc(tmpStrips * sizeof(ObjStrip));
tmpObj->Strips[iStripNr].iNumberOfVertices = tmpStripsSize[iStripNr];
tmpObj->Strips[iStripNr].Vertices = (ObjVertexB*)malloc(tmpStripsSize[iStripNr] * sizeof(ObjVertexB)); |
i then draw it like this: | Code: | tmpObj->Strips[iStripNr].iNumberOfVertices = tmpStripsSize[iStripNr];
tmpObj->Strips[iStripNr].Vertices = (ObjVertexB*)malloc(tmpStripsSize[iStripNr] * sizeof(ObjVertexB));
|
Hope someone can help me implement the alignment
greets ghoti _________________ My PSP games:
Boxy II: http://www.ghoti.nl/boxyii.php
Elementals: http://www.ghoti.nl/Elementals.php |
|
| Back to top |
|
 |
zoret
Joined: 19 Mar 2006 Posts: 22
|
Posted: Tue Sep 19, 2006 5:25 am Post subject: |
|
|
to allocate aligned on 16b you can use the memalign function
so :
ObjVertexB * pVertices = memalign(16, nbVertices * sizeof(ObjVertexB));
maybe you can help to use psplink ! ;) |
|
| Back to top |
|
 |
Raphael

Joined: 17 Jan 2006 Posts: 646 Location: Germany
|
Posted: Tue Sep 19, 2006 5:50 am Post subject: |
|
|
malloc on psp is aligned to 16byte by default.
There's nothing generally wrong with the code, if the drawing messes up, its more likely to other problems than the alignment, because wrong alignment would just crash the program. _________________ <Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki
Alexander Berl |
|
| Back to top |
|
 |
Ghoti
Joined: 31 Dec 2005 Posts: 288
|
Posted: Tue Sep 19, 2006 5:54 pm Post subject: |
|
|
Hi thanks for the reply, however i have a question left:
i have used psplink it is very usefull for everything but there is one thing that is very annoying about psplink. for some reason psplink accepts some code while the psp on its own does not.
example:
with controls, if i use the analog pad this way:
| Code: | float movement;
movement = (float)(pad.Lx) - 128.0f; | if i run this through psplink i can move around, however when i run this the normal way as a pbp i can't move around.
other annoying things that happens are code that crashes the normal way but in psplink it is accepted. Last time i was quite far with some code and then i ran it the normal way and it crashed on several occasions.
why is this? is this because i am probebly not using the newest psptoolchain anymore?
greets ghoti _________________ My PSP games:
Boxy II: http://www.ghoti.nl/boxyii.php
Elementals: http://www.ghoti.nl/Elementals.php |
|
| Back to top |
|
 |
Tinnus
Joined: 29 Jul 2006 Posts: 67
|
Posted: Wed Sep 20, 2006 2:48 am Post subject: |
|
|
You need that to make the analog work:
| Code: | sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG); |
PSPLink probably does that itself, that's why your program can use it. IRShell does the same thing :) _________________ Let's see what the PSP reserves... well, I'd say anything is better than Palm OS. |
|
| Back to top |
|
 |
Ghoti
Joined: 31 Dec 2005 Posts: 288
|
|
| Back to top |
|
 |
|