Page 2 of 3

Posted: Wed Jul 21, 2004 8:23 pm
by pg
Hi

do you see an error message? Do u use version 3.91?

Posted: Wed Jul 21, 2004 8:27 pm
by thefool
yes i use 3.91.

it complains about an error in this file:
XIncludeFile "INCLUDE\ProcPutSprite.inc"

hmm error message:

GetErrorPos() is not a function, linked list or an array

Posted: Wed Jul 21, 2004 8:33 pm
by pg
GetErrorPos()? this function does not exist in the raycaster! I downloadet the file to test it. Here I don't get the error. Very strange. Corrupted download?

Posted: Wed Jul 21, 2004 8:37 pm
by pg
did you replace the library?

Posted: Wed Jul 21, 2004 8:42 pm
by Num3
New lib works just fine, but how does one define which sprite is the texture one?

In the big example you assign the sprite to a dx surface, but wouldn't it be easier to have a command like.

Set_texture(sprite,texture)

where sprite would be PB sprite number a texture would be the wall (a,b,c,d)

Can you gimme an easy example otherwise?

Posted: Wed Jul 21, 2004 8:59 pm
by pg
Hi

Yes, it is also possible to load each texture like a sprite. In the example the sprites are single bitmaps. The walls are all together, exept the door. In the SetupTextures.inc file you can see, that the door texture is loaded as a single texture. You can make this with all other textures. But you have to change the blt command in the ProcRenderScene.inc to choose the correct texture for the texture number and declare this surface as a global variable. I made it this way to make it simpler (same surface). But it's up to you how to make it. :D

Edit...

If you want to add new textures (Walls) (b to z), you can just add a new picture at the end of the Textures.bmp. It will choose itself the correct texture. The texture.bmp lenght can be 64* the number of textures.

Posted: Wed Jul 21, 2004 9:09 pm
by thefool
:oops:

