• What Do You Need Help With? V8
    1,074 replies, posted
You can use something like a map/hashmap or a sparse set. They have different advantages, a map/hashmap will be more space efficient but the memory won't be contiguous, a sparse set uses some more memory but has contiguous memory of components. It's also a bit more advanced implementation wise.
Use IEnumerable instead of List. c# - Generic list of lists, converting List<List<T>> to IList<IL.. An example: C# Online Compiler | .NET Fiddle
I'm attempting to do a calculation to get number of employees absent by imputing the employee id (any number not 0 or negative) and the days said employee was absent along with the total number of days absent for all employees. The inputs stop at a certain number of times like after 5 inputs for employees and 5 days absent inputs then putting them in a outward text file. So far my coding has brought new errors and unknown identifiers. Basic c++ my arse.
None of this even compiles. Post the code here, I am not sure if google is rendering it correctly.
The file itself or a copy/paste of the code? I have the latter here. For some reason the #include is not spaced out in new lines like in the C++ file: #include <iostream> #include <fstream> #include <string> using namespace std; outFile employeeabsences.txt; int numEmployees(); int numOfEmployees(); void writeEmployeeNumberAndDaysMissed(string, int); int main() { //Get NumEmployees //write TotDaysAbsent // Calculate AverageDays Absent int numEmployees; int totalNumber; int totAbsences; int TotDaysAbsent; outFile; double average; cout << "\nThe" << numEmployees << " employees were absent a total of " << totAbsences << "days \n The averagr number of days absent is " << average << "days \n\n"; } int numOfEmployees(ofstream & outfile) { int numEmployees; int employeeID; cout << "Please enter the number of employees in the company." << endl; cin >> numEmployees; } int TotDaysAbsent() { i < numEmployees; int AverageDaysAbsent; } double averageAbsent(int numOfEmployees, int totAbsences) { totAbsences / numOfEmployees; } system("pause"); return 0;
There are several things wrong with your code, but you'll get the hang of it eventually. For starters (in no particular order), your functions have no return call. Your function: int numberOfEmployees(ofstream & outfile) {} the first part of that declaration says that it returns an integer Thus, when you've retrieved the number of employees from the console with "cin", you're then looking to pass that number back. You do this by saying "return numberOfEmployees;" Secondly, your total days absent function doesn't really do anything, same of the average absent function.
I'd honestly go read C++ Primer: you could really use the information that can provide as this code has a lot of things that could be improved or fixed.
Hey guys, been reading C++ Primer as per your suggestion, and so far it's great (albeit having a steep learning curve for someone who has never programmed before in their life). One of the exercises asked me to print numbers in between a range specified by the user. It works, but how's my coding looking? #include "stdafx.h" #include <iostream> int main() {     int v1 = 0, v2 = 0;     std::cout << "please enter your first number:" << std::endl;     std::cin >> v1;     std::cout << "" << std::endl;     std::cout << "Now enter the second number:" << std::endl;     std::cin >> v2;     std::cout << "" << std::endl;     std::cout << "Here's your list of numbers between " << v1 << " and " << v2 << std::endl;     // List of numbers starts here. Without the "", the first two numbers will stack next to each other on the same line     std::cout << v1;     std::cout << "" << std::endl;     while (v1 < v2) {         ++v1;         std::cout << v1 << std::endl;     }     return 0; } Note: I'm using "std::cout << "" << std::endl;" to basically ignore a line as it looks nicer for formatting. Not sure if there's a simpler way to do that?
How would I go about making a simple game on android? Think kinda a little more complex than pong. I just wanna get some experience in mobile dev since a lot of my experience is in web dev.
Why does std::cout << std::endl; not work?
Oh so it does, I'm just a gooseberry and didn't think to try that. Currently haven't used "\n" but I'll remember that for future reference, thanks!
Instead of while (v1 < v2) { ++v1; std::cout << v1 << std::endl; } You could do for(int i = v1; i < v2; i++) { std::cout << i << std::endl; } which is a bit more readable than a while loop IMO since iterating a number is what a for loop is meant to do
Still lost on rotation matrices. I'm adding custom camera controls to a game through memory editing, so I can only directly rotate in global space, but the camera needs to rotate on its local axes with player input.
Good things here: pre-increment your loop variables, it's a good habit to get into (for relatively complex reasons, but nevertheless its a simple habit and change to make) Stylistically, I'd recommend declaring one variable per line. It makes it harder to forget to initialize singular variables grouped together, and sorta helps readability imo. A for loop would make sense here, in my opinion. When you have bounds that can be set outside of the loop or don't require logic inside the loop to decide continue/not-continue, for loops are your best bet You might not have encountered do-while loops, but these are effectively the same - however, they have the upside of guaranteeing that the code in the loop will execute at least once Instead of using std::endl, consider just using "\n". std::endl forces an iostream flush, which is a much slower operation than using a newline. This usually won't come up much, but it's good to think about hidden intricacies like this, especially with C++'s stream classes as they're a bit odd at times. C++ Primer might be tough, but keep doing examples like you have been and keep polishing your skills and you'll start to get it. Feel free to keep posting here with questions or asking for criticism, especially once you get to larger/tougher topics: you're on the right track and you've got a good attitude, so I'm sure you'll do quite well eventually.
Translate to origin, rotate it then translate it back?
Are there any good techniques for real time 3D visibility calculations? Currently in my engine, in a separate thread I pull a list of all objects to render from a given perspective, and then I view-frustum cull it. Much like everything else in my engine I want to avoid pre-computations such that the levels can be dynamic.
That should work but it seems like it's introducing more steps than necessary. To clarify, the origin is still at the center of the camera object, not a fixed point in world space, but rotation around that origin isn't local.
Are you using occlusion queries yet? Query Object
I've never heard of those before This sounds like it could be useful for complex objects, though I'm not sure if I could seamlessly integrate this I was thinking more like cpu side, as creating cpu->gpu syncpoints sounds bad.
Well the gist is that you don't create a CPU-GPU sync point; the GPU does some calculations in one pass and modifies the indirect drawing buffers you're already using. Nvidia has an example of this technique that works best with Multidraw indirect, which I think you're still doing? Geometry pooled together into one or a few VBOs/IBOs, which I believe you are also doing? Can find the example repo here: https://github.com/nvpro-samples/gl_occlusion_culling Bottom of the readme has further examples intended for more complex/alternate use cases. You keep giving me chances to toss really crazy advanced/cutting-edge GPU techniques at ya, haha
Actually this is clunker than I realized. I can read global or local rotation, but I can't write to either. What I can manipulate is rotational force on each axis, so I need a way of calculating how much force on each global axis equals the rotational force on the local axis I want to manipulate.
This line was a good line of research I never knew SSBO's could be written to FROM shaders. I think I understand some of this technique. Render bbox's of desired 'heavy list' of models, and within the shader perform a depth test using the previous frame's depth buffer. If fragment passes, update some value such as an element within an SSBO indicating that this primitive is visible. I wonder if cases would appear where some fragments pass and others do not for the same primitive. Once this visibility information is updated, I'm not sure how I might use it while also preventing a sync point. For instance, if I were to read this buffer back, I could just check each element and generate a new render list consisting only of those visible objects. This would require synchronization. However, on the GPU, the only way I can think of is to just render the whole list again, discarding fragments right off the bat in the fragment shader if the buffer says their invisible. Since vertices cannot be discarded, I could do a passthrough geometry shader, however I feel that this would be a bad idea and would ultimately slow things down. Maybe this is a roll for compute shaders or something, though I know naught about them.
iirc, the way most people do it is writing into the draw indirect structure for each primitive that can't be rendered - just setting the vertex or index count to 0, so that it doesn't actually end up being rendered
I'm going to try this tomorrow, however I wonder if opengl even supports binding the same buffer to both the GL_DRAW_INDIRECT_BUFFER as well as to the GL_SHADER_STORAGE_BUFFER at the same time. They both use different binding calls (glBindBuffer vs glBindBufferBase) If I can, then MAYBE I can get away with doing this simply. If not, then I may need to make a duplicate buffer and adjust the ranges to 0 from the shader. In any case, I'm excited
Hey guys! Just a few days ago started learning python. I don't really have any issues with my script, it's working fine. I just wanted to get some feedback on my code. It'd be great if you guys could take a look at it and see if anything's could be improved or changed so I could write better code less shit code in the future. Thanks! https://gist.github.com/ontrigger/299ed8521845970b4045123a0e62b6e6
I have kind of a mentality question. As someone like me who's new to game programming in C++, what would be the most valuable approach: Learning how to make games from scratch (with just the OpenGL API) Learning how to make games using a library (like SFML) Using an engine like the Unreal Engine Personally I'm not really aiming to finish a game and distribute it, right now I'm just in it to gain as much experience as possible.
Can recommend the former that's what I did although I can't say it's the way that gets you to make a lot of games quickly unless you're being reasonable with scoping and come one who does that
What are you aiming for? I was interested in game programming and started modding using the GoldSource engine - I still don't know anywhere near enough to write an entire engine but playing around a lot on the game side gives you a decent understanding of what the engine has to do.
All approaches are valid, so it might boil down to your personal preferences / what you value more The fist approach will give you more hands on experience with OpenGL, which is a good thing, but since you're working at a pretty low level and all by yourself, you will most likely just be making a rendering tech demo (unless you keep at it for a long time). The second approach might make the rendering tasks easier and give you more time to focus on making the other engine systems. The third approach gives you most if not all the engine systems ahead of time, allowing you to focus on making gameplay specific elements.
The value of each one is really tough (if not impossible) to objectively evaluate, because they all have different values. The best question to ask is to yourself: what do you want to do? Do you want to learn how to make a renderer, and all the challenging part of that? Write your own rendering engine in OpenGL/Vulkan/DX12. Read lots of recent graphics programming journals, articles, and books to keep up-to-date on in-industry techniques and practices. Do you want to create a game engine of your own? Maybe choose a renderer (or still build your own, but make it part of your grander scheme) and pick up some textbooks on game engine programming, and find some good blogs to read for advice and ideas. Do you really want to just make a game? Then use a pre-existing engine. If you're in for game development and not graphics programming or engine programming, then choose something that lets you get involved in game programming sooner rather than later.
Sorry, you need to Log In to post a reply to this thread.