[QUOTE=esalaka;31225870]The first part teaches to use the wrappers.
Most likely this is done so that the examples wouldn't require teaching the use of native windowing APIs or writing new examples for each platform.
The actual content obviously discusses the actual graphics API.[/QUOTE]If you can, please post that on the gamedev question too.
So you're saying that only the first part teaches to use GLUT and GLtools?
[QUOTE=TerabyteS_;31225909]If you can, please post that on the gamedev question too.[/QUOTE]
I don't have a credible source
[editline]20th July 2011[/editline]
[QUOTE=eXiv2;31225910]So you're saying that only the first part teaches to use GLUT and GLtools?[/QUOTE]
I believe only the first part teaches it [I]specifically[/I]. The actual OpenGL api is not dependent on window managers and should be exactly the same on every platform apart from windowing et cetera, handled by the wrapper libraries.
Anybody know an equivalent function of Socket.LocalEndPoint (C#) which can be used in C?
I'm using this right now:
[code]
char hostname[256];
gethostname(hostname, sizeof(hostname));
struct hostent *host = gethostbyname(hostname);
return *(unsigned int *)host->h_addr;
[/code]
Works great on Windows. Returns 192.168.0.5
However on Linux it's returning 127.0.1.1
Any ideas? :\
The IP address attached to your hostname on Linux is usually 127.0.0.1 or some other 127 address so that's working correctly as far as I can see
Well, I want it to return 192.168.0.5. My LAN IP. Is this possible with Linux? (Already googled quite a bit, can't find much at all.)
[QUOTE=ThatLuaCoder;31226318]Anybody know an equivalent function of Socket.LocalEndPoint (C#) which can be used in C?
I'm using this right now:
[code]
char hostname[256];
gethostname(hostname, sizeof(hostname));
struct hostent *host = gethostbyname(hostname);
return *(unsigned int *)host->h_addr;
[/code]
Works great on Windows. Returns 192.168.0.5
However on Linux it's returning 127.0.1.1
Any ideas? :\[/QUOTE]
hostent.h_addr is a shortcut for hostent.h_addr_list[0]. Loop through all the other addresses (h_addr_list is null-terminated) and you'll find your local address as well as the loopback address.
hostent.h_addr_list[0] is the only entry. :\
[code]
Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
s.Connect("xxx.xxx.xxx.xxx", xxxxx);
Console.WriteLine ("My local Ip Address is :" + IPAddress.Parse (((IPEndPoint)s.LocalEndPoint).Address.ToString ()));
[/code]
[quote]
My local Ip Address is:192.168.0.5
[/quote]
Works fine in Mono, there has to be an exact way to do that in C..
[QUOTE=ThatLuaCoder;31227025]hostent.h_addr_list[0] is the only entry. :\
[code]
Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
s.Connect("xxx.xxx.xxx.xxx", xxxxx);
Console.WriteLine ("My local Ip Address is :" + IPAddress.Parse (((IPEndPoint)s.LocalEndPoint).Address.ToString ()));
[/code]
Works fine in Mono, there has to be an exact way to do that in C..[/QUOTE]
The equivalent of that code would be using getsockname().
Aha, that seems to have worked! Thanks jA_cOp!
I'm messing around with 3D programming, and I wanted to create a large "city". I can easily load up a 3D model of the entire city, but that doesn't seem efficient.
I always wondered how GTA 3/Vice City/San Andreas did this. I know it used the RenderWare engine, but wasn't the entire city created in 3ds and then loaded realtime as you traveled?
What about be a good way to render a huge city? Right now I have a large model (the city) that's placed into an octree. But I don't know how to deal with view distances.
This will almost definitely sound stupid but how do I run a python file?
I'm using Visual Studio 2010 but can't find a compiler thing anywhere and I can't figure out how to run it from the Ironpython console :(
Anyone?
you should just need to install python from the website (chose the version you will be using )
and then open with.... python
[QUOTE=Drak_Thing;31227281]I'm messing around with 3D programming, and I wanted to create a large "city". I can easily load up a 3D model of the entire city, but that doesn't seem efficient.
I always wondered how GTA 3/Vice City/San Andreas did this. I know it used the RenderWare engine, but wasn't the entire city created in 3ds and then loaded realtime as you traveled?
What about be a good way to render a huge city? Right now I have a large model (the city) that's placed into an octree. But I don't know how to deal with view distances.[/QUOTE]
they use "Level of Detail" meshes. so when you're across the map from some building, it'll only render it as a single cube with a small 32x32 texture on it or something like that. When you get closer, the game will read in a higher quality LoD mesh for that object and fade the low quality one out as the high quality one fades in. There are usually a bunch of different LoD meshes for how far you are from the building. For the finer detail models, you could even stream in the entire object so as to prevent you from having a massive list of items for the entire world where most of them won't even be rendered.
[QUOTE=Richy19;31232023]you should just need to install python from the website (chose the version you will be using )
and then open with.... python[/QUOTE]
I'm using Ironpython (.net framework) and installed the plugin for that for Visual Studio
I've figured out how to run it now, but for some reason it thinks that something I entered had errors in it even though it was straight from a tutorial, so I think the plugin thing may not be working properly
what should I do?
I have never used ironpython but have you checked the version of python that the tutorial uses is the same as the version that ironPython supports?
[code]void DoSomething()
{
static int i = Cocks();
}[/code]
When does Cocks get called? On startup? On the first call to DoSomething?
[QUOTE=garry;31232310][code]void DoSomething()
{
static int i = Cocks();
}[/code]
When does Cocks get called? On startup? On the first call to DoSomething?[/QUOTE]
When the function is first called probably.
...UB?
But I think it's on the first call to DoSomething. See the spec?
I've been trying to convert some C# code into C++ for use in a spatial hashing implemention, but I've come across a little problem, the code below compiles fine without the for loop but with it, I get quite a large error, simplified down it looks like this:
[QUOTE]'std::list' : 'cellIds' is not a valid template type argument for parameter '_Ty'
1> .\GridManager.cpp(41) : see declaration of 'cellIds'
1>.\GridManager.cpp(45) : error C2440: 'initializing' : cannot convert from 'std::list<_Ty>::_Iterator<_Secure_validation>' to 'std::list<_Ty>::_Iterator<_Secure_validation>'[/QUOTE]
GetIdForObj returns a list of sf::Shapes but I'm not entirely sure that's what I'm meant to be doing, I think it should return a list of something, it's all rather confusing for me, I got the code from here: [url]https://conkerjo.wordpress.com/2009/06/13/spatial-hashing-implementation-for-fast-2d-collisions/[/url]
[cpp]
std::list<std::list<sf::Shape>> cellIds;
cellIds.push_back(GetIdForObj(shape));
for (std::list<cellIds>::iterator item = cellIds.begin(); item != cellIds.end(); ++item)
{
}
[/cpp]
The original C# looks like this:
[cpp]
List cellIds= GetIdForObj(obj);
foreach (var item in cellIds)
{
Buckets[item].Add(obj);
}
[/cpp]
Let me if know if you need any more information, and thanks for any help I get.
Hi, first post in this thread as I'm finally trying to learn C++.
I'm only on my sixth or so lesson and I'm starting pointers, and I have a couple questions about it.
Correct me if I'm wrong, but pointers appear to be (from what I understand) basically a separate memory address that you can use to reference (point) to another memory address, right?
What's the point of doing this, unless do you use it to reference to a specific portion of an array or something? (I'm still pretty hazy on arrays so might be wrong here)
I don't seem to understand how/why this is used, could someone give me a good implementation or example of this idea?
The main use for pointers in C++ is for [url=http://en.wikipedia.org/wiki/Dynamic_memory_allocation]dynamic memory allocation[/url].
The variables declared in your source code are "set in stone" at compile time, but you might need to decide [i]at runtime[/i] how big an array you need (e.g. to hold data loaded from a file) or which class (in an inheritance hierarchy) you need to create an instance of. The "new" operator in C++ lets you essentially create a new variable (or array) at runtime. That variable doesn't have an actual name in your source code, but it does have an address, which serves its unique identifier. A pointer is a variable that [i]is[/i] declared in your source code, and holds the address of some other dynamically-allocated variable that [i]isn't[/i].
Of course, pointers can also refer to variables that [i]are[/i] declared in your source code too. You can point one to a certain object in an array (as you alluded to) or to one of several independent objects (of compatible type) so that other code can just use the pointer and not have to care about which specific object it's working with. [url=http://en.wikipedia.org/wiki/Reference_%28C%2B%2B%29]References[/url] are better for this in some cases, though.
I've just started learning C#, I don't have my project open at the moment so this question isn't very specific, but;
How do you pass a variable as an argument to another class when calling a function, e.g something like:
bullet.Initialize(player.Direction)
Doesn't work, so I had to do
bullet.Initialize(new Vector2(player.direction,0))
Or something along those lines which worked perfectly but is obviously just a dodgy work around. Sorry if this doesn't make much sense.
Chaz, your first example should work as long as the type of player.Direction is the same type that bullet.Initialize() expects as an argument. If you're constructing a Vector2 from player.Direction and zero, that sounds like player2.Direction is a float, and it doesn't make any sense to pass a float to a function that expects a Vector2.
[QUOTE=Wyzard;31239987]Chaz, your first example should work as long as the type of player.Direction is the same type that bullet.Initialize() expects as an argument. If you're constructing a Vector2 from player.Direction and zero, that sounds like player2.Direction is a float, and it doesn't make any sense to pass a float to a function that expects a Vector2.[/QUOTE]
Hm, I couldn't get it to work earlier but I was probably being rather stupid somehow. How come you have to declare, say, vector2 for an argument but not what type of variable something is- Or do you?
In that scenario I had the direction as an int, but the rest is probably not quite accurate so jut ignore me :smile:
You [i]do[/i] have to declare what type a variable is — except in the cases where you can use the [url=http://msdn.microsoft.com/en-us/library/bb383973.aspx]var[/url] keyword because the compiler can determine from context what the type must be.
Int can convert automatically to float, so if your direction was an int you can pass it to the Vector2 constructor that wants floats. But there's no automatic conversion from int to Vector2 because there's no sensible way to convert one number into a coordinate of two numbers.
Think about the meaning of the values you're working with. What is that bullet.Initialize() argument supposed to represent? (Is it a position? A velocity vector?) What does player.Direction represent? (Is it a rotation angle?) Then think about how (or whether) it makes sense to convert one to the other.
If player.Direction is an angle and you need it to be a vector, you probably need to use some trigonometry to convert that angle to its corresponding X and Y values. Plugging it in directly as the X-coordinate of a vector makes no sense; that doesn't give you a vector pointing in the direction that the angle indicates.
What's the fastest and easiest way to get into c# and xna? I'd need the basics too, since I've only got mediocre programming experience in other languages.
And while I'm here, that same question for java. I've heard that c# and java are syntax brothers so it'd be easy to move between them aswell.
Hey, do any LOVE2d coders have a good tutorial to get me started making games? Most of the wiki tutorials aren't that helpful to me.
[QUOTE=coolity;31242025]Hey, do any LOVE2d coders have a good tutorial to get me started making games? Most of the wiki tutorials aren't that helpful to me.[/QUOTE]
It might help to learn a bit of actual coding first, many game libraries require the coder to be independent.
[QUOTE=coolity;31242025]Hey, do any LOVE2d coders have a good tutorial to get me started making games? Most of the wiki tutorials aren't that helpful to me.[/QUOTE]
The wiki tutorials are very helpful.
You should use luas PIL(Programming in Lua) to help you get started in Lua. Maybe you'll be the next prodigy and make Not Metroid
Sorry, you need to Log In to post a reply to this thread.