Wchris Posted June 10, 2016 Share Posted June 10, 2016 If it's not a bug what's wrong with my code please ? What can be causing this #include "App.h" using namespace Leadwerks; App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {} App::~App() { delete world; delete window; } bool App::Start() { window = Window::Create(); context = Context::Create(window); world = World::Create(); camera = Camera::Create(); camera->SetPosition(0, 0, -5); light = DirectionalLight::Create(); light->SetRotation(45, 45, 45); light->SetPosition(0, 0, -3); //Create a material Material* material = Material::Create(); material->Load("Materials\Developer\Bluegrid.mat"); //material->SetColor(1, 0, 0); //Create a model and apply the material to it Model* model = Model::Box(); model->SetPosition(0, -2, 0); model->SetScale(10, 1, 10); model->SetMaterial(material); return true; } bool App::Loop() { if (window->Closed() || window->KeyDown(Key::Escape)) return false; Time::Update(); world->Update(); world->Render(); context->DrawRect(100, 10, 100, 60); context->Sync(); return true; } This is what I get Quote Windows 7 home - 32 bits Intel Quad Q6600 - nVidia GTX 460 1GB - 2 GB RAM Link to comment Share on other sites More sharing options...
tjheldna Posted June 10, 2016 Share Posted June 10, 2016 Your path needs forward slashes instead of backward. Quote Link to comment Share on other sites More sharing options...
Josh Posted June 10, 2016 Share Posted June 10, 2016 In C++ and Lua you have to do this to get a slash, otherwise you are specifying something else: material->Load("Materials\\Developer\\Bluegrid.mat"); For example, \" will specify a quote symbol inside a string. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Wchris Posted June 10, 2016 Author Share Posted June 10, 2016 Sorry guys, really wish it would be so easy ... but it's still diving me mad. Something must be wrong in my setup \\ are converted into / in log see screenshot + no error but still no good Crossing fingers someone will figure out Even tryed with full path as you can see... but in both case log says material and texture is loaded. Just not applyed. PS: I'll switch to beta buid now, maybe it'll help EDIT: same result with beta, I think I need some sleep now ... Quote Windows 7 home - 32 bits Intel Quad Q6600 - nVidia GTX 460 1GB - 2 GB RAM Link to comment Share on other sites More sharing options...
Josh Posted June 10, 2016 Share Posted June 10, 2016 Thank you for the best bug graphic of all time. You sir have thoroughly confused me. I look forward to solving this puzzle. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted June 10, 2016 Share Posted June 10, 2016 You sneaky person. Material* material = Material::Create(); material->Load("Materials\Developer\Bluegrid.mat"); Should be: Material* material = Material::Load("Materials\Developer\Bluegrid.mat"); 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Wchris Posted June 11, 2016 Author Share Posted June 11, 2016 You sneaky person. Hi Josh You found the explanation and saved my day. As a reward I'll tell you why we got there I started from this example of setmaterial http://www.leadwerks.com/werkspace/page/api-reference/_/entity/entitysetmaterial-r183 and could have avoided the pitfall if I used the load exemple http://www.leadwerks.com/werkspace/page/api-reference/_/material/materialload-r266 If you refer to the fact that my avatar remained invisible, it was because since LE3 armageddon and loss of possibility to use other alternative programming languages I was not using the engine anymore, but I still loved Leadwerks for the simplicity of it's command set and visuals. Since I was not using the engine and had nothing to exchange with the community I decided to go invisible. Why I'm back after so long ? Well, because after version 4 of Leadwerks I realized that people who were working on a SWIG wrapper finally failed. So I started writing my own called PWIG (Pascal Wrapper and Interface Generator). This forced me to install VC++ 2013 and learn the basics of C++ to tell my generator how to code in C++ for me. Stay relax, I perfectly understand you want to promote lua since it provides you more visibility of what people can achieve; it makes sense. Since I do not have enought knowledge of C++ and cannot provide good support I will not promote my work and this time it will stay a private work. So don't fear an alternate programming way will emerge, it won't happen this time. I really like some of the C++ features I discovered even if I still dislike his SMS style syntax. But one syntax flaw that made PWIG generate the code above is that there is no clear specification of the constructors in the class. In Pascal you must specify the keywords constructor/destructor but in C++ you can have as many as you want and specify nothing, so LOAD is a constructor that replaces CREATE but no way to know. And this leads to errors if you use a class and are not it's conceptor, errors that even you have difficulty to spot because of the ambiguity of the language. Cheers Thank you PS1 : I have awaken because VC++ can finally compile the code PWIG produces (It restored my willpower) but I have no idea how to solve the constructor enigma yet. PS2: Please don't tkink I prefer Pascal because of the syntax. It's not really the main reason. I prefer it because of the Component API build on top and integrated with the IDE. It simplifies my work and makes the code easyer to manage. C++ is great but I prefer to work with a small subset than being overwhelmed, I just like simplicity. I guess people who love Blitzmax think the same way. 1 Quote Windows 7 home - 32 bits Intel Quad Q6600 - nVidia GTX 460 1GB - 2 GB RAM Link to comment Share on other sites More sharing options...
Wchris Posted June 11, 2016 Author Share Posted June 11, 2016 You sneaky person. Material* material = Material::Create(); material->Load("Materials\Developer\Bluegrid.mat"); Should be: Material* material = Material::Load("Materials\Developer\Bluegrid.mat"); What strange is that I do the same mistake with model = Model::create(); Model->Load(...) instead of model = Model::load and it works, do you have an idea why ? Sorry I'm still a beginner in C++. Quote Windows 7 home - 32 bits Intel Quad Q6600 - nVidia GTX 460 1GB - 2 GB RAM Link to comment Share on other sites More sharing options...
Josh Posted June 11, 2016 Share Posted June 11, 2016 Both will load and return a material or model. However, your code was applying a blank material you created to the surface. You're able to see the model because the model doesn't get "applied" to anything. It simply exists in the world, although your model variable still does not contain the model you loaded. This should never ever be called this way: material->Load("Materials\Developer\Bluegrid.mat"); Material::Load() is a static function, which basically means it is a global function for the class. C++ is a little lenient in that it lets you call it with an instance of the class, which I don't think is appropriate. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Wchris Posted June 11, 2016 Author Share Posted June 11, 2016 Thank you very much Josh ! you were a great help, I have learnt something. Time to go back to the code. Quote Windows 7 home - 32 bits Intel Quad Q6600 - nVidia GTX 460 1GB - 2 GB RAM Link to comment Share on other sites More sharing options...
Recommended Posts
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.