c++

Use stl vectors to manage opengl buffer objects

I don't think I am the first one to think about this ... but would it be possible to write a STL allocator that manages VRAM/Buffer Objects(BO) in OpenGL? As a result of this Question I currently use vectors to write to and read from BOs. Additionally i use some templating to map BOs as almost anything i like. Like this: TypedBufferO...

How to create static background image in OpenGL(GLUT) scene?

I create some scene, and i would like to display some static background image, which would not change from how and what I am doing with the scene. ...

How to allocate a memory with execute permissions ?

I want to allocate a memory with execute permissions. So I use mprotect to change the permissions.. To get a page aligned memory I use a valloc function. void * temp = (void *) valloc(x); and then if( mprotect(temp, BLOCK_SIZE, (PROT_READ | PROT_WRITE |PROT_EXEC))) { exit(-1); } Now I want to add more memory to this allocated bl...

Can I exhaust stack?

I know that by using operator new() I can exhaust memory and I know how to protect myself against such a case, but can I exhaust memory by creating objects on stack? And if yes, how can I check if object creation was succesful? Thank you. ...

c++ web services client library

I'm writing a native c++ application that needs to grab information from a web service. What is the recommended library/libraries to handle this in c++? I cannot use .NET for this. ...

cannot open output file debug\serbest.exe: Permission denied

I compile a Qt program with C++; I got this error message: cannot open output file debug\serbest.exe: Permission denied collect2: ld returned 1 exit status what are these command's meaning? What to do for get out of the errors? ...

C++: Print out enum value as text

If i have an enum like this enum Errors {ErrorA=0, ErrorB, ErrorC}; Then i want to print out to console Errors anError = ErrorA; cout<<anError;/// 0 will be printed but what i want is the text "ErrorA", can i do it without using if/switch? And what is your solution for this? ...

Distributed random on cluster

I need a deterministic random number generator that maintains some sort of distribution (e.g. uniform or normal) that works over a cluster. Boost::Random fulfils most of these requirements. Is there any way I can use it in a cluster while maintaining the distribution? If there was an efficent way to advance the the number generator thi...

How to overload operator-> on a "generating" iterator?

I'm defining an iterator type that does not store its current value explicitly. Instead, it's a wrapper around another iterator, and returns std::pairs of the underlying iterator's values and another value. The relevant part of the class definition: class MyIterator : public std::iterator<input_iterator, std::pair<Foo *, Bar *> > { ...

Code in header files will always be inlined?

I just had a discussion with a coworker concerning code in header files: He says that code defined in header files will always be inlined by the compiler (like the code from the function GetNumber() in my example header). I say it will be inlined sometimes, whenever the compiler decides to do so. So which one of us has to bring a cake t...

Fast infoset or .net binary compression open source libraries

Hi, are there open source libraries implementing the fast infoset or the .net binary compression format? I'd need them for C, C++ and C# (including support for the .net framework, I'm not sure it natively supports the binary compression). The final goal is that of compressing xml files with a fast algorithm available for a wide range of...

std::stringstream bugs?

I've got my own DLL which is being injected into another process. From the other process, the DLL sends IPC messages via boost::message_queue to my application. I'm using std::stringstream to construct the messages, as following: class Client { ... private: template &lt;class T> void AddMessageParameter(const T &m) ...

Strange crash with SQLite when finalizing a statement

I'm writing a C++ test app with SQLite, for which I made a small wrapper. I'm repeatedly reading some data with it, and the fourth time I do, when finalizing the statement, it crashes. I'm sure I'm matching each prepared statement with a finalize. The 4th time, before the crash, the data has ben read successfully. One curious thing: I...

Which is the fastest decoder for jpeg full-scale decoding?

Which is the fastest decoder for jpeg full-scale decoding ? I want to accelerate my apps' jpeg decoding speed, how can I do this? I am using libjpeg now, it is a bit slow, is there any one faster than libjpeg? I do not need partical decoding. Many thanks! ...

C++ statement analysis

I am seeing a code where in the program it is creating a hash_map: // Create a hash_map hm3 with the // allocator of hash_map hm1 hash_map <MyStr, MyInt>::allocator_type hm1_Alloc; hm1_Alloc = hm1.get_allocator( ); hash_map <MyStr, MyInt, hash_compare <MyStr, less_str > > hm3( hash_compare <MyStr, less_str > (), hm1_Allo...

c functions on strings

here is code to copy input string to buffer question is how make such that code show me result on output? code #include <stdio.h> #include <iostream> using namespace std; using std::memset; using std::cout; using std::endl; void foo(char *s){ char buf[15]; memset(buf,0,sizeof(buf)); strncat(buf,s,sizeof(buf)-1); c...

Inheritance and pointers to pointers: why doesn't it work and how do I get around it?

Why do I get a compilation error when I call a base-class function with a pointer to a pointer to an inherited class? Example: class cFoo {}; class cBar : public cFoo {}; void func1(cFoo *) {} // base class void func2(cFoo **) {} // base class void main(void) { cBar bar, *pbar; // inherited class func1(&bar); // compiles ...

Using Wide Character Constants with clang Gets "extraneous characters in wide character constant ignored" Error

I recently decided to switch to clang from gcc and I’m getting the following warning for my use of wide character constants: "extraneous characters in wide character constant ignored". Here is the code that gets the warning: wstring& line; … for (wstring::iterator ch = line.begin(); ch != line.end(); ++ch) switch (*ch) { cas...

Extract a tar.xz in C/C++

I am writing a program that downloads tar.xz files from a server and extracts them in a certain place. I am struggling to find a away of extracting the tar.xz file in the certain place. I am using Qt so a more Qt-way of doing it would be useful, but I don't really mind. ...

HALF_PTR Windows data type

The VS documentation states Half the size of a pointer. Use within a structure that contains a pointer and two small fields. What, exactly, is this type and how is it used, if ever? ...