Jump to content
  • Advertisement

Archived

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

Logar

Slow Voxel engine :-(

This topic is 6354 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

DrawVoxel(WORD *pixels, int x, int y, int scale, int r, int g, int b) { WORD Pixel; Pixel = (r << Position.rgbRed) | (g << Position.rgbGreen) | (b); for(int i = 0;i < y;i++) { for(int j = 0;j < scale;j++) { pixels[x + ((ScreenY - i)*ScreenVert) + j] = Pixel; } } return true; } //--------------------------------------------------------------- void UpdateFrame(void) { DDSURFACEDESC2 DDSurfDesc; DDSURFACEDESC2 DDSurfDesc2; ZeroMemory( &DDSurfDesc, sizeof( DDSurfDesc )); DDSurfDesc.dwSize = sizeof( DDSurfDesc ); ZeroMemory( &DDSurfDesc2, sizeof( DDSurfDesc2 )); DDSurfDesc2.dwSize = sizeof( DDSurfDesc2 ); g_pDDSBack->Lock( 0, &DDSurfDesc, DDLOCK_WAIT, 0 ); g_pDDSOne->Lock( 0, &DDSurfDesc2, DDLOCK_READONLY, 0 ); ScreenVert = DDSurfDesc.lPitch/2; ///////////////////////////////////////////////////////////// int rv,gv; rv = 8;gv = 100;float bv = 50; WORD *pixels = (WORD *)DDSurfDesc.lpSurface; WORD *pixels2 = (WORD *)DDSurfDesc2.lpSurface; DrawVoxel(pixels,1,480,640,1,1,1); float W = 60; for(int j = 20;j < 50;j++) { bv -= 0.; W -= 1; int k = W / 2; for(int i = 0;i < W;i++) { rv = pixels2[(100 + i + j*256 - k)]/3.6-150; DrawVoxel(pixels,i * (640 / W), pixels2[(100 + i + j*256 - k)]-((j*j)/25), (640 / W)+1,rv,gv,bv); //fix!!!! } } ///////////////////////////////////////////////////////////// g_pDDSOne->Unlock(NULL); g_pDDSBack->Unlock(NULL); g_pDDSPrimary->Flip(NULL,0); // } this is the main code of a little test i made to create a Voxel-engine but its very slow (I´ve a Thunderbird 800 but there are only 2 or 3 fps) why? DDSurfDesc2 = is the scourimage and DDSurfDesc = is the Primarysurface

Share this post


Link to post
Share on other sites
Advertisement
-Galileo430-

Voxels are still usefull for some neat effects, they are easy to make landscapes, and landscapes that take damage and deform.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!