• What Do You Need Help With? V8
    1,074 replies, posted
[QUOTE=proboardslol;52502179]C#. I would never recommend Visual Basic to anyone because I don't know if any serious software companies use it anymore. C++ can do the same thing, but more people are moving towards C# these days so I'd recommend C#[/QUOTE] C# and C++ are both widely used. C++ audience is not being pulled to C# because they both have different design goals. Visual Basic .NET is definitely not something you would use in a new project; it would be C# by default.
Still, where do I look about accessing files from a program or... I cant even properly formulate that. Really no clue which documentation i should look up. Halp :v:
[QUOTE=CruelAddict;52502389]Still, where do I look about accessing files from a program or... I cant even properly formulate that. Really no clue which documentation i should look up. Halp :v:[/QUOTE] Depends on what language you decide to use. If you're going to use C#, google "how to read a file in c#"
I'm trying to figure out if I have done the "Fix your timestep" thing correctly, can someone double check this? I have the following: [code] auto previous = system_clock::now(); double lag = 0.0; int time_per_update = 16; //This sets the framerate to ensure render only happens every X set_frame_rate(16); auto now = system_clock::now(); auto last = system_clock::now(); while( !should_close() ) { //This makes sure the app sleeps the remainder of time to ensure a full loop takes however long set_frame_rate has been set to ensure_max_render_time(); auto current = system_clock::now(); lag += duration_cast<microseconds>( current - previous ).count() / 1000.0; previous = current; poll_events(); while ( lag >= time_per_update ) { // update(); lag -= time_per_update ; std::cout << duration_cast<milliseconds>( now - last ).count() << std::endl; last = now; now = system_clock::now(); } gl_clear(); // render(lag / time_per_update ); gl_display(); } [/code] So, if I set set_frame_rate to 16, I get the following: [QUOTE] 14 15 16 17 14[/QUOTE] And imgui says the render time is also 16ish ms, meaning the update is hapening once per frame. If I set set_frame_rate to 0, meaning there is no framerate limit I get: [QUOTE] 14 15 16 17 14[/QUOTE] But imgui says its taking around 1-2ms per draw call, so the outer loop is going as fast as it can, rendering as many times as possible, but the update loop is still only running every 16ms. Up to here its all understood and I think its correct. However, If I put in 30 to set_frame_rate, simulating a drop to 30fps, I get: [QUOTE] 1 28 1 28 1 28 2 28 0[/QUOTE] And as expected imgui says it takes arond 30ms per draw iteration. The jump between 1-28ms, is that because it takes 28ms to get back to the loop, then instantly can make another update iteration to stay in sync?
[QUOTE=Richy19;52502772][...] The jump between 1-28ms, is that because it takes 28ms to get back to the loop, then instantly can make another update iteration to stay in sync?[/QUOTE] Yes. It's working (roughly) as intended, but you're technically not using a fixed timestep this way. Which is good because otherwise (with 'proper' fixed timestep and if you don't use additional frame interpolation), you get the average Japanese PC game. [editline]24th July 2017[/editline] The advice really should be 'cap your timestep [B]and[/B] cap your frame advance'. If you (completely) fix the timestep instead of capping it, you can't render at high FPS. If you don't cap your frame advance, your game can grind to a halt if you get too low performance.
[QUOTE=Tamschi;52502884]Yes. It's working (roughly) as intended, but you're technically not using a fixed timestep this way. Which is good because otherwise (with 'proper' fixed timestep and if you don't use additional frame interpolation), you get the average Japanese PC game. [editline]24th July 2017[/editline] The advice really should be 'cap your timestep [B]and[/B] cap your frame advance'. [B]If you (completely) fix the timestep instead of capping it, you can't render at high FPS. If you don't cap your frame advance, your game can grind to a halt if you get too low performance.[/B][/QUOTE] What are the changes I would need to do these? I think I would be fine rendering at max 60fps
Trying to use [I]fopen[/I] in C++, for some reason it does not like working outside of the executable directory. This works for example: [code]logFile = fopen("game.log", "w");[/code] But this: [code]logFile = fopen("cfg\\game.log", "w");[/code] Or this: [code]logFile = fopen("C:\\Users\\username\\Documents\\My Games\\ThisGame\\game.log", "w");[/code] does NOT work (returns null pointer), and [I]perror[/I] says "No such file or directory" even though the corresponding files and folders exist. Is there something I am overlooking?
Not sure, seems weird. But if you're using C++ I suggest using fstream instead (I'd suggest the same to any other C functionality, it almost certainly exists in C++). [editline]25th July 2017[/editline] Maybe try using unix style filesystems aka '/' instead.
[QUOTE=Alice3173;52500409]Unfortunately this just ends up returning an empty array. It's a fairly similar method to the last one I'd tried myself. [CODE]function uniparser(input) { let output = []; if (!Array.isArray(input)) { for (let i in input) { output[output.length] = `${i}: ${parserswitch(input, i)}`; } } else { for (let i = 0; i < input.length; i++) { output[output.length] = parserswitch(input, i); } } return output; } function parserswitch(input, i) { let output = []; switch (i) { case "children": output[output.length] = uniparser(input[i]); break; case "traits": for (let j = 0; j < input[i].length; j++) { output[output.length] = `${input[i][j].type} (${input[i][j].magnitude})`; } break; default: output[output.length] = input[i]; } output = output.join(", "); return output; }[/CODE] Though my attempt here is probably far more inefficient because I kept adding on to it trying to work out what its issues were.[/QUOTE] Yeah not sure - it's a bit hard to follow and without the whole thing it's hard to say but there's nothing that's obviously wrong. I'd try starting with something only two levels deep and adding a whole lot of logging to try and narrow it down.
[QUOTE=WTF Nuke;52504542]Not sure, seems weird. But if you're using C++ I suggest using fstream instead (I'd suggest the same to any other C functionality, it almost certainly exists in C++). [editline]25th July 2017[/editline] Maybe try using unix style filesystems aka '/' instead.[/QUOTE] Using forward slashes did not help either. I need to be able to use backwards slashes since I want to use environment variables which have paths with backslashes anyways. I do not think using fstream would help either because boost seems to be running into the same issue as well with [I]read_ini[/I]. Maybe something to do with file permissions?
Hello. My opengl application works like this: The entire thing is in a class, where all variables are defined as private members and are then initialized in the constructor and updated in the update member function. I am currently working on a shader class. I need to make it so the following process works out fine: 1. construct with constructor without parameters (init with 0) 2. In the apps constructor make a temporary object that uses the 2nd shader constructor to load the shader files 3. using a overloadet operator= or a copy-constructor, copy everything from the temporary object to the member variable. 4. destruct temporary object. I have the destructor done (just a simple glUseProgram(0) and glDeleteProgram) I have all the constructors done (except copy constructor) My question now is: How can I correctly copy a shader program so that I can safely delete the old one.
I don't recall there being a shader copying function, but if you still have the ID's for the fragment and vertex shaders then you can use them to generate another functionally equivalent shader program - though it won't have any of the uniforms set from the previous one.
If you use newer OpenGL, you can use [URL="https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glProgramBinary.xhtml"]glProgramBinary[/URL] and [URL="https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glGetProgramBinary.xhtml"]glGetProgramBinary[/URL] to basically copy one shader into another.
I'm looking to support faces for my brush-based geometry that have more than 3 points. I've discovered the Delaunay triangulation algorithm, however it seems to generate points in 2D. This doesn't sound like it should be a problem, since triangles can define a 2D plane between the 3D points; however I'm having a brain fart and can't think of an ideal solution to transforming the input points to 2D (in a way that I can convert them back into 3D after). The only way I can think of to use this algorithm would be to transform my point list by the inverse of a TBN matrix, generate the modified triangles for the face in tangent space, and then transform the resulting points back. However, I would like a solution that doesn't require using tangent space, lest I ever want to triangulate faces that aren't UV wrapped...
-snip
[QUOTE=tschumann;52504746]I'd try starting with something only two levels deep and adding a whole lot of logging to try and narrow it down.[/QUOTE] That's a really stupid oversight on my end actually. I should've thought of doing this long before, lol. I'll give that a try later when I get some time.
[QUOTE=daigennki;52504475]Trying to use [I]fopen[/I] in C++, for some reason it does not like working outside of the executable directory. This works for example: [code]logFile = fopen("game.log", "w");[/code] But this: [code]logFile = fopen("cfg\\game.log", "w");[/code] Or this: [code]logFile = fopen("C:\\Users\\username\\Documents\\My Games\\ThisGame\\game.log", "w");[/code] does NOT work (returns null pointer), and [I]perror[/I] says "No such file or directory" even though the corresponding files and folders exist. Is there something I am overlooking?[/QUOTE] [QUOTE=daigennki;52504805]Using forward slashes did not help either. I need to be able to use backwards slashes since I want to use environment variables which have paths with backslashes anyways. I do not think using fstream would help either because boost seems to be running into the same issue as well with [I]read_ini[/I]. Maybe something to do with file permissions?[/QUOTE] Found the culprit, it seems both [I]fopen[/I] and [I]boost::property_tree::read_ini[/I] do not like spaces in the file path. "C:/Users/username/Documents/ThisGame/game.log" works for example, but "C:/Users/username/Documents/My Games/ThisGame/game.log" (note space in "My Games") does not. Why is this, and is there some way I can make it work with spaces in the path?
[QUOTE=daigennki;52511595]Found the culprit, it seems both [I]fopen[/I] and [I]boost::property_tree::read_ini[/I] do not like spaces in the file path. "C:/Users/username/Documents/ThisGame/game.log" works for example, but "C:/Users/username/Documents/My Games/ThisGame/game.log" (note space in "My Games") does not. Why is this, and is there some way I can make it work with spaces in the path?[/QUOTE] I'm not at all familiar with C++ but after a bit of searching I found [url=https://stackoverflow.com/questions/11466139/open-file-with-fopen-given-absolute-path-on-windows#14792044]this[/url] which suggests escaping the spaces like you'd do for the backslahes. So instead of what you had you'd want something like this I think: [code]logFile = fopen("C:\\Users\\username\\Documents\\My\ Games\\ThisGame\\game.log", "w");[/code]
[QUOTE=Karmah;52509832]I'm looking to support faces for my brush-based geometry that have more than 3 points. I've discovered the Delaunay triangulation algorithm, however it seems to generate points in 2D. This doesn't sound like it should be a problem, since triangles can define a 2D plane between the 3D points; however I'm having a brain fart and can't think of an ideal solution to transforming the input points to 2D (in a way that I can convert them back into 3D after). The only way I can think of to use this algorithm would be to transform my point list by the inverse of a TBN matrix, generate the modified triangles for the face in tangent space, and then transform the resulting points back. However, I would like a solution that doesn't require using tangent space, lest I ever want to triangulate faces that aren't UV wrapped...[/QUOTE] Delaunay can be used in 3D as well - here's a nice paper about it: [url]https://www.kiv.zcu.cz/site/documents/verejne/vyzkum/publikace/technicke-zpravy/2002/tr-2002-02.pdf[/url]
[QUOTE=Alice3173;52511648]I'm not at all familiar with C++ but after a bit of searching I found [url=https://stackoverflow.com/questions/11466139/open-file-with-fopen-given-absolute-path-on-windows#14792044]this[/url] which suggests escaping the spaces like you'd do for the backslahes. So instead of what you had you'd want something like this I think: [code]logFile = fopen("C:\\Users\\username\\Documents\\My\ Games\\ThisGame\\game.log", "w");[/code][/QUOTE] Weird, "\ " could not be interpreted by the compiler, and "\x20" (hex for space character) was interpreted correctly by the compiler but the same result as earlier. [editline]27th July 2017[/editline] Okay, that is really weird, it suddenly works... I might have made a typo somewhere, or I misplaced some files or folders. Sorry for wasting your time.
"\ " doesn't work because it's not an escaped character in C++. The space character is no different, so it's just an issue with fopen/boost. Try fstream?
I've got a question about lines: So let's say I've got a player, and he shoots a bullet. That bullet needs to intersect with walls so it stops and doesn't go through the wall. But, I want to use lines to represent the walls, not tiles. Okay, getting the intersection of two lines is like, 9th grade algebra. But, I want to do it efficiently. Obviously I don't want to check the intersection with EVERY line, so I assume I'd get the walls that are [I]closest[/I] to the player, but What if the wall is REALLY long, and the two points representing the wall are REALLY far away from the player? How do I figure out what the closest walls are? Am I going about it wrong from a conceptual standpoint?
[QUOTE=proboardslol;52514311]I've got a question about lines: So let's say I've got a player, and he shoots a bullet. That bullet needs to intersect with walls so it stops and doesn't go through the wall. But, I want to use lines to represent the walls, not tiles. Okay, getting the intersection of two lines is like, 9th grade algebra. But, I want to do it efficiently. Obviously I don't want to check the intersection with EVERY line, so I assume I'd get the walls that are [I]closest[/I] to the player, but What if the wall is REALLY long, and the two points representing the wall are REALLY far away from the player? How do I figure out what the closest walls are? Am I going about it wrong from a conceptual standpoint?[/QUOTE] you could have a grid that stores wall lines that are within each tile and only check for walls that are within the same grid squares as the bullet line
[QUOTE=zakedodead;52514483]you could have a grid that stores wall lines that are within each tile and only check for walls that are within the same grid squares as the bullet line[/QUOTE] I was thinking along those lines as well. Then, when I've confirmed that it's hit that tile, do the calculation on the line intersection
[QUOTE=JWki;52511654]Delaunay can be used in 3D as well - here's a nice paper about it: [URL]https://www.kiv.zcu.cz/site/documents/verejne/vyzkum/publikace/technicke-zpravy/2002/tr-2002-02.pdf[/URL][/QUOTE] I've been attempting this unsuccessfully for the past couple of days My original code was based on the Watson version, which is just an incremental insertion type of Delaunay triangulation. In the paper you posted, I've attempted to upgrade my function to the 3D watson version. Is my following assumption right about the differences between the 2D and 3D algorithms? In the 2D watson, starting from a super triangle we collect the edges of all triangles the new point intersects, deleting those triangles from the main list. We then delete all duplicate edges and form new triangles from the 2 points of an edge + the new point. In 3D watson, we start with a tetrahedron instead, and collect the triangles the new point intersects, deleting those tetrahedrons from the main list. We then delete all duplicate triangles and form new tetrahedrons from the 3 vertices of a triangle + the new point. Is this analysis right? Because my implementation ends up deleting the entire tetrahedron list when trying to remove the original tetrahedron at the end, suggesting it isn't generating the right tetrahedrons... I put a copy of my code on pastebin here [URL]https://pastebin.com/qpzzmNsm[/URL]
:snip:
Anyone have some arcball examples I could look at? I can't find anything using relatively modern OpenGL semantics. NeHe stuff is out of date and isn't working for me, and none of the github examples I've found have worked for me either. I've been stuck on this 4 times now, and I can't skip around it this time: i really just need a simple arcball camera that works, and I can't fucking find one or program one and its really fucking pissing me off.
[QUOTE=paindoc;52526111]Anyone have some arcball examples I could look at? I can't find anything using relatively modern OpenGL semantics. NeHe stuff is out of date and isn't working for me, and none of the github examples I've found have worked for me either. I've been stuck on this 4 times now, and I can't skip around it this time: i really just need a simple arcball camera that works, and I can't fucking find one or program one and its really fucking pissing me off.[/QUOTE] I don't see how exactly OpenGL has anything to do with the camera logic but fwif here's a gist that contains a pretty self contained camera class [url]https://gist.github.com/JWki/c55d18e40718add909d83bcc138e688f[/url] works pretty much like Blenders default camera so I think that should have the arcball rotation behaviour you want? EDIT: Has dependencies on glm obviously but should be easy to rip out / replace if need be. Or just look at it to see how it works.
[QUOTE=JWki;52526226]I don't see how exactly OpenGL has anything to do with the camera logic but fwif here's a gist that contains a pretty self contained camera class [url]https://gist.github.com/JWki/c55d18e40718add909d83bcc138e688f[/url] works pretty much like Blenders default camera so I think that should have the arcball rotation behaviour you want? EDIT: Has dependencies on glm obviously but should be easy to rip out / replace if need be. Or just look at it to see how it works.[/QUOTE] Cheers, this may well be the last of what I need. My main problem now is the rotation "sticks" while the mouse is held down. So a click and drag doesn't result in a slight move: it results in the viewport spinning maniacally. I'm not sure quite what's wrong with my method, I pretty much followed several tutorials I'd found but alas nothing is working. Everything breaks in some manner, but the endless spinning is the most common. I've got some ideas about that though, and what you shared looks like it'll give me a good start. Blender-esque camera (or a CAD/Modelling program) camera is precisely what I'm seeking out. [editline]edited[/editline] got it working, at least a barebones implementation: [url]https://github.com/fuchstraumer/VulpesRender/blob/master/src/util/Arcball.cpp[/url] Now I need to add translating the camera, zooming the camera, and probably locking axis'. Then onto object picking and editing. This is all completely new stuff to me so its been pretty tough. The ultimate fix was changing how/when I update mouse data, fixing an incorrect usage of a kind of data, and removing the terribly nested updates I had from my GUI wrapper to the instance from the instance to the camera (why did I ever even do that)
:snip:
Sorry, you need to Log In to post a reply to this thread.