c++

How to draw a filled envelop like a cone on OpenGL (using GLUT)?

Hi, I am relatively new to OpenGL programming...currently involved in a project that uses freeglut for opengl rendering... I need to draw an envelop looking like a cone (2D) that has to be filled with some color and some transparency applied. Is the freeglut toolkit equipped with such an inbuilt functionality to draw filled geometries...

What is std::safe_string?

An answer to one of my questions included the following line of code: label = std::safe_string(name); // label is a std::string The intent seems to be a wrapper around a string literal (so presumably no allocation takes place). I've never heard of safe_string and neither, apparently, has google (nor could I find it in the 98 standard)...

Relative performance of std::vector vs. std::list vs. std::slist?

For a simple linked list in which random access to list elements is not a requirement, are there any significant advantages (performance or otherwise) to using std::list instead of std::vector? If backwards traversal is required, would it be more efficient to use std::slist and reverse() the list prior to iterating over its elements? ...

Big number in C++

Hey! I am trying to place a big number in a C++ variable. The number is 600851475143 I tried unsigned long long int but got an error saying it the constant was too big. I then tried a bigInt library called BigInt -> http://mattmccutchen.net/bigint/ The problem is I can't compile the code as I get many errors regarding the lib. undefi...

Where can I learn more about pthreads ?

I am asked to work on a piece of code which relies heavily on pthreads. So many calls are made to this library that I know nothing of. I have learnt the basics of pthread and have tried out a few examples like creating joining etc. but dont know the depths of it. I have learnt much of it using http://www.yolinux.com/TUTORIALS/LinuxTuto...

Can a C compiler rearrange stack variables?

I have worked on projects for embedded systems in the past where we have rearranged the order of declaration of stack variables to decrease the size of the resulting executable. For instance, if we had: void func() { char c; int i; short s; ... We would reorder this to be: void func() { int i; short s; ch...

C++ RTTI Viable Examples

I am familiar with C++ RTTI, and find the concept interesting. Still there exist a lot of more ways to abuse it than to use it correctly (the RTTI-switch dread comes to mind). As a developer, I found (and used) only two viable uses for it (more exactly, one and a half). Could you share some of the ways RTTI is a viable solution to a pr...

Static or dynamic linking the CRT, MFC, ATL, etc.

Back in the 90s when I first started out with MFC I used to dynamically link my apps and shipped the relevant MFC DLLs. This caused me a few issues (DLL hell!) and I switched to statically linking instead - not just for MFC, but for the CRT and ATL. Other than larger EXE files, statically linking has never caused me any problems at all...

What's a quick way to trace the entry and exit of functions in a Visual Studio 2005 c++ multithreaded program?

I have intermittent crashes occurring in my ActiveMQ libraries due to the way I'm using the activemq-cpp API. It'd be much easier to debug the issue if I could observe every function being called leading up to the crash. Are there any quick ways to trace the entry and exit of functions in a Visual Studio 2005 c++ multithreaded program?...

Is Python and pygame a good way to learn SDL?

If I want to move to C++ and SDL in the future, is Python and pygame a good way to learn SDL? ...

C++ performance of accessing member variables versus local variables

Is it more efficient for a class to access member variables or local variables? For example, suppose you have a (callback) method whose sole responsibility is to receive data, perform calculations on it, then pass it off to other classes. Performance-wise, would it make more sense to have a list of member variables that the method popula...

Events in C++

I'm not sure how to look for this online... I think they might be called something different in C++ I want to have a simple event system, somthing like event myCustomEvent; myCustomEvent.subscribe( void myHandler(string) ); myCustomEvent.fire("a custom argument"); // myHandler prints out the string passed in the first argument event ...

Visio & UML - Showing pointers in attributes and return values

I have the requirement of generating UML Diagrams for one of my C++ assignments. I'm using Visio 2007 and I'm having trouble representing C++ pointers. I've found a way to add a suffix to Datatypes however it's rather time consuming to do this for every pointer used or returned in my program. Basically I'm trying to get -object1 : Obje...

IDirectInputDevice8 Keyboard hook

We have a 3D application that retrieves keyboard presses via the IDirectInputDevice8. Is there any way, when we retrive keyboard events via the win32 API winproc loop back that we can send these commands to the DirectInputDevice? ...

Visio & UML - Showing vectors

I have the requirement of generating UML Diagrams for one of my C++ assignments. I'm using Visio 2007 and I'm having trouble representing C++ vectors. The only way I can see this working is creating a custom C++ datatype or creating a vector class in my project, then for each instance of a vector in the UML, I need to dig into the proper...

Are Thread Input queues global?

In win32, are thread input queues global to all applications? So Application A can attach itself to application B's thread input queue? ...

Is it useful to test the return of "new" in C++?

I usually never see test for new in C++ and I was wondering why. Foo *f = new Foo; // f is assumed as allocated, why usually, nobody test the return of new? ...

How to embed Ruby in C++?

What's the best way to embed Ruby as a scripting language in C++? Using ruby.h? SWIG? Something else? What I need is to expose some C++ objects to Ruby and have the Ruby interpreter evaluate scripts that access these objects. I don't care about extending Ruby or accessing it in C++. I've found this article on embedding Ruby in C++, and ...

How could I improve this code ( C++ )

Hello ! I want your suggestion on the following pseudo-code . Please suggest how could I improve it,whether or not I could use some design patterns . // i'm receiving a string containing : id operation arguments data = read(socket); tokens = tokenize(data," "); // tokenize the string based on spaces if(tokens[0] == "A") { if(to...

Approaches to creating the View for "Humble Dialogs"

I have a bunch of questions to post regarding the issue of separating the view from logic when creating a GUI. The following is a minimal example of what I would do for a simple dialog that has a label and a button using the "Humble Dialog" approach. Pressing the button should show some text on the label. I have used C++ an Qt that I am ...