Does anyone know how to set up SFML in NetBeans for C++ on Windows 7? I found this - [url]http://trevoke.net/blog/2009/03/08/howto-sfml-with-netbeans/[/url] - but it's for Linux, and I'm not sure which package to download, if the process can even be applied here.
[QUOTE=redonkulous;27460276]Anyone have a good tutorial for making a Socket server in C++? I have made servers in Java so I know generally how they work, I just need something that explains the C++ methods and stuff. Everything I have found via Google either doesn't even work, or just gives me uncommented source code I can't even begin to dissect.[/QUOTE]
beejz guide to network programming
its pretty useful
I'm currently playing around P/Invoke, to see how wrappers work, etc. I took GWEN as a base c++ library. Some methods are passing wchar_t's as arguments, or other c++ strange types. I'm importing the function using
[csharp]
[DllInvoke("gwen.dll")]
extern void Msg([MarshalAs(UnmanagedType.LPWStr)]string str);
[/csharp]
is [MarshalAs(UnmanagedType.LPWStr)] the right way to convert str to a wchar_t ?
[editline]e[/editline] And is [MarshalAs()] the right thing to do at all ?
[QUOTE=PiXeN;27462168]I'm currently playing around P/Invoke, to see how wrappers work, etc. I took GWEN as a base c++ library. Some methods are passing wchar_t's as arguments, or other c++ strange types. I'm importing the function using
[csharp]
[DllInvoke("gwen.dll")]
extern void Msg([MarshalAs(UnmanagedType.LPWStr)]string str);
[/csharp]
is [MarshalAs(UnmanagedType.LPWStr)] the right way to convert str to a wchar_t ?
[editline]e[/editline] And is [MarshalAs()] the right thing to do at all ?[/QUOTE]
If it's wchar_t* (pointer to a [b]w[/b]ide [b]char[/b]acter [b]t[/b]ype), then yes, LPWStr ([b]l[/b]ong [b]p[/b]ointer to a [b]w[/b]ide [b]str[/b]ing) is the correct type.
Ok, thanks.
Also, I'm seeing methods like this : Msg(const wchar_t* str,...)
What are those three dots for ? Not really informed on all this c++ witchcraft
[QUOTE=PiXeN;27462327]Ok, thanks.
Also, I'm seeing methods like this : Msg(const wchar_t* str,...)
What are those three dots for ? Not really informed on all this c++ witchcraft[/QUOTE]
... means it's a varargs function (a meaning similar to lua's ...), which means it can take any number of extra arguments. It doesn't know how many it gets, but it uses the format string it gets passed to determine that. Also note that varargs functions are called with the cdecl calling convention (caller cleans the stack), because only the caller knows for certain how many arguments it passed.
I need to write some information from a remote client to a file on a server, I'm using python as the client and PHP as the server and I'm wondering how I would go about doing that. (Let's say the server is managed, not a VPS)
What I thought of doing is using HTTP/Post and then using the PHP page that gets called when the python client posts writing the sent data into a linear text-based data file. Does this sound like a viable plan?
-snip wrong thread-
Can someone point me to a good C++ complier? The one I got with this book does not work with Windows 7.
[QUOTE=The Great Ghast;27512039]Can someone point me to a good C++ complier? The one I got with this book does not work with Windows 7.[/QUOTE]
Visual C++ has become the de facto standard for compiling C++ on Windows.
[url]http://www.microsoft.com/express/Downloads/[/url]
[QUOTE=yakahughes;27512093]Visual C++ has become the de facto standard for compiling C++ on Windows.
[url]http://www.microsoft.com/express/Downloads/[/url][/QUOTE]
Thank you very much my good sir.
Oh god how do I use boost::multi_arrays? I declared it like this: boost::multi_array<char, 2> maparray; but I can't resize it: maparray.resize(boost::extents[posx][posy]);
[editline]18th January 2011[/editline]
Also what does assert do?
I don't remember boost::multi_array usage well enough to be able to answer the first part of your question directly, but assert() basically means "if this condition is ever false, raise a big red flag during debugging because it's definitely a bug in the code". (It's not appropriate for checking for runtime errors, such as invalid input.)
[QUOTE=Wyzard;27513904]I don't remember boost::multi_array usage well enough to be able to answer the first part of your question directly, but assert() basically means "if this condition is ever false, raise a big red flag during debugging because it's definitely a bug in the code". (It's not appropriate for checking for runtime errors, such as invalid input.)[/QUOTE]
So it's for debugging? I see.
Yes, and if you define a macro named "NDEBUG" when compiling (e.g. with a "-DNDEBUG" option to gcc), assert() becomes an empty macro so that the calls to it are completely removed from the compiled program.
So the basics of assert() are:
[list]
[*]In a debug build, an assert failure does something highly noticeable, typically terminating the program immediately, to help you notice that there's a bug.
[*]In a release build, an assert failure does nothing at all, to give the program a chance to at least maybe recover from the problem, so that it doesn't appear unstable to the user.
[/list]
Yeah, so I need some help with Java and Graphics.
We are learning Java in school and use NetBeans drag and drop to make the Gui, but if I try to make a Graphics object to draw on (Both images and simple lines/squares etc) it only works as long as no other window is moved in front of the application and it's not resized:
[IMG]http://i53.tinypic.com/29bndwy.jpg[/IMG]
[IMG]http://i54.tinypic.com/2h37iw8.jpg[/IMG]
The only code I used is:
Graphics g = jPanel1.getGraphics();
g.draw*whatever*...
Some beginner tips would be greatly appreciated, so don't use too long and complicated words :v:
[QUOTE=Zyx;27516843]Yeah, so I need some help with Java and Graphics.
We are learning Java in school and use NetBeans drag and drop to make the Gui, but if I try to make a Graphics object to draw on (Both images and simple lines/squares etc) it only works as long as no other window is moved in front of the application and it's not resized:
The only code I used is:
Graphics g = jPanel1.getGraphics();
g.draw*whatever*...
Some beginner tips would be greatly appreciated, so don't use too long and complicated words :v:[/QUOTE]
Most likely you're only telling it to paint once in the code.
If you put the drawing code inside the onPaint/paint (whatever it's called in java) method for the form, then you can simply call the invalidate() method to make it repaint (i.e call it every 33 milliseconds or something)
Sorry I can't be more specific, but I'm no good with Java
Pseudocode:
[code]MyForm.OnPaint() {
drawSquare();
}
MyTimer.OnTick() {
MyForm.invalidate();
}[/code]
Where MyForm is your form and MyTimer is some sort of timer object that fires the OnTick event at a specified interval.
I'm trying to initialize D3D. Why does this give me errors:
[code]
...
const unsigned int SCREEN_WIDTH = 1024;
...
DXGI_SWAP_CHAIN_DESC scd;
scd.BufferDesc.Width = SCREEN_WIDTH;
...
[/code]
Do I need to do something before I describe the swap chain?
Errors:
[code]
1>------ Build started: Project: Lab02-Transformationer, Configuration: Debug Win32 ------
1> Winmain.cpp
1>c:\users\michael\desktop\3dprogrammering\lab02-transformationer\winmain.cpp(21): error C2143: syntax error : missing ';' before '.'
1>c:\users\michael\desktop\3dprogrammering\lab02-transformationer\winmain.cpp(21): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\michael\desktop\3dprogrammering\lab02-transformationer\winmain.cpp(21): error C2371: 'scd' : redefinition; different basic types
1> c:\users\michael\desktop\3dprogrammering\lab02-transformationer\winmain.cpp(20) : see declaration of 'scd'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
[/code]
[img]http://dl.dropbox.com/u/2014606/wtf_noise.png[/img]
What am I looking at here?
It is part of a noise program I just made, though I ask what is the problem here?
[csharp]
private void Generate()
{
int[,] items = null;
int[,] oldItems = null;
for (int x = 0; x < 10; x++)
{
int size = (int)Math.Pow(2, x);
items = new int[size, size];
if (x != 0)
{
for (int y = 0; y < Math.Pow(2, x - 1); y++)
{
for (int z = 0; z < Math.Pow(2, x - 1); z++)
{
items[y * 2, z * 2] = oldItems[y, z];
}
}
}
for (int y = 0; y < size; y++)
{
for (int z = 0; z < size; z++)
{
if (items[y, z] == 0)
{
int avarage = 0;
int count = 0;
if (y > 0)
{
avarage += items[y - 1, z];
count++;
}
if (y < size - 1)
{
avarage += items[y + 1, z];
count++;
}
if (y > 0 && z > 0)
{
avarage += items[y - 1, z - 1];
count++;
}
if (y > 0 && z < size - 1)
{
avarage += items[y - 1, z + 1];
count++;
}
if (y < size - 1 && z > 0)
{
avarage += items[y + 1, z - 1];
count++;
}
if (y < size - 1 && z < size - 1)
{
avarage += items[y + 1, z + 1];
count++;
}
if (z > 0)
{
avarage += items[y, z - 1];
count++;
}
if (z < size - 1)
{
avarage += items[y, z + 1];
count++;
}
if (count > 0)
{
avarage = avarage / count;
avarage += rand.Next(-20, 20);
items[y, z] = avarage;
}
}
}
}
oldItems = items;
}
Bitmap img = new Bitmap(512, 512);
for (int x = 0; x < 512; x++)
{
for (int y = 0; y < 512; y++)
{
int value = Clamp(items[x, y], 0, 255);
img.SetPixel(x, y, Color.FromArgb(value, value, value));
}
}
pictureBox1.Image = img;
pictureBox1.Refresh();
}
int Clamp(int value, int max, int min)
{
if (value > max)
{
return max;
}
if (value < min)
{
return min;
}
return value;
}
[/csharp]
Also excuse the code, it is 1:30am over here.
(This is in C++) How do I convert a char array to a float value? I'm trying to extract a decimal number from a human-readable text file and convert it to a float value to be used mathmatically.
I am trying to program some graphics testing in Java, and I have some .png's with transparent backgrounds that I am redering with a Graphics2D object. No matter what I try they always seem to be rendered with white where the transparency should be.
For source-to-source compilation, what would be the best approach?
Compiling down to a byte-codish representation, and then back up to the target language, or just producing code in the target language straight from the AST?
[QUOTE=Venice Queen;27539219]For source-to-source compilation, what would be the best approach?
Compiling down to a byte-codish representation, and then back up to the target language, or just producing code in the target language straight from the AST?[/QUOTE]
I would use an intermediate language (byte-code or [url=http://www.cminusminus.org]C--[/url])
Hey guys, I'm getting an access violation for my map, I don't understand why though, I thought the code I had produced would cover not trying to access chunks that don't exist, but it's still crashing from trying to access chunks that don't exist, I just don't understand where...
The max size of the map is 16 tiles, so the array is defined as Chunk Chunks[15][15].
[cpp]
void Render(int x, int y)
{
// Make sure we have an actual zone we're in
if(CurrentZone != 0)
{
// Make sure we aren't on a tile that doesn't exist
if((x) >= 0 || (x) <= 15 || (y) >= 0 || (y) <= 15)
{
// Make sure all the tiles above us exist
if((y-1) >= 0 || (y-1) <= 15)
{
if((x-1) >= 0 || (x-1) <= 15) Render(CurrentZone->Chunks[x-1][y-1], x-1, y-1);
Render(CurrentZone->Chunks[x][y-1], x, y-1);
if((x+1) >= 0 || (x+1) <= 15) Render(CurrentZone->Chunks[x+1][y-1], x+1, y-1);
}
// Render our Middle Area
if((x-1) >= 0 || (x-1) <= 15) Render(CurrentZone->Chunks[x-1][y], x-1, y);
Render(CurrentZone->Chunks[x][y], x, y);
if((x+1) >= 0 || (x+1) <= 15) Render(CurrentZone->Chunks[x+1][y], x+1, y);
// Make sure out Bottom Row exists
if((y+1) >= 0 || (y+1) <= 15)
{
if((x-1) >= 0 || (x-1) <= 15) Render(CurrentZone->Chunks[x-1][y+1], x-1, y+1);
Render(CurrentZone->Chunks[x][y+1], x, y+1);
if((x+1) >= 0 || (x+1) <= 15) Render(CurrentZone->Chunks[x+1][y+1], x+1, y+1);
}
}
}
}
[/cpp]
[cpp]if((x) >= 0 || (x) <= 15 || (y) >= 0 || (y) <= 15)[/cpp]
should be
[cpp]if(x >= 0 && x <= 15 && y >= 0 && y <= 15)[/cpp]
Actually... just change all the || to &&. Otherwise the condition will be true even if only one of them is true.
Sorry, you need to Log In to post a reply to this thread.