Jump to content

Ma-Shell

Members
  • Posts

    371
  • Joined

  • Last visited

Everything posted by Ma-Shell

  1. You might want to consider supporting cmake. cmake is able to generate projects for different IDEs. So you only have to support the cmake-files and by that you gain support for various IDEs. cmake can e.g. generate Make-files, as well as CodeBlocks-, CodeLite-, Eclipse-, or Sublime-Projects. Though I really don't know much about it, it looks like something worth looking into!
  2. I have a vive and will test this later. The last time I tried it, the camera was always stuck at 0,0,0 with no way to move it. Is there some way of moving the camera while having the tracking relative to the movement implemented?
  3. A memory leak won't cause access violations! A memory leak is when you allocate space on the heap, by using malloc or new and then simply abandon it without ever releasing it with free or delete. Smart pointers should do that sort of management for you and even if you were to do that wrong, it would simply cause the memory used by your program to rise steadily. An access violation occurs, when you are trying to access memory in a way you're not supposed to. This means, it is either not in an allocated state (never allocated or allocated and then freed) or it has protections active. In most cases, this happens, when you freed some object but did not set all pointers to null. This sort of problem can cause very weird types of errors. In the worst case, the memory you freed is reallocated for a different purpose and the next time you write to it, you modify some completely different structure
  4. It might be a good idea to allow us to register a callback before the context-sync is executed, so we can put other drawing stuff there.
  5. Is it a C++ or a LUA-project? In the case of LUA, I think, you don't have to do anything (except maybe e.g. if you hardcoded paths somewhere, you might need to change them to use forward slashes instead of backward slashes). In the case of C++ it depends on the additional includes you are using. The Leadwerks-API-functions should work without modifications, just like most standardlib-funcitons. Unfortunately there are some functions existent in the standardlib, that are not present on the linux-version and vice versa. However, if you didn't do any "exotic" includes, you should be fine.
  6. You're right, at the moment this is working but what Josh is asking is about the future with smart-pointers. The question is, if the user should have to maintain these source-references for them to keep playing or if the engine should do that for you. (At least that's how I interpreted the question)
  7. Yeah, holding the sound is one thing but holding the sources played from that sound is another thing: If you have a gun, which you can fire quite fast, you will play the sound everytime you pull the trigger. However, you would expect there to be sometimes 3-4 sources of the same sound playing at the same time if you're trigger-happy. This would mean, you'll have to keep a list of all sources emitted around and periodically check, whether you can release the individual sources. So: It's reasonable to always have a reference to the Sound, but not to all the Sources. To sum up the design I would prefer with a clear differentiation between Sound and Source: - Source has a smart-pointer to the Sound, which gets nullified when the source gets deleted. - Engine has a list of smart-pointers to all currently playing Sources. As soon as a Source is Stopped/Paused, this smart-pointer is nullified. The reasoning behind this, is that if the user plans to Resume/Restart the Source, they need to have their own smart-pointer anyway (otherwise they have no means of calling Resume()/Play()), which by itself prevents it from getting deleted. (This replaces what I previously stated as the source having a smart-pointer to itself) Bonus: The Sound::Play()-function should return a smart-pointer to the emitted Source-object!
  8. Correct, if the user wishes to stop the source, they have to keep a pointer to it themselves. If the user only wants to play the source once, without planning on stopping/resuming it, I see no reason, why you would want to force them to keep their own pointer around and continually check, whether the sound is done playing, so they can release it. The way I described it above, the user can choose whether to keep a pointer to it or not. Basically: Whenever the sound is playing, the engine makes sure that it is not deleted, while whenever the sound is not playing, it can be deleted. If you go down the other route of always forcing the user to keep the pointer, I can already see a new thread coming up every other week complaining about their sounds not playing. I'm pretty sure that for most users, playing a sound is a "fire-and-forget" kind-of-thing. PS.: What I forgot to mention above is, that if the user calls Play() after they called Stop(), the pointer needs to be populated again, of course
  9. I think, it's most reasonable to have the source maintain a smart pointer to itself. When the sound is finished playing or the user calls Stop(), this smart pointer is set to NULL. This would mean: - If the user keeps his own smart-pointer, there will be two smart pointers to the source and it will not be released until it is done playing and the user releases their own one. - If the user does not keep his own smart-pointer, the source is deleted once it is finished playing.
  10. Regarding Performance:
  11. The problem you're describing in the end can be solved with by deriving from "std::enable_shared_from_this" (http://en.cppreference.com/w/cpp/memory/enable_shared_from_this). This basically does what you planned with the weak_ptr-stuff but without additional overhead on your side. Translating your code-example, this would be: #include <memory> #include <iostream> using namespace std; class Thing : public enable_shared_from_this<Thing> { public: shared_ptr<Thing> GetSelf(); }; shared_ptr<Thing> Thing::GetSelf() { return shared_from_this(); } int main(int argc, const char *argv[]) { shared_ptr<Thing> p1 = make_shared<Thing>(); shared_ptr<Thing> p2 = p1->GetSelf(); } EDIT: It is important to derive publicly! In the example of the cppreference-link, they are using a struct, which derives publicly by default. For classes, you have to explicitly write ": public". I edited the code above
  12. The error message tells you that you're missing a fourth argument (#5, because "self.entity" is implicitly #1 and r,g,b are #2, #3, #4), which should be a number! Looking at the documentation (https://www.leadwerks.com/learn?page=API-Reference_Object_Entity_Camera_SetFogColor), you can see that there is also an alpha-value expected.
  13. #include <stdio.h> #include <unordered_map> unordered_map<std::string, Model*> models; ... std::stringstream mid_stream; mid_stream << -dim << ":" << -df << ":" << dim << (...) std::string mid = mid_stream.str(); if (models.find(mid) == models.end()) { Model* model = Model::Create(); model->SetRotation(orientation); models[mid] = model; } Edit: meh, 5 minutes too late
  14. How about instead having PlayAnimation return a handle/id, which you could later use to query the status?
  15. Ma-Shell

    Steam?

    To the right, there is a box, which says "Controles del propretaro". if you scroll down, you will see the last item in that box to say the spanish equivalent of "Change Visibility". There you can define who can see your item
  16. According to http://enet.bespin.org/Features.html under the heading "Sequencing" (third paragraph), ENet already does that:
  17. Ma-Shell

    AppDataPath()

    Actually, for linux "~" doesn't have any meaning at all... expanding "~" to the current user's home-directory is a feature of most shells (bash, zsh, ...). This means, if you type "~" in the terminal, the shell that is executing in the terminal replaces this by the user's home-directory. However, if you try to use "~" from your program, it will not mean anything to linux and your program can't do anything with it. Look at the following example-terminal session: $ echo foo > ~/bar $ cat ~/bar foo $ python Python 2.7.6 (default, Oct 26 2016, 20:30:19) [GCC 4.8.4] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> f = open("~/bar") Traceback (most recent call last): File "<stdin>", line 1, in <module> IOError: [Errno 2] No such file or directory: '~/bar' >>> f = open("/home/user/bar") >>> As you can see, e.g. Python can't find the file "~/bar", since "~" doesn't mean anything to it. Using the complete path, however, works. The same would hold for your Leadwerks LUA/C++ project: You can't use "~" to refer to the current user's home directory. Using the result of getenv("HOME"), as Josh mentioned, is the correct way to get the home-directory. (And yes, for the SHELL it is equivalent to "~/", but for your program)
  18. Then save the old font: oldfont = context:GetFont() context:SetFont(myfont) [write...] context:SetFont(oldfont)
  19. You need to create a separate buffer, render to this buffer and set this buffer as the texture for the corresponding material. For a code example, look at the code here: https://www.leadwerks.com/community/topic/16413-draw-on-buffer-to-apply-to-sprite/#comment-107677
  20. For me the text is red (given, it's a very dark red...). You should be able to make it more visible by using "diffuse+normal+emission+alphamask.shader" and binding the texture to both, channels 0 (diffuse) and 4 (emission): i.e.: local shader = Shader:Load("Shaders/model/diffuse+normal+emission+alphamask.shader") local currentBuff = Buffer:GetCurrent() local mat = Material:Create() mat:SetShader(shader) local sprite = Sprite:Create() sprite:SetViewMode(0) sprite:SetMaterial(mat) local buffer = Buffer:Create(20, 20, 1, 1) -- draw the text on the buffer Buffer:SetCurrent(buffer) self.context:SetBlendMode(Blend.Alpha) self.context:SetColor(Vec4(1, 0, 0, 1)) self.context:DrawText("Hello", 0, 0) local tex = buffer:GetColorTexture(0) mat:SetTexture(tex, 0) mat:SetTexture(tex, 4) Buffer:SetCurrent(currentBuff) That should make it more crisp.
  21. The shader is the problem. Use "Shaders/model/diffuse+normal+alphamask.shader" instead of "diffuse.shader", then it should work.
  22. You should put the libs into Leadwerks.h with pragma comment: If you add the following to the beginning of Leadwerks.h, it will automatically tell the linker that these libs are needed. So you do not need to add them to the linker settings for every project individually. (You will have to add the include header search directories, though, since there is sadly no pragma for this): #pragma comment(lib, "libcryptoMT.lib") #pragma comment(lib, "libsslMT.lib") #pragma comment(lib, "Rpcrt4.lib") #pragma comment(lib, "crypt32.lib") #pragma comment(lib, "libcurl.lib") #pragma comment(lib, "lua51.lib") #pragma comment(lib, "msimg32.lib") #pragma comment(lib, "steam_api.lib") #pragma comment(lib, "ws2_32.lib") #pragma comment(lib, "Glu32.lib") #pragma comment(lib, "Leadwerks.lib") #pragma comment(lib, "OpenAL32.lib") #pragma comment(lib, "OpenGL32.lib") #pragma comment(lib, "winmm.lib") #pragma comment(lib, "Psapi.lib") #ifdef DEBUG #pragma comment(lib, "libovrd.lib") #pragma comment(lib, "newton_d.lib") #pragma comment(lib, "dContainers_d.lib") #pragma comment(lib, "dCustomJoints_d.lib") #else #pragma comment(lib, "libovr.lib") #pragma comment(lib, "newton.lib") #pragma comment(lib, "dContainers.lib") #pragma comment(lib, "dCustomJoints.lib") #endif This makes updating projects more easy (I only tried it in Visual Studio and I don't believe gcc honors these pragmas, so if you are developing on linux, you need to add the libraries yourself, like it is right now).
  23. Shouldn't there be the name of the game somewhere in there, as well? Or do you just get a list of all servers and then have to read through the descriptions to see, if it is a server for your game?
  24. Ma-Shell

    gnet

    This shows only "ERROR"...
  25. If you DO want to explicitly use the cross-product (which is less efficient), nick.ace's approach has two small errors in the initial vectors for tangent and bitangent (and it's OK to normalize after calculating the cross-product). It should be: Vec3 tangent = Vec3(2.0, center_r - center_l, 0.0) Vec3 bitangent = Vec3(0.0, center_d - center_u, 2.0) Vec3 normal = cross(tangent, bitangent).Normalize()
×
×
  • Create New...