This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 »
556
Developing ENIGMA / Re: Accessing with types and passing by strong reference
« on: July 25, 2014, 02:07:34 pm »
So does Josh have an opinion on this? Should we start ditching ID's and maps, and start passing classes?
557
Programming Help / Re: C++ short delay when using CIN
« on: July 25, 2014, 02:00:58 pm »Quote
stl::containers is definitely something I need then, since I would need to pass the objects between functions, as I like to keep it clean and not do everything in main say for example a file reading function, then passing the read large block to an encryption function and so forth, I know that the non dynamic, regular ways of doing things, it gets lost outside the function (scope). Something I definitely do not want at this point for my specific needsYeah, it's useful when passing to functions, because regular arrays don't hold it's size. So if you pass an array to a function, you cannot know how large it was (so you cannot iterate over it). That requires ugly fixes like passing size as a separate argument. With containers, you always have that information. Just remember passing stuff by reference, so you don't create a copy. I had a project to do with computer vision - I passed images to functions to extract data from them.
Code: (edl) [Select]
double awesomeFunction(std::vector<std::vector<unsigned char> > img){
//Calculate something awesome and return
}
I had like 20FPS, because I was passing data by value. Then I just had to pass it by reference (add &) and it jumps to 60FPS:Code: (edl) [Select]
double awesomeFunction(std::vector<std::vector<unsigned char> > &img){
//Calculate something awesome and return
}
It's something people learn early, but still something worth reminding. Especially when working with large amount of data.Quote
I discovered the hard way back when I using GM that file functions were HORRIBLY, RIDICULOUSLY slow, but YYG must have assumed most people would use small files and never notice...... But try reading a larger binary and it's a PAIN....... They read 1 byte at a time, and I believe ENIGMA also, since it is compatible to its GML, also uses the same method.......Yeah, we need to address that. One suggestion I have is to have an option to load the whole file (file_open function) and then abstract that fact, so you can still use file_text_readln() and so on, but instead of doing that on the HDD, you do that in RAM. So in essence you would have a much larger speed, but still be compatible.
Quote
IN your example you are reading lines of text from a text file. I'm guessing, model informationAs the name implies, I loaded data from a CSV file. I saved point clouds in that format (as it's very easy) and used this function to load it in ENIGMA.
Quote
BTW speaking of that, if I were to code a function that uses containers, buckets, vectors, or whatever they are called, and stuff dynamically allocated (heap), in functions, can I use this in my ENIGMA projects. Example, if I use stl containers and vector and store a large 100 MB file into for example ResRead, and do something like return ResRead, can I pass back that 100MB back the function that was called in my enigma project ? If that is the case, then I could easily revamp the file functions and add faster more efficient ones for advanced game developers.Well the idea is that you can use C++ in ENIGMA. So you should be able to just call "vector<double> myVector;" straight in ENIGMA. I do make calls like "glEnable(...)" in my ENIGMA projects, so I know it's possible to use stuff that is not just in ENIGMA functions. Problem is that they break GML/EDL compatibility, as you know are using classes instead of ID's. But I personally think we should end using them.
558
Programming Help / Re: Can i use EDL and GML to make game?
« on: July 25, 2014, 01:51:59 pm »Quote
That question seems quite clear to me.But not in the context that this is project is named ENIGMA which has it's own language (EnigmaDevelopmentLanguage aka EDL) and is compatible with GM, as it's a GM alternative. It's like asking if you can program using GameMakerLanguage in GameMaker. So I thought he maybe meant something else.
559
Programming Help / Re: Can i use EDL and GML to make game?
« on: July 25, 2014, 04:51:08 am »
The OP was quite hard to understand. If I get it correctly you are asking if you can use GML to code instead of C++? Then of course you can. Technically you can use all three languages, but sadly there are some parser bugs that don't allow it 100% of the time.
560
Programming Help / Re: C++ short delay when using CIN
« on: July 25, 2014, 04:40:44 am »Quote
What container is allocated on the heap? Those sure look like they are being allocated on the stack, doesn't automatic storage duration apply to most of STL?As far as I know the difference between stack and heap is that stack has limited size, it's not dynamic (so the sizes must be known at compile time) and has limited scope (so it gets deleted when it goes out of scope). stl::containers are dynamic. Their size is usually not known at compile time, as you can always resize them and add/delete as much as you want. This means they are not allocated on the stack. What could be allocated on the stack is the class instance itself, which allows it to exist only in scope. But the memory for data internally probably uses new/delete, to allocate on the heap. That is why you can make a vector as big as you want, and if it fits in RAM, then you are okay.
Quote
Actually it does matter, there is limit on the size of an array you can use on the stack before you crash your program - I've found out the hard way when trying to use big arrays. If I will be manipulating large files 50MB, 100Mb, +++ the stack won't cut itWhat I meant is that if you use stl functions and don't use new/delete or regular static arrays, then you don't even have to know what heap and stack is. The whole distinction disappears, like in C# and Java where virtual machines have no such distinction.
Quote
You don't use stdio for files ? Doesn't ENIGMA use stdio ? Isn't it faster ?As I said, there are many ways to do it. You could try the one I posted, I will try it too, and see how fast it is. I remember I tried many ways to make the fastest file loading possible and the fastest I was able to get was this:
I would use that instead, not familiar with the above sounds more complicated for nothing. I've heard that with stdio and memory allocation someone managed to load a file at FULL speed (100MB/s) instead of the regular slower method of 10MB/s
Code: (edl) [Select]
int load_csv(string fname, int kind, double radius)
{
model_primitive_begin(kind);
ifstream data(fname.c_str());
string str_line;
int line_num = 0;
float v[3];
int col;
//vector<vector<unsigned int> > benchmark_frames;
//benchmark_frames.reserve(1000);
while(getline(data,str_line))
{
stringstream lineStream(str_line);
string cell;
int cell_num = 0;
while(getline(lineStream,cell,' '))
{
if (cell_num<3){
v[cell_num] = atof(cell.c_str());
}else{
col = atoi(cell.c_str());
}
cell_num+=1;
}
if (v[2]*v[2]<radius*radius){
model_vertex_color(v,col + (col << 8) + (col << 16),1.0);
}
line_num += 1;
}
model_primitive_end();
return line_num;
}
If regular ENIGMA takes like 20 seconds to load the file, then this does it in less than 1. But I didn't try loading using the vector copy. That might be faster.
561
Programming Help / Re: C++ short delay when using CIN
« on: July 24, 2014, 05:28:21 pm »
All of those containers will be allocated on the heap, not that it really matters. But you can just use a char vector. Like this little example I found:
Code: (edl) [Select]
#include <iostream>
#include <iterator>
#include <fstream>
#include <vector>
int main()
{
// open the file:
std::ifstream file(filename, std::ios::binary);
// read the data:
std::vector<unsigned char> myData((std::istreambuf_iterator<unsigned char>(file)), std::istreambuf_iterator<unsigned char>());
//Now myData holds the file, so you can access them however you like
if (myData[0] == 'a') return 2;
return 0;
}
There are MANY other ways to load a file into some kind of array. Some are slower (usually the C++ variants) and some are faster (for me C variants are usually faster). Like check this: http://stackoverflow.com/questions/15138353/reading-the-binary-file-into-the-vector-of-unsigned-chars
562
Programming Help / Re: C++ short delay when using CIN
« on: July 24, 2014, 01:56:31 pm »Quote
Interesting, ok so about memory what I knew was correct, but in regards to file handles, I was under the impression that those got automatically closed as well. As far as the maximum per process, it's 32 right So what happens if file handles don't get closed in such case, does it require a window restart ?I think it's safe to say that it closes file handles too. It was very long time ago when I heard that it didn't. Maximum amount of open though is limited if using POSIX C. It's 512 by default, but can be changed. So that is not a big issue (http://msdn.microsoft.com/en-us/library/kdfaxaay%28vs.71%29.aspx).
Quote
So for storing reading/writing files, and in general you mean it's FASTER that way ? If I were to bench both methods one would be significantly faster ? Remember I am not entering any coding competition, so I would use what I know about and what works, but if one method is significantly faster than the other I would definitely use that.The speed difference if used properly is about the same. Arrays are as low level as you can get. Vector on the other hand is class, which has some memory overhead, but it usually is as fast as an array. But vectors are dynamic, and so when you use it for a dynamic array instead of coding special routines for your own custom array, then it's probably going to be faster. Those containers are also not really used for reading or writing files. Your char array was used for that? Because you will have to use other specific functions to actually write to files, that are not tied to containers the data is stored in.
Quote
How would it know WHEN to free the memory ? Only at exit ? What if I wanted it to free earlier ?It's freed at the end of scope. If you create a vector inside the function, then it is freed when the function ends. If it's inside main(){}, then it's freed when the program ends. You can always delete the contents of a vector via vector.clear().
Quote
Do I have to use std::, I see that a lot in code, can't I just use using namespace std; ?You can use the latter. But it's usually a good coding convention not to pollute namespace with "using namespace", because if it's used in a header, then you effectively make everything in std namespace. That can cause conflicts and hard to find bugs, like the one we had in ENIGMA a few months ago. ENIGMA would not compile a game, because LGM showed an error in valid code, and it took like 3 weeks to fix that. Turned out Robert had included namespace in a header, and it broke LGM. If you want to use only something specific, like vectors, then you can write "using std::vector;". This will allow you not put std in front of vector, but nothing else will be changed.
Quote
I thought it was the opposite, that malloc and free are used in C, and that new and delete are C++.Correct, my mistake. But what I wanted to say is that you would almost never need to use them. Even in the ABS situation I had, I could of used smart pointers (which is basically wrapping a pointer around a class so it can automatically be destroyed when not in use). Using these things in a modern code is not that great of a practice and while many would disagree, I personally don't like it. I had so many problems with them, then it has scarred me for life.
Quote
But I see pointers, new and delete used in many places in ENIGMA's sourceThose are in underlying resource structures and in some hack'd classes, like "variant". In most decent code (like the graphics systems) they are not much used.
563
Developing ENIGMA / Re: Android
« on: July 24, 2014, 04:43:24 am »
I think it should be now possible to compile without Java boilerplate. Just like the link Rusky gave mentions. You can use GCC directly to compile for android.
564
Programming Help / Re: C++ short delay when using CIN
« on: July 24, 2014, 04:28:47 am »
1) Yes, memory is freed at the end of the program if it either crashes or if you didn't free the resources. It's done by C++ runtime (in MinGW case it's libstdc++.dll). It sometimes won't release resource handles though, so if you open a file, but don't close it, then it's possible that over time you won't be able to open new files, as the maximum open files at once has a limit per process. At least it did have a limit in the past. This freeing of memory is true for most devices and OS's. Only some embedded stuff still doesn't do it explicitly.
2) To get size you can use sizeof(). So sizeof(resMem) will return the number of bytes used. It's the same as doing sizeof(char)*5000. Note that you won't be able to use sizeof(array) way in functions, because if you pass the array via function parameter, then it's treated as a pointer. So it will return the size of the pointer, not the array.
3) For dynamic arrays (or actually arrays in general) you should use stl::containers. There is very little use in using the old C arrays anymore. The containers are fast, very optimized and releases you of many stupid tasks. Like freeing the memory, as it's done automatically. In your array case I would suggest using a std::vector. So you could write this instead:
So pointers and "new"+"delete" is the bain of C. In C++ there are very few cases you actually have to use them. The biggest thing I have written for myself in pure C++ is 10k line program for research purpose and it only used pointers in about 3 places, because of Abstract Base Class (ABS) usage.
2) To get size you can use sizeof(). So sizeof(resMem) will return the number of bytes used. It's the same as doing sizeof(char)*5000. Note that you won't be able to use sizeof(array) way in functions, because if you pass the array via function parameter, then it's treated as a pointer. So it will return the size of the pointer, not the array.
3) For dynamic arrays (or actually arrays in general) you should use stl::containers. There is very little use in using the old C arrays anymore. The containers are fast, very optimized and releases you of many stupid tasks. Like freeing the memory, as it's done automatically. In your array case I would suggest using a std::vector. So you could write this instead:
Code: (edl) [Select]
#include <vector>
//in main(){}
std::vector<char> resMem(5000,'a'); //This will create a 5000 element vector of chars (filled with char 'a' specificly)
//Use regular semantics to modify and access them like this
resMem[0] = 'b';
resMem[4999] = 'c';
//You can get size of array
printf("resMem size is %i and in bytes = %i\n", resMem.size(), sizeof(resMem));
//When calculating size in bytes you would have to take vector.capacity() into account as well, but I won't go into that here
//You can add elements
resMem.push_back('d');
//Now resMem.size() is 5001.
So pointers and "new"+"delete" is the bain of C. In C++ there are very few cases you actually have to use them. The biggest thing I have written for myself in pure C++ is 10k line program for research purpose and it only used pointers in about 3 places, because of Abstract Base Class (ABS) usage.
565
General ENIGMA / Re: Fun with imge_single
« on: July 23, 2014, 09:05:46 am »
I think the only way this will be in ENIGMA is if it's somehow done in the GM5 compatibility extension. But seeing as this modifies quite deep engine stuff, I guess it might be impossible now, as we have problems with extensions not being able to add very down to the metal stuff (like path_start, which has been a pain for some time now).
566
Proposals / Re: Modifying the way we select objects
« on: July 23, 2014, 03:58:18 am »
I'm for it. Though there need to be an option to create and object on top of another object as well. So maybe adding another button (alt?) to 1).
567
Developing ENIGMA / Re: Android
« on: July 22, 2014, 05:46:37 am »Quote
there are specific functions that need to be added, virtual keys, in app advertising, tilt and other mobile/tablet specific features, and of course the apps would have to be signed/app store compliant.None of which is actually required to run a game on android. I was thinking what is ESSENTIAL for it to compile and run.
edit: I think the hello-gl2 example is the one that should be taken as a starting point in creating a window, rendering context and drawing. For me the only thing required is for it to create these things. Then I am willing to code drawing functions to work (which involves changing the GL3 shader to run in GLES2.0).
568
Developing ENIGMA / Re: Android
« on: July 21, 2014, 03:49:34 pm »
He probably wants to get the dropbox in the settings panel working now. For Android to work he would have to redo the whole "ENIGMAsystem\SHELL\Platforms\Android" folder together with getting "ENIGMAsystem\SHELL\Graphics_Systems\OpenGLES" to work. I think GLES could actually be a smaller issue now, as GL3 graphics system should work as GLES with very little changes.
So the hard part is to get AndroidNDK working. It should be easier now that it was 3 years ago, because then you actually needed SDK (Java) and NDK (native, or C++) as they were separate. As far as I know now the SDK actually allows C++ to be compiled.
So the hard part is to get AndroidNDK working. It should be easier now that it was 3 years ago, because then you actually needed SDK (Java) and NDK (native, or C++) as they were separate. As far as I know now the SDK actually allows C++ to be compiled.
569
General ENIGMA / Re: Indentation Styles
« on: July 21, 2014, 04:55:47 am »
I also like tabs a lot. I don't get the "width" issue though, because it doesn't matter if a tab is 1cm or 5cm. The code will still be indented properly. So I haven't had any problems with that, but I rarely use linux, so I don't know if they have problems there or now. I haven't had any problems in Code::Blocks, Notepad++, VS and Wordpad. Works flawlessly everywhere. So it's seems to be a linux issue.
edit: I personally use https://en.wikipedia.org/wiki/Indent_style#Kernel_style and https://en.wikipedia.org/wiki/Indent_style#Variant:_1TBS . More the 1TBS.
edit: I personally use https://en.wikipedia.org/wiki/Indent_style#Kernel_style and https://en.wikipedia.org/wiki/Indent_style#Variant:_1TBS . More the 1TBS.
570
Off-Topic / Re: Religious wars in the programming community
« on: July 21, 2014, 04:29:47 am »
Damn that was a long post about nothing. Dark, you should really reread what I wrote. IN NO PLACE, SHAPE OR FORM, did I make an offense or a derogatory statement about you. I was talking about your statements in regard to science on how it's inability to answer your questions is somehow a cause for belief in god. I was just pointing out that it's not really the case, because not having an answer isn't the same as having the wrong one. So the fact that science, less than 200 years after it's inception (or at least stricter formulation), cannot answer questions about the whole universe - questions, I might add, all religions got wrong for thousands of years - isn't a reason to think science is in any shape or form wrong. It's also not valid to think those questions are somehow beyond science, like god is. So the whole point of my post was to point out the fallacy you made. I did say "religious people" in general as well, because that really is a fallacy many people with similar beliefs make. I didn't say that to offend you or to "put you "all" in the same bucket", just the contrary, I wanted to convey the idea that you aren't alone in that thought. So I wanted you not to feel like it was somehow a personal affront, as many people are thinking the same.
tl;dr - Science in 200 years have done, proved, identified and discovered more than anything in thousands of years before it (even religions), so not having answers to all questions in the whole universe doesn't show lack of ability in science, it just shows the scope of the universe.
tl;dr - Science in 200 years have done, proved, identified and discovered more than anything in thousands of years before it (even religions), so not having answers to all questions in the whole universe doesn't show lack of ability in science, it just shows the scope of the universe.
Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 »