Jump to content

framework used with custom rendering


Rick
 Share

Recommended Posts

I'm trying to use the framework, so I can get the lua stuff, but use my own buffer and drawing. All I get is a black screen.

 

So I init the framework just like normal, I create my own buffer, and in the loop I call UpdateFramework() but in the drawing part I have:

 

               TBuffer buffer = CreateBuffer(1024, 768, BUFFER_COLOR0 | BUFFER_DEPTH | BUFFER_NORMAL);

               //RenderFramework();
	SetBuffer(buffer);

	RenderWorld();

	SetBuffer(BackBuffer());

	RenderLights(buffer);

                // Send to screen
                Flip(0);

 

 

This produces a black screen and I can't figure out why. Everything is created in the main framework world and that's what would be set as the current world before RenderWorld() is called so that should render the world to my custom buffer. Then I follow the normal steps for non framework to get the lights drawn on that buffer. Why would this produce a black screen?

Link to comment
Share on other sites

require "scripts/constants/engine_const.lua"
RegisterAbstractPath(".")
Graphics(800,600)
fw = CreateFramework()
camera =fw.main.camera
camera:SetPosition(Vec3(0,20,-20))
light = CreateDirectionalLight()
light:SetRotation(Vec3(45,45,0))

camRotation=Vec3(0,0,0)

MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2)
HideMouse(1)

prevPos = Vec3(0)
cube = {}
cube1 = {}
cube2 = {}

gx=0
gy=0
cub=CreateCube()

for a = 0, 50, 1 do
for b = 0, 100, 1 do
	cube[b] = CopyEntity(cub)
	cube[b]:SetPosition(Vec3(prevPos.x + 1,prevPos.y + 1,prevPos.z))
	prevPos = cube[b]:GetPosition()
end
prevPos = Vec3(0,0,prevPos.z + 2)
end
prevPos = Vec3(0)
for a = 0, 50, 1 do
for b = 0, 100, 1 do
	cube[b] = CopyEntity(cub)
	cube[b]:SetPosition(Vec3(prevPos.x - 1,prevPos.y + 1,prevPos.z))
	prevPos = cube[b]:GetPosition()
end
prevPos = Vec3(0,0,prevPos.z + 2)
end

CameraClearMode(camera,-1)

minibuffer=CreateBuffer(256,256,BUFFER_COLOR+BUFFER_NORMAL+BUFFER_DEPTH)
thisbuffer=GetBuffer()

while KeyHit(KEY_ESCAPE)==0 do

        --Camera look
       gx=Curve(MouseX()- GraphicsWidth()/2,gx,10)
       gy=Curve(MouseY()- GraphicsHeight()/2,gy,10)
       MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2)
       camRotation.x = camRotation.x+gy /10
       camRotation.y = camRotation.y-gx /10    
       camera:SetRotation(camRotation,1)

       --keys
       move   = Curve(KeyDown(KEY_W)-KeyDown(KEY_S),move,10)
       strafe = Curve(KeyDown(KEY_D)-KeyDown(KEY_A),strafe,10) 
       camera:Move(Vec3(strafe ,0,move))       

       fw:Update()

thisbuffer=GetBuffer()
SetBuffer(minibuffer)
camera:Turnf(0,180,0)
RenderWorld();
RenderLights(minibuffer);
camera:Turnf(0,180,0)	
SetBuffer(thisbuffer)

fw:Render()	

SetBlend(1);
SetColor(Vec4(0,1,0,0.5));
DrawImage(GetColorBuffer(minibuffer,0),0,300,256,-256)
SetBlend(0);

       Flip(0)
end

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...