I have this little SDL/OpenGL game that I am working on. It runs great, but only on one computer. If I compile it and run it on my desktop, it just pops up a blank screen. If I run it on my netbook, it works just fine and I am able to see what I am trying to render. My question is: What could be causing these inconsistent rendering resul...
In C++ how can I determine if the program has either read-only access or read-write access to a file? I searched the boost filesystem library but I have yet to find something to help me. Right now I thinking of opening the file, trying to write inside and check for error, but that doesn't seem a very appropriate way of doing this.
Any c...
How to create timer in WinApi (C++)?
...
Hi,
I noticed that somewhere polymorphism just refer to virtual function. However, somewhere they include the function overloading and template. Later, I found there are two terms, compile time polymorphism and run-time polymorphism. Is that true?
My question is when we talked about polymorphism generally, what's the widely accepted m...
I've been trying to write a small application which will work with mysql in C++. I am using MySQL server 5.1.41 and MySQL C++ connector 1.0.5. Everything compiles fine when i write console applications, but when i try to compile windows forms application exactly the same way (same libraries, same paths, same project properties) i get thi...
Hi all, I have a program that creates a file and writes to it using ofstream. I need the program to be able to parse command line parameters later on. But for some reason, it does not create a file when I drag-and-drop a file onto the compiled executable, even if the program doesn't involve any command line parameters at all. If the exec...
Hello
I have this code
char * oldname = new char[strlen(name) + 1];
memcpy(oldname,name,strlen(name) + 1);
name = new char[strlen(oldname) + strlen(r.name) + 1];
memset(name, '\0', strlen(name));
strcat(name,oldname);
strcat(name," ");
strcat(name,r.name);
I understand that it is a no no to use memcpy and memset but I...
The C++ move constructor and move assignment operator seem like really positive things. And they can be used in situations where the copy constructor makes no sense because they don't require duplicating resources being pointed at.
But there are cases where they will bite you if you aren't careful. And this is especially relevant as I...
Is there any way to view the default functions ( e.g., default copy constructor, default assignment operator ) generated by a compiler such as VC++2008 for a class which does not define them?
...
the following code:
myQueue.enqueue('a');
myQueue.enqueue('b');
cout << myQueue.dequeue() << myQueue.dequeue();
prints "ba" to the console
while:
myQueue.enqueue('a');
myQueue.enqueue('b');
cout << myQueue.dequeue();
cout << myQueue.dequeue();
prints "ab" why is this?
It seems as though cout is calling the outermost (closest to t...
I have a problem with this bit of code:
#include <boost/multi_array.hpp>
#include <boost/array.hpp>
#include <vector>
#include <iostream>
template <typename Vec>
void foo(Vec& x, size_t N)
{
for (size_t i = 0; i < N; ++i) {
x[i] = i;
}
}
int main()
{
std::vector<double> v1(10);
foo(v1, 5);
std::cout << v1[4...
I have been able to build LLVM 2.6 (the llvm-2.6.tar.gz package) using MinGW GCC 3.4.5. I haven't tested properly, but it seems to work.
The trouble is, I have libraries of my own which don't build using GCC3, but which work fine in GCC4 (template issues). I believe the first official GCC4 version for MinGW is GCC 4.4.0.
EDIT
Declutte...
Using http://www.pelib.com/index.php
How do you open/save a pe file using PeLib? The 1 example it does have for writing a PE file is writing one from scratch, not loading an existing one, editing and saving it.
Also, anyone know of a more up to date library? PeLib works, just it is kinda old and a bit of a pain to use.
...
I'm writing a game for school in OpenGL. Since there will be several more similar assignments I want to make a small framework for doing common things in OpenGL. I have made a few simple games before and I usually break it down into an IO class to handle input and drawing to the screen, Game class for the main game loop/logic, and classe...
I need to print packaged binary data to stdout in C++. Are there any STL libraries that can accomplish this? I know perl has this functionality but I need to be able to do it in only C++. If c++ does not have this functionality can someone please guide me on how I would go about programming something like this. Thank you.
...
I know that sizeof is a compile-time calculation, but this seems odd to me: The compiler can take either a type name, or an expression (from which it deduces the type). But how do you identify a type within a class? It seems the only way is to pass an expression, which seems pretty clunky.
struct X { int x; };
int main() {
// ret...
I have some dll that implements some logic. I want to create wrapper that will be accessible from JavaScript of HTML page in Mozilla browser. I have found npruntime framework,but it seems supports only window control, i don't need GUI. I am looking for mechanism like ActiveXObject implemented in Internet Explorer.
...
Is it possible to use wxMutex->Lock() in an event handler? Since it's the main program thread (gui thread) it can't sleep right?
...
I've been googling and reading about this and didn't come up with an answer yet, maybe someone can help me with this.
I want my UserPile class to be able to access data members and class member functions from my CardPile class. I keep getting the error mention in the title. Could someone explain what is happening? The inheritance tut...
I am having trouble getting rand() to work in C++. rand() normally gives me a very large number. When I try to use the modulo operator (%) to give it a range, it always returns 0, no matter what. Seeding the random number generator at the beginning of the program doesn't help either.
...