View previous topic :: View next topic |
Author |
Message |
Jeroen Site Admin
Joined: 07 Aug 2004 Posts: 5332 Location: The Netherlands
|
Posted: Sun Nov 06, 2005 10:03 pm Post subject: |
|
|
Vampyre_Dark wrote: |
Mr.Fletcher wrote: |
The glBegin(GL_POLYGONS); Command should come in your Polygons-Loop |
That's only going to make it even slower than it already is. |
He's not interested in fast code, he just wants to render it properly. |
|
Back to top |
|
|
Mr.Fletcher DeleD PRO user
Joined: 07 Aug 2004 Posts: 1772 Location: Germany
|
Posted: Mon Nov 07, 2005 2:13 pm Post subject: |
|
|
Vampyre_Dark wrote: |
Mr.Fletcher wrote: |
The glBegin(GL_POLYGONS); Command should come in your Polygons-Loop |
That's only going to make it even slower than it already is. |
I think i see what you mean, but it's necessary here, because the GL has to know, where to begin and where to end the polygons. You cannot start the GL_POLYGONS - rendering with every object unless it exists of only one polygon. But yes, triangulating it would be a lot faster. And it's not that difficult, either. _________________ Behold! The DeleD Wiki! Please help us expanding it
DeleD on IRC |
|
Back to top |
|
|
Daaark DeleD PRO user
Joined: 01 Sep 2004 Posts: 2696 Location: Ottawa, Canada
|
Posted: Mon Nov 07, 2005 5:49 pm Post subject: |
|
|
Mr.Fletcher wrote: |
Vampyre_Dark wrote: |
Mr.Fletcher wrote: |
The glBegin(GL_POLYGONS); Command should come in your Polygons-Loop |
That's only going to make it even slower than it already is. |
I think i see what you mean, but it's necessary here, because the GL has to know, where to begin and where to end the polygons. You cannot start the GL_POLYGONS - rendering with every object unless it exists of only one polygon. But yes, triangulating it would be a lot faster. And it's not that difficult, either. |
You are correct. That was a mistake on my part. Because GL_POLYGONS is difference and can have n sides. I forgot about that when I was posting.
Ghost -- why are you rendering your DMF map out? Is it intended just for fun, or are you trying to make a real time application like a game? GL_POLYGON will get the job done, but it's going to be really slow. |
|
Back to top |
|
|
GhostManZero Member
Joined: 05 Nov 2005 Posts: 10
|
Posted: Tue Nov 08, 2005 10:50 am Post subject: |
|
|
Yes, i am trying to make a real-time app, it will be my 1st attempt at making a 3D world, since DeleD seems to be very good at it. After this, i'll try to do some collision detection, and later, a game. |
|
Back to top |
|
|
GhostManZero Member
Joined: 05 Nov 2005 Posts: 10
|
Posted: Sun Nov 13, 2005 4:36 pm Post subject: |
|
|
I finally was able to draw a DeleD map's geometry well! Thanks to the creator of the delphi loader & renderer example! (i heard it was Mr. Fetcher, so i thank you, Mr. Fetcher!)
Note: i still wasnt able to place textures on it, working on it now.
For a screenshot-> http://www.ghostdev.gamedev-pt.net/Downloads/dmfload7.jpg |
|
Back to top |
|
|
Mr.Fletcher DeleD PRO user
Joined: 07 Aug 2004 Posts: 1772 Location: Germany
|
Posted: Sun Nov 13, 2005 4:57 pm Post subject: |
|
|
Can you post your rendering code? Maybe we could help you then.
Quote: |
i heard it was Mr. Fetcher, so i thank you, Mr. Fetcher! |
I'm glad i could help someone _________________ Behold! The DeleD Wiki! Please help us expanding it
DeleD on IRC |
|
Back to top |
|
|
GhostManZero Member
Joined: 05 Nov 2005 Posts: 10
|
|
Back to top |
|
|
GhostManZero Member
Joined: 05 Nov 2005 Posts: 10
|
Posted: Mon Nov 14, 2005 1:25 pm Post subject: |
|
|
Forgot to mention that the DMF drawing code itself is located @ DMFRender.h in the Tester folder. |
|
Back to top |
|
|
Mr.Fletcher DeleD PRO user
Joined: 07 Aug 2004 Posts: 1772 Location: Germany
|
Posted: Mon Nov 14, 2005 1:56 pm Post subject: |
|
|
Hi,
in dmfrender.h:
Code: |
glBegin(GL_TRIANGLE_STRIP);
for(int k=0; k < dmf.objectList[i].polygons[j].numVertices; k++)
{
glVertex3f(...);
}
glEnd();
} |
This is only correct when there are only triangles in the map, means polygons with three vertices. If you want to do it the right way, you should call glBegin(GL_POLYGON); instead of glBegin(GL_TRIANGLE_STRIP);
For the textures, you should bind the texture before every Polygon and with every vertex, you need to specify the texture coordinates with glTexCoord2f(dmf.objectList[i].polygons[j].texcoord[k][0],dmf.objectList[i].polygons[j].texcoord[k][1]);
(just an example, no guarantee for correctness. i don't really know how the texture coordinates are stored there) _________________ Behold! The DeleD Wiki! Please help us expanding it
DeleD on IRC |
|
Back to top |
|
|
CMe Member
Joined: 30 Jun 2005 Posts: 72 Location: Ontario Canada
|
Posted: Mon Nov 14, 2005 11:42 pm Post subject: |
|
|
Hi all. It seems people are interested in using the dmf loading procedures I wrote and I can imagine understanding how to render with it can be a bit confusing. I wrote the routines in such as way to leave all the data exposed for maximum flexibility and not change the structure used by deled.
I'm going to write a small opengl rendering example and include it with the dmf.h / dmf.c code.
btw, if you want to ensure that all your geometry in the map are triangles, there is a function which will split all polygons down with TriangulateDMF. |
|
Back to top |
|
|
Paul-Jan Site Admin
Joined: 08 Aug 2004 Posts: 3066 Location: Lage Zwaluwe
|
Posted: Thu Nov 17, 2005 10:02 am Post subject: |
|
|
Quote: |
I'm going to write a small opengl rendering example and include it with the dmf.h / dmf.c code. |
I think that's a great idea! |
|
Back to top |
|
|
banshee777 Member
Joined: 10 Feb 2005 Posts: 37
|
Posted: Sun Nov 20, 2005 4:10 am Post subject: asd |
|
|
Well this is mine. I hope it helps
int brushrender()
{
char crap;
int i = 0;
int j = 0;
int uv0 = 0;
int uv1 = 1;
int uv2 = 6;
int uv3 = 7;
char test;
glEnable(GL_TEXTURE_2D);
while (i < mapcore[0].boxes) // MAX OBJECTS etc box, pyramid, etc
{
//unsigned int twopasscount = 0;
for (int j = 0; j < box[i].polygons; j++) // render all faces
{
uv0 = 0;
uv1 = 1;
uv2 = 6;
uv3 = 7;
//unsigned int twopass[20];
for (int b = 0; b < twopasscount; b++)
{
if (twopass[b] == box[i].materialID[j])
{
glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, mtexture[b]);
glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, mtexture1[b]);
}
}
glBegin(GL_TRIANGLES);
//for (int z = 0; z < box[i].vertices[j] && box[i].visible == -1; z++)
for (int z = 0; z < box[i].vertices[j]; z++) //render face
{
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, box[i].uv_values0[j][uv0], box[i].uv_values0[j][uv1]); //texture stretch
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, box[i].uv_values0[j][uv2], box[i].uv_values0[j][uv3]);
glVertex3d(box[i].x[box[i].vertice_index_values0[j][z]],box[i].y[box[i].vertice_index_values0[j][z]],box[i].z[box[i].vertice_index_values0[j][z]]);
uv0 = uv0 + 2;
uv1 = uv1 + 2;
uv2 = uv2 + 2;
uv3 = uv3 + 2;
}
glEnd();
}
i++;
}
glDisable(GL_TEXTURE_2D);
} |
|
Back to top |
|
|
|