About Monkey 2 › Forums › General Discussion › Lighting with Monkey-X
This topic contains 17 replies, has 5 voices, and was last updated by
PixelPaladin 11 months, 1 week ago.
-
AuthorPosts
-
May 10, 2018 at 2:48 am #14610
Hello, friends.
This topic is related to Monkey-X. I’m trying to use light, but nothing happens. I’m doing a very simple sample. What could be wrong? Could it be related to my computer? It’s an old – more than 5 years – HP notebook with integrated video. But I found a link with a sample over the internet and the lights work fine… Here’s my code.
Monkey12345678910111213141516171819202122232425262728293031323334353637383940Import mojo2Function Main()New X()EndClass X Extends AppField canvas:Canvas,img:ImageMethod OnCreate()SetDeviceWindow(320,240,False)canvas = New Canvasimg=Image.Load("monkey://data/bg.png",0,0,Image.Filter)canvas.SetAmbientLight .2,.2,.2End MethodMethod OnUpdate()End MethodMethod OnRender()canvas.Clearcanvas.SetLightType 0,1canvas.SetLightColor 0,.5,.5,.5canvas.SetLightPosition 0,MouseX(),MouseY(),-50canvas.SetLightRange 0,200For Local l:Int=0 To 639 Step 128For Local c:Int= 0 To 479 Step 128canvas.DrawImage img,l,cNextnextcanvas.Flush()End MethodEnd ClassThanks
May 10, 2018 at 1:38 pm #14611I don’t use mojo2, but I think you might get some information in the Cerberus X forums. Cerberus is the successor of Monkey X.
May 14, 2018 at 4:55 pm #14620Hello.
Phil, unfortunately I couldn’t make it work neither with Cerberus or Monkey. Monkey2 doesn’t launch on my notebook.
Does anyone know why light isn’t working??
Regards
May 14, 2018 at 8:50 pm #14623What are the specs of your notebook? What gpu, processor, ram?
It’s the gpu really that is most important. Are all the drivers up to date, especially the gpu’s?
May 15, 2018 at 11:59 am #14627Hi, Amon.
Well, as I told before, my notebook is a little bit old, it is more then 5 years old. Its specs are: Core i3, 4GB Ram with integrated gpu. I believe all drivers are updated… What can I do to play around with lights??
Thanks
May 15, 2018 at 12:32 pm #14628Do any of the MonkeyX light samples work, or is it just your own code that’s not working?
I can’t remember what samples are in MX, but seem to recall there was a lights sample. If that doesn’t work, I’d guess the notebook doesn’t support the GL or shader level required for them.
If it’s just your own code, ie. the sample works, probably best to post on the CerberusX forums, since probably very few here are using MX now.
May 15, 2018 at 12:38 pm #14629Well, I didn’t try any MX samples – and I don’t know if there is any – but once I accessed a link with a sample and it worked fine.
I’ll post my problem at CerberusX.
Thank you so much!
May 15, 2018 at 12:49 pm #14630For me it works with Cerberus-X when I change the path to just “bg.png” (instead of “monkey://data/bg.png”) with the following file structure:
12345FILE app.cxs ← main applicationDIR app.dataFILE bg.png ← color textureFILE bg_NORMALS.png ← the notmal mapFILE bg_SPECULAR.png ← specular mapMay 15, 2018 at 1:08 pm #14631Hi, PixelPaladin. Can you send me your code, please?
Thanks
May 15, 2018 at 1:40 pm #14632sure, here it is:
Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748StrictImport mojo2Function Main:Int()New XReturn 0EndClass X Extends AppField canvas:CanvasField img:ImageMethod OnCreate:Int()SetUpdateRate(60)SetDeviceWindow(320, 240, 2|4)canvas = New Canvasimg = Image.Load("bg.png", 0, 0, Image.Filter)canvas.SetAmbientLight(0.2, 0.2, 0.2)Return 0EndMethod OnUpdate:Int()If KeyHit(KEY_ESCAPE) Then OnClose()Return 0EndMethod OnRender:Int()canvas.Clearcanvas.SetLightType(0, 1)canvas.SetLightColor(0, 0.5, 0.5, 0.5)canvas.SetLightPosition(0, MouseX(), MouseY(), -50)canvas.SetLightRange(0, 200)For Local y:Int = 0 Until 480 Step 128For Local x:Int = 0 Until 640 Step 128canvas.DrawImage(img, x, y)NextNextcanvas.Flush()Return 0EndEndMay 15, 2018 at 2:39 pm #14633Thanks, it’s quite like mine, but I’ll give it a try!
May 15, 2018 at 2:55 pm #14634Well, it was your code. I just did some changes so that I can read it better myself
I think changing the path should be enough to make it work.
May 15, 2018 at 2:57 pm #14635I did notice that it was my code!!
I just didn’t understand why changing the path it should work…
May 15, 2018 at 4:47 pm #14636Just checking, did you have bg.png in a data subfolder, like this?
[/crayon]Monkey123456[crayon-5cb9af62e1608721700156 inline="true" ]--example.monkey--data/--data/bg.pngMay 15, 2018 at 4:52 pm #14637Sure I do.
-
AuthorPosts
You must be logged in to reply to this topic.