Advice please
I built a 2D tile engine in d3d8 and it works fine. Can you think of anyway to optimize this render?
Update geometry for base tile layer
Lock the vertex buffer
Fill the buffer with all the base tiles
Unlock the vertex buffer
Turn alphatesting off if its still on
Set tileset texture
Draw all tiles with one draw primitive call
Update geometry for fringe layer
Lock the vertex buffer discard the original contents
Fill the buffer with all fringe tiles
Unlock the buffer
Turn alphatesting on
Draw all fringe tiles with one draw primitive call
Update geometry for overlay layer
Lock the vertex buffer discard the original contents
Fill the buffer with all overlay tiles
Unlock the buffer
Draw all fringe tiles with one draw primitive call
Update 2D player
Lock the vertex buffer discard the original contents
Fill the buffer with one quad!!!
Unlock the buffer
Set the player texture
Draw the player
One thing that concerns me is when I add just one quad to render like when I render the player. Also I don''t really know how to keep track of what has been draw in a vbuffer so I just discard all of it each lock. This seems to run well on my computer and I don''t know how to do text in d3d (since it banished gdi) so I can''t put a fps counter on the screen. I''m just looking for some helpful hints, suggestions, and critiques on my method so far.
Helpful Hint:
char Buffer[256]
sprintf(Buffer, "MyApp - %d FPS", FPS);
SetWindowCaption(hWnd, Buffer);
Hope it helps.
EDIT: I think your general idea sounds good. Hopefully your running in windowed mode so you can hceck the fps using above code.
[edited by - Illumini on July 24, 2003 11:16:10 PM]
char Buffer[256]
sprintf(Buffer, "MyApp - %d FPS", FPS);
SetWindowCaption(hWnd, Buffer);
Hope it helps.
EDIT: I think your general idea sounds good. Hopefully your running in windowed mode so you can hceck the fps using above code.
[edited by - Illumini on July 24, 2003 11:16:10 PM]
[(funny?) joke]
char Buffer[256];
sprintf(Buffer, "MyApp - %d FPS", FPS);
ofstream File( "LPT1:" ); // printer
File << Buffer;
File.close();
[/(funny?) joke]
.lick
char Buffer[256];
sprintf(Buffer, "MyApp - %d FPS", FPS);
ofstream File( "LPT1:" ); // printer
File << Buffer;
File.close();
[/(funny?) joke]
.lick
There are some great D3D tutorials on www.Andypike.com - especially source code (and tute) on fonts in D3D - unfortunately the site is offline at the moment but i have the source code - email me if you want it.
Cya
Cya
quote:Update geometry for base tile layer
Lock the vertex buffer
Fill the buffer with all the base tiles
Unlock the vertex buffer
What kind of updates are you doing to the base tile layer, exactly?
2D tile maps are mostly static, and most of these can be fitted into a single vertex buffer. If possible, do so and then use a dynamic index buffer for streaming instead:
Lock the index bufferFill the buffer with indices of visible tilesUnlock the index buffer
Index buffers are better for streaming, due to the bandwidth savings (as well as cache utilization, and avoidance of redundant vertices)
quote:Draw all tiles with one draw primitive call
I like this part =)
quote:Update geometry for fringe layer
Lock the vertex buffer discard the original contents
Fill the buffer with all fringe tiles
Unlock the buffer
Same goes here - and for the overlay layer too -: index buffers.
quote:Also I don''t really know how to keep track of what has been draw in a vbuffer so I just discard all of it each lock.
It''s actually pretty easy if you think about it for a while. I won''t explain it here, because it''s already demonstrated at nVidia''s developer website (in 4 header files - I think):
DyanmicVB.h, DynamicIB.h, StaticIB.h, StaticVB.h
Search for these there and you''ll be happy
quote:[(funny?) joke]
char Buffer[256];
sprintf(Buffer, "MyApp - %d FPS", FPS);
ofstream File( "LPT1:" ); // printer
File << Buffer;
File.close();
[/(funny?) joke]
It is funny.
You need to have some self-confidence, there
Peace,
Muhammad Haggag
quote:Original post by Coder
What kind of updates are you doing to the base tile layer, exactly?
2D tile maps are mostly static, and most of these can be fitted into a single vertex buffer. If possible, do so and then use a dynamic index buffer for streaming instead:Lock the index bufferFill the buffer with indices of visible tilesUnlock the index buffer
Index buffers are better for streaming, due to the bandwidth savings (as well as cache utilization, and avoidance of redundant vertices)
I don''t understand what you''re suggesting. Are you saying that you keep all an entire tile map in a static vertex buffer and then to change which layer is being drawn you just select the indices pointing to that layer?
quote:I don''t understand what you''re suggesting. Are you saying that you keep all an entire tile map in a static vertex buffer and then to change which layer is being drawn you just select the indices pointing to that layer?
I initially suggested keeping each layer in a static vertex buffer and using indices to render the visible tiles.
If you can put your tile map, with all its layers, in a reasonably sized vertex buffer, I''d say you should do it.
Peace,
Muhammad Haggag
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement