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


Problem loading multiple sprites in a 3D isometric engine

Recommended Posts

generalmx    122
Hello everyone. I''m trying to alpha blend using Direct3D7, working with VC++ 6.0. Futhermore, I''m working with sprites in a tile-based engine. Now, I have seen routines that work. I mostly like the ones that copy pixel-by-pixel. Yet I cannot make them work when I deal with a surface with more then one type of sprite. I load the entire bitmap into a temporary DD7 surface. I create a new DD7 surface in my array. Then I copy each pixel from the temporary DD7 surface to the new DD7 surface, region by region. Basically, I want to seperate a large DD7 surface with multiple sprites into an array of surfaces, and add alpha transparency for each of these surfaces. My region values seem fair. I seperate all sprites with one line, column and row-wise. recSearch.left = (TileDim * columncount) + columncount; = (TileDim * rowcount) + rowcount; recSearch.right = (TileDim * (columncount+1)) + columncount; recSearch.bottom = (TileDim * (rowcount+1)) + rowcount; This works with my background tiles, so it probably works here. And this is how I set my vertices. TANSTAAFL created the functions in his book, and I''m sure some will recognize them. They work fine for now. ptiSpriteList is a pointer to the array of surfaces and vertices, and TileDim is the dimension of each sprite. They have to be square, and divisable by 32. As well, I added one extra row and column (making the 64x64 image 65x65) to add anchors (which are calculated correctly, I checked). That''s why I subtract one from TileDim each time. //set up vertices //tiledim must be subtracted by 1 since anchors at +1 VERTEX_Set(&ptiSpriteList[tilenum].vertices[0],-ptAnchor.x,-ptAnchor.y,D3DRGB(1.0,1.0,1.0),0.0,0.0); VERTEX_Set(&ptiSpriteList[tilenum].vertices[1],-ptAnchor.x+(TileDim-1),-ptAnchor.y,D3DRGB(1.0,1.0,1.0),1.0,0.0); VERTEX_Set(&ptiSpriteList[tilenum].vertices[2],-ptAnchor.x,-ptAnchor.y+(TileDim-1),D3DRGB(1.0,1.0,1.0),0.0,1.0); VERTEX_Set(&ptiSpriteList[tilenum].vertices[3],-ptAnchor.x+(TileDim-1),-ptAnchor.y+(TileDim-1),D3DRGB(1.0,1.0,1.0),1.0,1.0); After this, we go into alpha blending. I used the assembly example found somewhere on this site. I added this, which is what you were suppose to do. Except I may have done something wrong. DDSURFACEDESC2 ddsdSource; DDSD_Clear(&ddsdSource); DDSURFACEDESC2 ddsdDest; DDSD_Clear(&ddsdDest); //lock textures lpddsSource->Lock(& region,&ddsdSource,DDLOCK_WAIT,NULL); (*lpddsDest)->Lock(NULL,&ddsdDest,DDLOCK_WAIT,NULL); DWORD ipitchsrc = ddsdSource.lPitch - (ddsdSource.dwWidth * 2); DWORD ipitchdest = ddsdDest.lPitch - (ddsdDest.dwWidth * 2); Region is a RECT that was gotten above (its recSearch). And yes, they are unlocked after the ASM routines. Note that I wrote & region because otherwise it''d look like ®ion. Can anyone help me? --gmx

Share this post

Link to post
Share on other sites