Jump to content
  • Advertisement

ryt

Member
  • Content count

    291
  • Joined

  • Last visited

Community Reputation

295 Neutral

About ryt

  • Rank
    Member

Personal Information

  • Interests
    Programming

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Yeah, I meant that test1 is a std::string. I updated original post. Sorry for that. So actually it's dependent on overloaded operator "+", thanks.
  2. Lets say we have: std::string test2 = "some text " + test1; How C++ knows that it should use "some text " as a std::string and not as a string literal? Is it because of the overridden operator "=" or something else? Edit: test1 is also std::string.
  3. Here is some good explanation that I found:
  4. As I'm reading C++ Programming Language and some other tutorials I came on Translation Unit part. I got a bit confused how they work with classes. What is rally not clear to me is inclusion of class headers in different other files that need them. Somewhere in these tutorials I red that each time when we #include a class header, that the current translation unit has its own class. From that I understood that even if we use include guards, that different files, that include same classes, have their own definitions of classes. So for e.g. let's say that we have two classes A and B. Another two separate files Alpha and Beta, where they include both classes. A third file main.cpp that includes Alpha and Beta, but knows nothing of A and B. From what I understood is that in main.cpp we will have two definitions of A and two of B, even if A and B use include guards. Is this true or I confused something?
  5. Reading through Stroustrup C++ Programming Language I arrived at some rather strange array arithmetic (without use of pointers). He says the following: This surprised me too. How 1. a[j]==j[a] and 2. 3["Texas"]=="Texas"[3]=='a' are possible? Isn't a usually (read always) implicitly converted to T*, so how [a] could point to something meaning able? Also if array has 10 elements, than j==10, how address of 10 could point to the same thing, or it does? If somebody could explain this through assembly or memory I would really appreciate it.
  6. In almost all (read all) tutorials and books I found that when they talk about object lifetime is that they say the same thing. That is that a variable, automatic variable (declared in local scope), is created when it's definition is encountered and destroyed when its name goes out of scope. I find this to not be true. Even Stroustrup mentions this in page 167 (C++ Programming Language). Usually this variable is allocated in a stack, called stack frame. Now, I wrote a few simple c++ code examples and opened them as MASM files. From what I know they are allocated immediately when stack frame is created, that is at some offset from base stack pointer (or whatever is called), for e.g. if we have two ints, the second one is located at [BSP-8] considering 32-bit wide ints. This also makes sense since the space for all local variables needs to be set once, at function beginning, instead of being created each time a variable is declared. This would also slow the execution since several variables would have to created at separate times in a function which would use additional instructions. The thing is that I don't understand why all the textbooks mention this as explained above? It used to confuse me at the beginning until I red several lower level (asm books). If I'm wrong in any way please correct me.
  7. Last few weeks I started programming again a bit with MASM. I wanted to create some simple demo using Mode 13h but I'm struggling to create a 3d system. I was wandering if anyone knows some good tutorial/book that would explain 3d software rendering from beginning? I know that there are lot of resources out there but most of them focus on GDI and that's something I don't have interest in learning (I already did some 2d demos in it). I also know some stuff how graphics pipeline works from DirectX (shaders, stages...) but now I would like to learn how and why stuff works this way. Edit: I would prefer some newer reference that is up to date (not like Graphics Black Book from Michael Abarsh). The tutorial does not need to focus on assembly or any specific language, just to be mostly about software rendering.
  8. I've been going through this tutorial and understood it mostly except the highlighted part. The tutorial explains vpointer and vtables. Steps are as follows, vpointer hidden in first 4 bytes of the object will be fetched vTable of this class is accessed through the fetched vPointer Now from the vTable corresponding function’s address will be fetched Function will be executed from that function pointer What I don't understand is the 3rd (bold) part. How does the compiler know which function (function address) to call from its virtual table? Edit: I went through this tutorial too which explains it a bit further but the original question still holds. I guess that compiler knows how to get to specific function in vtable by some pointer indexing, like vptr+4 or something. But than how a compiler knows not to overflow and not do a vptr+12 if a +12 does not exist?
  9. Ok, I plotted every function. I can see where you were going with this through I don't understand it yet completely. Maybe I'll get to it later. @swiftcoder mentioned that you are using mod() to wrap the function back to desired range but you were not converting it to radians in the first place so I'm left a bit confused. I see that you had to bring it back because of +2 (+M*.5) but it's still not entirely clear to me. It came to my mind that when I tried to convert [0, 4] to [0, 6.28] radians I can do it with percentages too. If we say that the first part is in domain K and second in domain L, then if we have some angle A_k in domain K, we can divide it by K Lenght, that is 4. This will give us the percentage p. If we multiply L Lenght * p it will give us the same angle in domain L, that is a angle A_l in radians. Now, I know that the next calculation is wrong, but I guess that we could do something like we did before to get the same answer, try to multiply A_k * 6.28 and mod() this with K/L Lenght. This doesn't give us A_l but I'm sure that we could do something similar to arrive to it?
  10. I feel like I'm so close to understand this but somehow I'm not quite there. Could you please explain this a bit further, why do we use modulo here (@alvaro solution) for the expected value? How does that returns us to the desired range? Edit: Oh, I think I see, we just scratch the extra value, the value that got us to 8pi (4 times around the circle). Now it looks like to me that it's mandatory to use modulo after a multiplication so we could get back to transformed space, is this true?
  11. Thanks for the code snippet. Though I must say I don't understand it very well. I see that A is current location, B is the desired, M is probably the length of the circle and abs(A - B) is the distance, but I don't see why we have to add + M * .5 and that two times (second time with subtraction), use mod() and than again abs()? How I originally thought to solve the problem is to first transform it to radian space. I thought to multiply my domain x[0, 4] like x * 2pi. This would get me to [0, 25.12] which is I think not what I wanted. I think I should somehow convert [0, 4] to [0, 6.28] if I'm correct and than I'll be able to use sin(), cos() to get the distances and other things?
  12. Let's say we have another circle but this time not in radians but instead in domain [0, 4], where 0 represents beginning (like 0 rad) and 4 represents the end (like 6.28 rad), 0 and 4 are same point and 1, 2, 3 are evenly spaced between them (that is pi/2 apart). Than let's say that there are two points A and B on this circle. B is a fixed point and A tries to reach it through the shortest distance. Let's say that B = 4 and A = 3. Can we use the math we used above to find this solution for any points A and B? Would it help us if we transform this space to radians and than try to solve it? I invented this problem to see if I could apply the above logic. Maybe I went a bit of the path and the problem doesn't really need all the logic or it could really need something different. I'm not sure at this point so I wrote it.
  13. I'm confused about this one, I guess you meant to write 2pi*x = 1 or similar. Edit: Oh, I think I got it. To rewrite you meant T seconds * (1/2pi) = R radians which yields 2pi = T/R. From your first equation, T seconds * x = R radinas, if I'm correct we can conclude that multiplying some dimension (seconds here) by a constant gives us another dimension (radians in this case). I think that we get as a result radians because we explicitly multiplied with 2pi (could be pi too), but if we chose to multiply by some other constant we would get some other arbitrary space, not necessarily in radians? For e.g. multiplying by 0.01 would give us a percentage, or multiplying by some other constant would give us some other space.
  14. I came with two examples. Lets say we have to numbers, t = 3 and t = 15. These could be interpreted as times with dimension in sec. For first part, if we multiply 3 * 2pi, we get 18.84. Since pi is in radians we get 18.84 rad. This could be thought of changing the space and getting it actually in radians, something like in 3 sec we passed over 18.84 rad. For second part, if we divide 15 / 2pi, we get 2.38. Same as before this is 1/rad or if we think of t as time than it becomes sec/rad. This can be thought of how many units per some other unit, or how many sec per one rad, something like 2.38 sec in 1 rad. Another example that comes to my mind is taking a t between [-1, 1] that goes back and forth. If we multiply t * 2pi, we are getting a space in rad that corresponds to rotations [-6.28, 6.28] that go also back and forth. A rotating circle that rotates one turn in each direction. Taking the same example and dividing it instead t / 2pi, would get us [-0.15, 0.15] which would mean 0.15 in each direction per one rad.
  15. Do you maybe know some examples where we would want to multiply by 2*pi and where we would want to divide by 2*pi? What would be the effect of only using only pi instead of 2*pi? I know that the resulting value would be smaller for multiplication case and with your explanation that 1 unit would represent half rotation but I'm just asking for completeness in case I forgot something.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!