moving to directx advice please

Started by
31 comments, last by tok_junior 19 years, 1 month ago
It would not look horrible, as for seamlessness..That is a whole other level of dificulty. The simplest is to have many transition tiles and the best is to use a method called texture splatting.
Advertisement
lol my head hurts.

ok ill tackle that after i get the tile rendering done.

couple more questions...

whats the best way to render each tile...right now i render each one seperate...

beginscene
for(num of tiles)
draw tile
endscene

should i do one large triangle strip....
if i use a large triangle strip..i cant texture each quad individually can I?
and if i do that how am i supposed to scroll...
in 2d you just draw new stuff in the direction your going....
I assume i just have a position relative to my world array and draw from that position...so id be redrawing everything each time...

i really wish i could find a good tutorial on making a 3d isometric engine that talked about the specifics of tile generation and scrolling...and the proper way to load up new tiles as i walk in a particular direction. I just dont want to reinvent the wheel and invent it wrong.
You do not draw one big quad, you draw them each individually,so yeah, how you are doing it now is fine. This is a good tutorial on scrolling within a 3D framework and although it utilized Direct3D 7 the concepts still apply to Direct3D 8.
tiles are up and running...now on to the scrolling :) thanks a ton!
Just to be clear...

Each time the screen is scrolled i am planning on

1. screen scrolled
3. drop old vertex buffer
2. rebuild vertex buffer with new tiles from array
3. draw

yes?

thanks
If all you're doing is plopping textures down onto a flat grid of tiles u dont need to update the vertex buffer, just change the textures each quad maps to. This is assuming of course you arent using different sized tiles to represent walls/ground etc...
actually right now each tile has its own vertex buffer..is that a bad thing?

here is a bit of code

public void Render(TileMap tileMap,D3DPanel d3dWindow)
{
int xx=0;
int yy=0;

//change state based on keyboard
ReadKeyboard(d3dWindow);

//Begin the scene
d3dWindow.D3DDevice.BeginScene();

//Clear the backbuffer to a blue color (ARGB = 000000ff)
d3dWindow.D3DDevice.Clear(ClearFlags.Target, System.Drawing.Color.Blue, 1.0f, 0);

for(yy = 0; yy< _tileCountY; yy++)
{
for(xx = 0; xx<_tileCountX; xx++)
{
Tile tile = tileMap.GetTile(xx + _screenOffsetX , yy + _screenOffsetY);

tile.UpdateVertexBuffer(d3dWindow.D3DDevice, xx, yy, _tileWidth, _tileHeight, _scrollOffsetX-_tileWidth, _scrollOffsetY -_tileHeight);

d3dWindow.D3DDevice.SetTexture(0,tile.TileImage);
d3dWindow.D3DDevice.SetStreamSource( 0, tile.VertBuffer, 0);

d3dWindow.D3DDevice.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
}
}

//End the scene
d3dWindow.D3DDevice.EndScene();

d3dWindow.D3DDevice.Present();
this._previousSOX = _scrollOffsetX;
this._previousSOY = _scrollOffsetY;
}
also is there anything one needs to do to get this up and running on a non dev machine...it only crashes and burns on anything but a development box.
Dont make a VxBuffer for all the tiles, that goes agaisnt the whole point of a vertex buffer. Use DrawPrimitiveUp which doesnt require a VB or copy things into the buffer and then draw it all at once. See this. Actually just go here here
I’ve read quite a few of those tutorials...that’s actually how i got this far...they are a bit rough since I’m using the managed API...but its gone ok..

now...there is no DrawPrimitiveUp in the managed API so i cant really use that one unless there is a corresponding method i missed.

i changed it so that all of the tiles are using the same vertex buffer but the render loop still has to update that Vertex buffer each time...im not creating 1 vertex buffer and putting all of the tiles into it...mainly because i don’t know how to texture that...I understand how to texture each quad..but how am i supposed to texture when im using 1 huge VB?

ive got smooth scrolling implemented now :) that was fun

This topic is closed to new replies.

Advertisement