[QUOTE=chonks;34479100]I'm learning C++ off of a book from 1997, is this going to hurt my learning of the language?[/QUOTE]
C++ was first standardized in 1998, so that book is not teaching you standard C++. If you're just using it to learn the basics you should be OK, as long as you know that most things are in the std:: namespace now. But for anything beyond introductory material, I'd recommend you find a book that was written with the standard in mind.
[QUOTE=sim642;34479507]There have been numerous new standards of C++ since 1997.[/QUOTE]
Well, two: C++98 and C++11. (There's also TR1, but that's not [i]really[/i] a standard, even though a number of compilers implemented it.)
[QUOTE=Octave;34488884]Is your server properly configured? Because if it's downloading the PHP file as a text file it's most likely an issue with your server not having php installed or something.[/QUOTE]
That would explain it, I was using dropbox.
In DirectX, I'm attempting to create a dynamically written Texture2D.
I've got it working using the following code:
[cpp]
D3D11_TEXTURE2D_DESC desc;
ZeroMemory(&desc, sizeof(D3D11_TEXTURE2D_DESC));
desc.Width = (int)size.x;
desc.Height = (int)size.y;
desc.MipLevels = 1;
desc.ArraySize = 1;
desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
//desc.Format = DXGI_FORMAT_R8G8B8A8_UINT;
desc.Usage = D3D11_USAGE_DYNAMIC;
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
desc.SampleDesc.Count = 1;
//Create it
hResult = GetRenderBackend()->m_pDevice->CreateTexture2D(&desc, NULL, &m_pTexture2D);
if(FAILED(hResult))
{
printf("CDynamicTexture2D::Failed to create ID3D11Texture2D!\n");
return;
}
[/cpp]
However, this only lets me create textures on specific widths - Any multiple of 64 will work, but if it's not a base64 width it fails to create at the m_pDevice->CreateTExture2D line.
I think it has to do with [url=http://msdn.microsoft.com/en-us/library/windows/desktop/ff476253%28v=vs.85%29.aspx]this line from the Remarks page about Texture2D's.[/url]
[quote]The device places some size restrictions (must be multiples of a minimum size) for a subsampled, block compressed, or bit-format resource.[/quote]
Unfortunately I can't figure out what setting needs to be flipped (that will still let me create the Texture2D successfully) that would solve this issue.
The feeling when you accomplish something you've been working on for hours is fucking awesome.
May not be much, but this took me like 5 hours to do.
Insert string into postfix class. Separate string, push into stack that uses a linked list. Do magic.
Had to write both the stack and the linked list as a part of the homework.
[IMG]http://i.imgur.com/hy1F2.png[/IMG]
Hey all, I'm having some confusion with c# and initialization. Say I have my main winform (form1), a Guy class, and a Bet class. The guy class has an instance of bet as a field, and the Guy sends a reference of itself to the Bet instance. So my question:
1)When you code "Guy man = new Guy(){Name = "joe"};" into Form1, does it change the name field, AND call whatever is in my Guy(){} constructor? Is there a way to write it like this?
[code]Guy man = new Guy(){Name = "joe", MyBet.Bettor = man};?[/code]
[QUOTE=DoctorSalt;34503195]Hey all, I'm having some confusion with c# and initialization. Say I have my main winform (form1), a Guy class, and a Bet class. The guy class has an instance of bet as a field, and the Guy sends a reference of itself to the Bet instance. So my question:
1)When you code "Guy man = new Guy(){Name = "joe"};" into Form1, does it change the name field, AND call whatever is in my Guy(){} constructor? Is there a way to write it like this?
[code]Guy man = new Guy(){Name = "joe", MyBet.Bettor = man};?[/code][/QUOTE]
It calls the () constructor and then changes the Name field. It is exactly like doing
[code]Guy man = new Guy();
man.Name = "joe";[/code]
Sadly you can't do that. 'man' is not actually assigned until after 'Guy' is constructed and those fields are set. So to put that in perspective, that would be like doing
[code]
Guy man;
Guy local = new Guy(){Name = "joe", MyBet.Bettor = man};
man = local;
[/code]
Does anyone have tips on AS3 performance? Like, it's very very slow. My physics engine is fantastic so I know it's not that so it must be my "blob" renderer. Does anyone have any suggestions for tips on faster rendering?
[QUOTE=Foda;34504559]Does anyone have tips on AS3 performance? Like, it's very very slow. My physics engine is fantastic so I know it's not that so it must be my "blob" renderer. Does anyone have any suggestions for tips on faster rendering?[/QUOTE]
Profile to see if that's actually the problem before you spend time 'fixing' it.
Also I hear MovieClips/Sprites can be performance hogs.
I am trying to get LOS working. Right now I am making a circle using Bresenham's circle algorithm, then I am trying to draw a line using Bresenham's line algorithm, and if it hits a solid object it stops drawing. The problem is that the lines don't hit all possible squares when the radius is high(bigger than 7 I think or if it's 2).
[img]http://dl.dropbox.com/u/8414553/yunowork.png[/img]
What should I do to make sure it hits all the untouched squares? I like this algorithm because it is really fast to compute, much faster than what I had before, however I can switch if there's no way.
Which book would you recommend if I want to learn about design patterns ? Preferably with examples in C++.
Try using something that is more like a DFS/BFS/flood-fill.
Maybe:
[code]
mark every node as unprocessed
push player's current cell onto the stack
while the stack is not empty:
pop the top cell from the stack
if distance(cell, player) > radius:
continue
if not isvisible(cell): /* using Bresenham's or ray-marching, etc. */
continue
mark cell as visible
for each neighboring cell:
if neighbor has not been processed:
mark neighbor as processed
push neighbor onto the stack
[/code]
[QUOTE=Lord Ned;34504597]Profile to see if that's actually the problem before you spend time 'fixing' it.
Also I hear MovieClips/Sprites can be performance hogs.[/QUOTE]
I'm pretty much drawing nothing as it is. I did use a profiler and it's the rendering that is taking so long. The code that I know is causing problems is this:
[code]
// clear the intermediate bmp
intermediateBMP.fillRect(new Rectangle(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT), 0xffffffff);
// render the source MC into the intermediate bmp and blur it
intermediateBMP.draw(src);
intermediateBMP.applyFilter(intermediateBMP, new Rectangle(0,0,SCREEN_WIDTH,SCREEN_HEIGHT), new Point(0,0), blurFilter); //20px lowquality
// clear the screen and threshold the intermediate bmp into it
screen.fillRect(new Rectangle(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT), 0xffffffff);
//Threshold the white so background objects get drawn
screen.threshold(intermediateBMP, new Rectangle(0,0,SCREEN_WIDTH,SCREEN_HEIGHT), new Point(0,0), "==", 255, 0x00FFFFFF, 0x00000000, false);
//Render Blobs
screen.threshold(intermediateBMP, new Rectangle(0,0,SCREEN_WIDTH,SCREEN_HEIGHT), new Point(0,0), "<", 100, 0x5500E6E6, 0x000000ff, false);
[/code]
So I downloaded that C++ Visual Studio Express Edition, I think it was, and I kind of have this problem with it...
I searched for a tutorial online on how to make an application that would open an image. Everything went great. Didn't have any problems, but there is one thing I noticed.
You know how in some programs when you start writing a word, a little box will come up beside it with a list of commands and what not that start with the letter you typed? I noticed it had that in the video tutorial I was watching, but this little box isn't coming up for me. Does anyone know how to get this box to show up? Or is it only available in the full version?
CLR = Common Language Runtime Support?
I've tried turning that off but nothing happens.
Is "Thinking in C++" Vol. 1 a good place to start learning C++?
[QUOTE=WTF Nuke;34504656]I am trying to get LOS working. Right now I am making a circle using Bresenham's circle algorithm, then I am trying to draw a line using Bresenham's line algorithm, and if it hits a solid object it stops drawing. The problem is that the lines don't hit all possible squares when the radius is high(bigger than 7 I think or if it's 2).
[img]http://dl.dropbox.com/u/8414553/yunowork.png[/img]
What should I do to make sure it hits all the untouched squares? I like this algorithm because it is really fast to compute, much faster than what I had before, however I can switch if there's no way.[/QUOTE]
Use a square instead of a circle. If you MUST have a circle, still use a square, and just stop the beams if they get too far.
I figured out a solution, get the left points of a circle, then extend them to the other side and store all the points hit. Then do normal circle calculations, still testing the outer rims of the circle and removing the points that have been hit. I'll be left points I haven't hit, so now I can just test those.
[editline]2nd February 2012[/editline]
Wait, how fast is Bresenham's line algorithm exactly? It probably wouldn't be too horrible if I had to calculate around 170 lines for a 8 radius circle, would it? Because that seems a lot easier than doing minimal line calculations and checking for duplicate points and using up lots of memory.
[QUOTE=Flubadoo;34514587]Is "Thinking in C++" Vol. 1 a good place to start learning C++?[/QUOTE]
I wouldn't recommend it for absolute beginners. It's more for people who write C++ but use all C syntax and don't understand the power of C++ features.
Does anyone here have C Programming Language (2nd Edition)?
Is it outdated now?
And what are your thoughts on it?
I wish I had a copy of K&R.
[QUOTE=ROBO_DONUT;34520343]I wish I had a copy of K&R.[/QUOTE]
So I should get it then?
Does anyone know of a good tutorial that both explains and shows how to implement Marching Cubes? I can only find either already implemented stuff with no comments or theoretical explanations and can't make sense of either of them :v:
Books would be fine too, I plan on really getting into it.
Just ordered it :eng101:
[QUOTE=evil-tedoz;34504850]Which book would you recommend if I want to learn about design patterns ? Preferably with examples in C++.[/QUOTE]
[url=http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612]Design Patterns: Elements of Reusable Object-Oriented Software[/url]
and
[url=http://www.amazon.com/First-Design-Patterns-Elisabeth-Freeman/dp/0596007124]Head First Design Patterns[/url] (Java examples though)
Both are pretty good.
is anyone here good with SFML? I am trying to implement a scrolling, but instead it just shoots my character across the screen, in the opposite direction of where I want it to scroll.
[code]sf::FloatRect screen (0,0,800,600);
sf::View view1(screen);
if(Player1.x<10)
{
view1.Move(-1,0);
window.SetView(view1);
}[/code]
First, to oppose the direction, change the -1 to a 1
Second, the game is probably looping too fast, causing the player to shoot across the screen fast
And thirdly, view1.Move() will not change the position of the player. So I would do something such as this:
[code]if(Player1.x < (view1.x + 10)) { ... [/code]
I'm setting a keyboard hook to simulate media keys. However, it's fired twice when I press Ctrl+Alt+Home once.
Here's my KeyboardProc:
[cpp]
LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam) {
if (nCode < 0) return CallNextHookEx(0, nCode, wParam, lParam);
if ((lParam & (1 << 31)) && (lParam & (1 << 30))) { //up now and down before
bool bCtrl = GetKeyState(VK_CONTROL) < 0;
bool bAlt = GetKeyState(VK_MENU) < 0;
if (bCtrl && bAlt) {
switch (wParam) {
case VK_HOME:
//SendKeyboardInput(VK_MEDIA_PLAY_PAUSE);
MessageBox(NULL, "CTRL+ALT+HOME", "Hook", MB_ICONINFORMATION);
return true;
case VK_END:
//SendKeyboardInput(VK_MEDIA_STOP);
MessageBox(NULL, "CTRL+ALT+END", "Hook", MB_ICONINFORMATION);
return true;
case VK_PRIOR:
//SendKeyboardInput(VK_MEDIA_PREV_TRACK);
MessageBox(NULL, "CTRL+ALT+PGUP", "Hook", MB_ICONINFORMATION);
return true;
case VK_NEXT:
//SendKeyboardInput(VK_MEDIA_NEXT_TRACK);
MessageBox(NULL, "CTRL+ALT+PGDN", "Hook", MB_ICONINFORMATION);
return true;
}
}
}
return CallNextHookEx(0, nCode, wParam, lParam);
}
[/cpp]
Is there any way to make sure it's only fired once?
[editline].[/editline]
Wow, that was quick.
I tried it with sending the media keys, instead of doing a message box, and it just works right. If someone can explain why it happened, that would be great, but either way, it works now.
Working on some IT coursework. It has to be written in VB6 :v:
Here's what I have so far:
[img]http://i.imgur.com/2JE8v.png[/img]
It's a Point Of Sale system for a fast food outlet. The UI's horrible so far, I'll move some stuff around and tidy it up in a bit.
The form's all laid out at runtime, and the menu is laid out dynamically using images from a directory:
[img]http://i.imgur.com/UwG8t.png[/img]
Adding a new product involves pasting a picture of it into that folder, and making sure that the filename ends in "£price" - the application handles the rest. It prints out receipts (using a regular printer) and you can also view a log that's stored in a text file:
[img]http://i.imgur.com/JWmcL.png[/img]
That bit's actually necessary to get top marks. I'm not quite sure why.
All that's left to do now is add a login form, write a 50-page writeup, print it out and mail it to the bloody exam board. Yay :v:
[editline]3rd February 2012[/editline]
Added a login form. Password details are just stored as salted MD5 hashes, but everyone else in my class is storing login details in plain text files (if not just a bunch of 'elseif username = "bob" and password = "password"'), so I think I might get away with it :S
I just started using the "Son of Obsidian" theme for visual express (c#), and my god, it is beautiful.
I just stared at my code for the last 10 minutes looking at how cool the color scheme is.
Does anyone else like their theme, if they used one?
I just started a class programming in C and C++ and I was trying to write like a super basic program and I am having problems getting the equation part of the code to execute...
[code]# include <stdio.h>
int main(void){
float celsius, fahrenheit;
printf("Please enter a temperature in degress Fahrenheit: ");
scanf("%f", &fahrenheit);
celsius = (5 / 9) * ( (float) fahrenheit - 32);
printf("The temperature of %f in degrees Celsius is %f.\n", fahrenheit, celsius);
return 0;
}
[/code]
It just gives me zeros as the answer. I'm sure it is something really simple I just have basically no experience :P Thanks!
Sorry, you need to Log In to post a reply to this thread.