380 Posted Topics
Re: The problem is at line 14. Using that loop is an issue. It should just be: sencence[i]=sentence1[i]; Here is why. Take the sentence "The cow moved." Lets debug the code. At i=0: T isalnum=true, sentence1 is copied from 0 to i(0) into sentence, sentence="T" At i=1: h isalnum=true, sentence1 is … | |
Re: I am having trouble reading your code, but I understand the difficulty in the new system. To start a code block simply skip a line and indent by for. As such this does not work, even though as I type it it is highlighted like code, it will not show … | |
I never knew that near and far were reserved until I made a struct for bounding boxes like this: struct boundingBox { float near, far; float left,right; float top,bottom; }; Does anybody know what near and far do, because I got the error that the declaration does not declare anything. … | |
Re: The problem is (as far as I can tell) that you are getting caught by garbage cleanup of some kind. You created an A but it doesnt have a memory space (since new didnt return one) as such when the program ends the operating system tries to automatically destroy a, … | |
Re: Check out [this](http://www.cplusplus.com/reference/iostream/fstream/) site. | |
I want to test some graphics work I am doing with the Utah Teapot model. The issue is that all the data I can find on it uses bezier patches (which I have no clue how to render) does anybody know how I could get the data in a form … | |
I want to find a range of values that a valid pointer cannot achieve, but can store. Basically this is my situation: typedef struct myNumberTAG { //stuff }*myNumberHANDLE; //A bunch of functions that work with myNumberHANDLEs: ///Not Shown //Some constants const myNumberHANDLE numberOne=0x1; const myNumberHANDLE numberTwo=0x2; const myNumberHANDLE numberInfinity=0x3; const … | |
I am sorry to have to make a new thread for this, but as I cannot reply to any threads I cannot think of another easy option. Basically when I enter my message and click the submit button, a red box shows up and says "Message field required" How can … | |
I currently have the following code for a sprite struct (c-style for use in DLL): typedef struct LABglSpriteTAG { unsigned int glTexture; int w; int h; LABglColour *data; bool compiled; }*LABglSpriteHANDLE; And the following function: void LABglSpriteConvolute(LABglSpriteHANDLE spr, int w, int h, int *kernel) { size_t dim=spr->w*spr->h; LABglColour *out=new LABglColour[dim]; … | |
Re: I think that what sergent may be getting at is the idea of a more event-driven programming structure for games. I myself also made a working console snake game (I used colour, variable snake length, and extended ASCII to make it look good :P) and found that having code in … | |
Re: Can you maybe post what your iniMatrix class looks like? Also just to maybe catch any premature problems here is some sample vector of vector code: vector<vector<type> /*note the space that must be here*/> vec; vector<type> newVec;//this can be set to actually hold something; vec.push_back(newVec); vector<type> backVec=vec.back();//this will return the … | |
I am wondering how to perform a 2D image blit with openGL. I used to use SDL and it was easy, but with opengl I end up making a rectangle with texture coords that is sunk a little into the screen. Is there any way to perform a 'real' blit? … | |
Re: I would suggest debugging your code. You can then see where you go wrong. There are many mistakes regarding arrays, I would suggest you read some material on how they work. Also, your swap function does no sorting at all. In fact I don't think it even swaps the data, … | |
Re: I am not an expert, as I only recently started learning opengl myself, but from my understanding glLoadIdentity() clears the currently selected matrix. If you read through the [URL="http://www.opengl.org/sdk/docs/man/xhtml/"]OpenGL Documentation[/URL] thoroughly, you will find that OpenGL stores four matrices of data. I learnt about them from a very helpful tutorial … | |
I am working on a game making (or really just general program making, but my question applies to games) DLL for opengl. It is almost done but the collision detection is a little bit slow since it has to calculate bounding boxes for each object repeatedly. I was thinking of … | |
Re: I do not know of any resources off hand, but I used to use GML's automatic collision detection and it gave a half-decent explanations in the help files. It said that it starts by checking a bounding box defined by the most extreme points on the image. A bounding box … | |
Re: The derivative will not be a single integer, I think you want the value of the derivative at a specific point, in that case you will need to be given the point (x). Also, how are you supposed to know how long the array is if you don't pass a … | |
Re: Also shouldn't you use some kind of heuristic algorithm for making the computer play. You can do it with simple if statements and loops, or if you up for a challenge a minimax algorithm with alpha beta pruning allows for a variable AI. | |
I recently looked at [URL="http://www.songho.ca/opengl/gl_vbo.html"]this[/URL] description of VBOs and a sample implementation of them. When I ran the executable, it was significantly faster with no VBOs than with them. I don't understand why it should be slower with the VBOs than without. Can anybody explain why? | |
Re: Modularization will be key here. If you have not yet learnt functions, look them up. Then you can make your main look like this: [CODE]const int numNames=10;//this helps make the code more flexible int main() { char name[numNames][80]; for (int i=0; i<numNames; ++i)//use a loop gets(name[i]); char firstNames[numNames][80]; char lastNames[numNames][80]; … | |
Re: I haven't read all your code... but why in your record structure do you declare a bunch of string arrays of size true (1)? | |
Re: To edit you merely overwrite data usually (output the old data, input the new) to delete you usually remove the element by shifting all those after it back by one. I would suggest that an std::vector would be extremely useful in this situation. | |
Re: If sort works then you should have no trouble with sort2. In fact please delete sort2. The thing you do not seem to realize is that sort and sort2 are EXACTLY the same. Just changing the name of the parameters does not change the function. Here is an example: [CODE]void … | |
I am trying to find a bug in my new and (theoretically) improved syntax highlighter program. I have made 3 versions now and have been able to debug them all with ease. Unfortunately my debugger does not do well with std containers as it shows ALL the information they contain … | |
Re: This can be easily done with a loop: [CODE]int main() { bool exit=false; while (!exit) { //CODE HERE! //somewhere have: /* if (user_want_to_quit) exit=true; */ } return 0; }[/CODE] | |
Re: That is a lot of code! I have not read over it, but I would suggest that this should work: [CODE]int main() { time_t start=time(NULL);//get start time //TONS OF TIME CONSUMING CODE!!! time_t end=time(NULL);//get end time time_t deltatime=start-end;//this now stores how long the code took! //output? return 0; }[/CODE] | |
How exactly do you use a glConvolutionFilter2d() call? I know about convolution filters and kernels, but am not sure exactly how to implement them. Just a simple example with say... a gaussian blur, would be helpful. | |
I understand that data on computers can be compressed (I see it all the time with zip files and jpegs) but I was wondering just how compression works. Thinking it through, if you data is represented by 1s and 0s then it can be corresponded 1 to 1 with a … | |
Re: Could you post your source? It could be a silly error in the code. | |
Re: You have a fair bit of code there... could you use [ CODE ] tags to get it highlighted for us? | |
Re: I am not certain, but I do not think that [ICODE]if (opr='+',...)[/ICODE] works. I would suggest trying: [CODE]if (opr='+'||opr='-'||...)[/CODE] | |
Re: For sorting I would suggest looking up [URL="http://en.wikipedia.org/wiki/Sorting_Algorithms"]sorting algorithms[/URL]. Once an array is sorted you can use a [URL="http://en.wikipedia.org/wiki/Binary_search_algorithm"]binary search[/URL] to find an element. | |
How do you make shadows in OpenGL. I have been using the NeHe tutorials, but I do not understand their shadow lesson. Can anybody help? | |
Re: First of all, why make a modulus function. There is a pretty little operator for that in c++ (%). Also I would suggest avoiding infinite loops and relying on the system to stop your program. Instead use a boolean to wait for... what? I have no Idea what the goal … | |
Re: You did not design your functions as well as you could have. That will make it hard. A function should be a single simple task, and it should do the entire task as expected. The function RemoveSpaces() then should probably take a string and... remove all its spaces. A sample … | |
Re: I think that the best way to do this is probably through another function definition. Basically you can use your function, but also declare one like this: [CODE]DOSTUFF& Insert() { //whatever you do with no parameters }[/CODE] I am not sure if it would work, but I would think that … | |
I have the following collision detection function that checks the collision between the line defined by lstart -> lend and the triangle defined by points a,b and c with a normal of nvec. I want to know if it will work and what to put into the missing part. (it … | |
A few friends and I made a bet to see who could single-handedly (we defined that as a team of up to 10 people, all of whom must be personal friends) make the best video game over the course of two years. I am planning on making a first-person horror … | |
Re: First of all, you could save yourself some time on lines 6-10 by just using [ICODE]using namespace std;[/ICODE] Also, I assume you are trying to find the interquartile range? In that case this can be done in very simple linear time. Think about this, there are three quartiles (the points … | |
Re: Any array is just a pointer to its first value, followed by allocated memory for the remaining values. As such this will work: [CODE]int myArray[]={5,3,6,8,4,2,9,1,10,7}; int *pntrToMyArray=myArray; //at this point myArray and pntrToMyArray are exactly the same. //note also that you can pass myArray directly to a function that uses … | |
Re: I do not know much about std::sort, but it is easy enough to sort this array manually. I would suggest using an insertion sort for each student entered, since it works really fast if the array is mostly sorted. Here is a sample implementation: [CODE]//This function will sort the vector … | |
Re: I have not read all of your code, but from a quick scan I would suggest printing a space where the character used to be. | |
I have a program that dynamically allocates an array and uses it. The thing is that under certain situations this array will get infinitely long. As such I would like to know if/when the array has gotten too long and then start saving it to a file (where length will … | |
Re: A) CODE tags make your code easier to read. B) What is setYear doing?! [CODE]void Movie::setYear(int num) { while(Year < 2013)//while year < 2013 ++Year;//++year //now year will be... 2013, regardless of num? }[/CODE] Perhaps this would work better? [CODE]Movie &Movie::setYear(int year)//I am going to return this, to allow for … | |
Hello, I have been working with opengl and other graphics libraries and they all require the bits per pixel of the screen on initialization of a window. My question is, is there any way to get the system's preffered bits per pixel? or that of the monitor? | |
A friend of mine recently asked me to help debug some code. I looked through it and it was riddled all over with goto statements. I know why he uses them (he used to program mainly in assembly and batch) and I tried to explain why he should try to … | |
Re: The problem is not the col variable. It is the scores1 and scores2 variables. Basically you tried to access the member of an array (arrays are just pointers) of a variable that was not even an array. The [] operators are almost exclusively for array and array-like objects. | |
I am getting ready to write a programming competition on Tuesday (the Canadian Computing Competition) and I remember that last year it said that only standard libraries can be used. I was having trouble deciding which libraries are standard. I ended up using windows.h and when I suddenly realized that … | |
To what extent does the system endianness effect a program. I know that doing pointer assignment will be affected, and unions are too, but what about bitshift operators? Do they apply to the value, merely emulating real bitshifts, or do they apply to the bits themselves? Are there any other … | |
Re: Think about it logically. You have O(N) executions of loop N and N executions of loop M. I would think that the complexity then would be O((N^2)M) of course I do not really know much about big-O notation (I just self-taught myself it) does anybody know if O((N^2)M) is right, … |
The End.