:( i guess that i said "no" to overwriting the lib :(

it works perfectly now!

Posted: Wed Jul 21, 2004 9:44 pm
by Num3
I understand how it works.

What i'm missing is how does the engine know which buffer the walls are...

Example:

Loadbitmap(0,"all_wall_textures.bmp")

How do i say to the engine, scan this buffer to read the textures....

There is no SetWallTexture(bitmapnumber)...

Must i always declare a TextureBuffer.IDirectDrawSurface7 so that the engine can grab the textures from there?

In other words i'm just trying to get the easy example to have textures :oops:

I've worked it all out, i even know how to make ligth FX with a dinamic map, but i haven't yet understand where the engine reads the textures from :mrgreen:

Posted: Wed Jul 21, 2004 10:04 pm
by pg
Aha, i think I know what you mean. The engine knows the texture number with the command GetTexture(ray).

Example:
If the command GetTexture(a) returns 5 (5=e in the map), then this will get the bitmapposition at 5*64 in the texture.bmp. It just moves a 64*64 clipping rectangle with blt and copies it. With this, you just have to add a new 64*64 pixel texture at the end of the texture.bmp when you add a new wall in the map.
If GetTexture(a) returns 2 (=b) , it is the first 64*64 pixel texture in the texture.bmp

This is how it clips the rectangle.

Code: Select all

        sldestRect\left   = a+100;
        sldestRect\top    = 300-scale;
        sldestRect\right  = a+100+1;
        sldestRect\bottom = 300+scale;
     
        slsrcRect\left    = ((texnum - 2) * 64) + texcol;
        slsrcRect\top     = 1;
        slsrcRect\right   = ((texnum - 2) * 64) + texcol+1;
        slsrcRect\bottom  = 64;
        
        SceneBuffer\Blt(sldestRect, TextureBuffer, slsrcRect, 0, 0)
The texturecolumn is the column number of the the texture returned by GetTexture().

Does this answer your question?

Posted: Wed Jul 21, 2004 10:09 pm
by pg
I make a short example code....

Posted: Wed Jul 21, 2004 10:44 pm
by pg
Here is an example, not perfect at all sorry. You have to put the Texture.bmp in the same folder!


Code: Select all


sldestRect.RECT
slsrcRect.RECT
destRect.RECT
eraserect.RECT

;rect for black sprite
eraserect\left=0
eraserect\top=0
eraserect\right=320
eraserect\bottom=200


; rect to copy buffer to buffer
destRect\left=160
destRect\top=140
destRect\right=480
destRect\bottom=340



Declare GetBackBuffer()
Declare GetPrimaryBuffer()


InitSprite()
InitKeyboard();


WndScrID = OpenScreen(640, 480, 16, "") 

InitMouse()



TextureBuffer.IDirectDrawSurface7 =LoadSprite(0, "Textures.bmp", 0)
FlipBuffer.IDirectDrawSurface7 =CreateSprite(2,520,600);320,600
backbuffer.IDirectDrawSurface7 =GetBackBuffer()
erase.IDirectDrawSurface7 =CreateSprite(3,320,200)



InitRaycaster()
Load_World("raymap.dat")
PositionPlayer(2,2,100)
SetMaxScale(400)

CloseDoor(1) ;open doors

Repeat
         
  
  ExamineMouse()
  KeyAction(-MouseDeltaY(),-MouseDeltaX())   ; move the player


  
 
  For a.l= 0 To 319
    
   
    texnum.l=GetTexture(a)
    texcol.l=GetTextureColumn(a) 
    scale=GetScale(a)/2
       
   
       
   If texnum=26:texnum=8:EndIf  ; no door, else no texture at z...bitmap lenght too short
     
    sldestRect\left = a+160
    sldestRect\top = 240-scale;
    sldestRect\right = a+160+1
    sldestRect\bottom = 240+scale;
     
    slsrcRect\left = ((texnum - 1) * 64) + texcol;
    slsrcRect\top = 1;
    slsrcRect\right = ((texnum - 1) * 64) + texcol+1
    slsrcRect\bottom = 64;
     
   
    
    FlipBuffer\Blt(sldestRect, TextureBuffer, slsrcRect, 0, 0)
 
  Next a






    ;copy scene to bacjbuffer
   backbuffer\Blt(destRect, FlipBuffer, destRect, 0, 0)

  
  
   FlipBuffers()
   
   
   ;erase backbuffer
   ClearScreen(0,0,0)
   
   ;Erase the the rendering buffer
   FlipBuffer\Blt(destRect, erase, eraserect, 0, 0)


  
  
   ExamineKeyboard()



Until KeyboardPushed(#PB_Key_Escape)
End




Procedure.l GetPrimaryBuffer() 
  !extrn _PB_DirectX_PrimaryBuffer 
  !mov eax, [_PB_DirectX_PrimaryBuffer] 
  ProcedureReturn 
EndProcedure

Procedure.l GetBackBuffer() 
  !extrn _PB_DirectX_BackBuffer 
  !mov eax, [_PB_DirectX_BackBuffer] 
  ProcedureReturn 
EndProcedure



Posted: Thu Jul 22, 2004 9:06 am
by Num3
Got it!

Now it's clear to me 8)

Going to do some real time FX tests now :lol:

Posted: Thu Jul 22, 2004 2:21 pm
by Dare2
This is pretty blooming impressive!

Using the simple example, after moving around a bit the title bar starts flickering v fast across the top of the screen, to the right of the scenario. You can see the bar and the [X] close button. Happens with both the .pb and the .exe

Haven't managed to make that happen with the other example.

Good stuff, this!

Posted: Thu Jul 22, 2004 4:05 pm
by blueznl
got the same with a lot of proggies, you wouldn't...

- be running on a multimonitor system?
- use a non-standard desktop size? (1152 x 8xx or something)
- use a desktop size that is different from the screensize?

all these things do cause that...

Posted: Thu Jul 22, 2004 5:02 pm
by Num3
It's a problem with the buffering... :(

I solved it by Clearing the entire screen before the buffer swap...