Archived

This topic is now archived and is closed to further replies.

Biberpelztrompete

Starcraft in OpenGL using Quads ??

Recommended Posts

Hiho, I tried to write Starcraft in OpenGL and I failed. The reason : 64 * 64 Quads using 4 different textures --> 12 frames per second. Does anybody know how to generate 256*256 maps with about 200 objects then ? I know that 256*256 would be 64 thousand Quads but there is no other way, is it ??

Share this post


Link to post
Share on other sites
hyho,

4096 Quads you''re drawing currently wiht your 64x64 field.. hm do you draw just one texture on one quad? there shouldn''t be such a speedloss.. do you draw your quads sorted by texture?

means, first all thequads with texture0, then all with texture1 and so on..

on the other way, dont draw quads..i''m not sure how much speed it gives to render trianglestrips instead but try it..

do you plan to do it in 2d or 3d?



we wanna play, not watch the pictures

Share this post


Link to post
Share on other sites
Hi,
I''m using an ortho projection matrix with an z-axis from -1 to 1. But it is not needed. The quads are drawn like this
For i := 0 to 63 do
For j := 0 to 63 do
begin
glBindTexture(z from a random map at position i,j
glBegin(QUADS);
glVertex2i(i ,j);
" i ,j+size
" i+size,j+size
" i+size,j);
glend;
end;

The camera sees max 25 * 19 quads, because the resoltution is 800x600 and every Quad is sized 32x32 --> 475 Quads
Drawing first all the quads with texture 1 ... would be much work. So does the BindTexture matter so much ?

Share this post


Link to post
Share on other sites
switching settings in opengl like glMaterial or glBindTexture or glLighting..whatever, they take alot of time.. a lot more than drawing things..

and its not soo much work.. believe me..

For t:= 0 to MaxTextures do
glBindTexture(texture[t])
For i := 0 to 63 do
For j := 0 to 63 do
if(texture[t]==texture from the map position i,j)
do
glBegin(QUADS);
blahblah..
glEnd();
end;

end;
end;
end;

(this is now really free style source.. but you should understand it.. when not, just say it..)

this is not the best sorting routine,but should boost up your rendering anyways..

btw, wich language are u using?


we wanna play, not watch the pictures

Share this post


Link to post
Share on other sites
Hiho,
my beloved Starcraft is now working at gigantic 49 fps. Thanx Dave. But I''ve wondered about glBitmap. Wouldn''t it be much easier with it ? I wanted to try it out, but the stupid command didn''t do anything !!!
Another problem is that I can ONLY use bmp files sized 64x64.
I did it like this :

procedure xy;
image := auxDIBImageLoadA(''pylon.bmp'');
...

glClear(bla bla)
glRasterPos2i(0,0); <-- Do I need this ??
glBitmap(image.sizex,image.sizey,0,0,0,0,image.data);
swapbuffers(dc);

Running it ... A strange black / white graphic appears.
So what did I do wrong ?

PS : Really great homepage ...

Share this post


Link to post
Share on other sites
hum.. i got glBitmap to work.. but anyways.. its really slow.. bether do it with quads (or even bether with the trianglestrips..)

its faster than glBitmap and glRasterpos and these..

tnx that you like the site..

we wanna play, not watch the pictures

Share this post


Link to post
Share on other sites
Hoho,
what do you mean with triangle strips ? I tried quad-strips but they don''t work, because they all have the same texture and there must not be space between the quads.
But my little game works with the quads as well and I don''t want to rewrite it, due the lots of work I had to invest. I hope in a few days / weeks time it will be mainly finished.
It won''t be as great as yours, but I DID IT.
So thanx for your support

PS : Did you really write 240 postings in this forum ????

Share this post


Link to post
Share on other sites
225 is written currently..

i mean instead of drawing one quad with 4 vertices, you draw two triangles with 4 vertices with a trianglestrip..

x---x
|\ |
| \ |
| \|
x---x

thats the whole trianglestrip you draw..(several times..)

why this is faster than a single quad, i dont know, but (mostly on older boards)it IS faster doing this..

we wanna play, not watch the pictures

Share this post


Link to post
Share on other sites