Jump to content
  • Advertisement


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


D3D Dynamic Tile Engine texturing questions

This topic is 5810 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

ok so i was workin on my tile engine in c(++) and directx7... but my dx7 must have been bugged because ddsurfacedesc2''s wouldnt work so i just used it without the 2...soon many things i needed wouldnt work..so i moved to dx8 finally and all the stuff worked... but THEN i realized ddraw was gone and i should use d3d to make it a better engine....i still use the old ddraw pixel drawing functions to load from my custom tiles and all but im gonna use d3d for drawing to the actual screen.. i made a function that sets up a vertex buffer with the width and height in tiles(well 2 triangles in a 32x32 quad)....all is going well but im not sure on texturing... can dx apply more than one texture to a vertex buffer? would it be quicked to draw the screen to a surface using mostly older ddraw functions then 2 the screen using 2 triangles to cover the whole screen? im not sure...heres my dynamic vertex buffer code
int CVertMap(int x, int y)
	int vees = x*y * 6;
	g_quad = new CUSTOMVERTEX[vees];
	int ii;
	for(int x2 = 0; x2 < x; x2++)
	for(int y2 = 0; y2 < y; y2++)
		ii = (y2*x)+x2;
		g_quad[6*ii+0].x		= (x2*32) + 32;
		g_quad[6*ii+0].y		= (y2*32) + 32;
		g_quad[6*ii+0].z		= 0.5f;
		g_quad[6*ii+0].rhw		= 1.0f;
		g_quad[6*ii+0].color	= 1000*ii;

		g_quad[6*ii+1].x		= (x2*32);
		g_quad[6*ii+1].y		= (y2*32) + 32;
		g_quad[6*ii+1].z		= 0.5f;
		g_quad[6*ii+1].rhw		= 1.0f;
		g_quad[6*ii+1].color	= 2000*ii;

		g_quad[6*ii+2].x		= (x2*32);
		g_quad[6*ii+2].y		= (y2*32);
		g_quad[6*ii+2].z		= 0.5f;
		g_quad[6*ii+2].rhw		= 1.0f;
		g_quad[6*ii+2].color	= 3000*ii;


		g_quad[6*ii+3].x		= (x2*32);
		g_quad[6*ii+3].y		= (y2*32);
		g_quad[6*ii+3].z		= 0.5f;
		g_quad[6*ii+3].rhw		= 1.0f;
		g_quad[6*ii+3].color	= 4000*ii;


		g_quad[6*ii+4].x		= (x2*32) + 32;
		g_quad[6*ii+4].y		= (y2*32);
		g_quad[6*ii+4].z		= 0.5f;
		g_quad[6*ii+4].rhw		= 1.0f;
		g_quad[6*ii+4].color	= 5000*ii;

		g_quad[6*ii+5].x		= (x2*32)+32;
		g_quad[6*ii+5].y		= (y2*32)+32;
		g_quad[6*ii+5].z		= 0.5f;
		g_quad[6*ii+5].rhw		= 1.0f;
		g_quad[6*ii+5].color	= 6000*ii;

	{ return -8;};

	CUSTOMVERTEX *vertices;
	if(FAILED(g.lpvb->Lock( 0, sizeof(g_quad), (BYTE**)&vertices, 0 )))
	for(ii = 0; ii <= vees-1; ii++)
	vertices[ii].x =		g_quad[ii].x;
	vertices[ii].y =		g_quad[ii].y;
	vertices[ii].z =		g_quad[ii].z;
	vertices[ii].rhw =		g_quad[ii].rhw;
	vertices[ii].color =	g_quad[ii].color;
	g.polys = vees/3;
	return DD_OK;

g is my global class for global variables.....EWarn is my error reporting function...vees is the number of verteices.. i also realize the custom vertex structure will need to be changed to support textures...and i use ii in the color defining just so i can see the differences in the polys -kaptan "If you cant handle the heat, Get off the car hood"

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!