c++

Setting a view frustum to enclose another frustum

Given the 8 corners of a camera's view frustum and the desired view direction of a light source (defined as a vector), what is a good way to calculate the view projection matrix of a light so that it encloses the camera's entire frustum? The purpose of this is to have a light that dynamically updates position so that the shadow map it pr...

STL vector taking up too much memory

Im using a STL vector in my SDL program. and it looks like this: vector< Bullet * > vec; this makes a vector that can contain pointers to Bullet objects. when i run my program i only add one item at a time using: vec.push_back( new_bullet ); (new_bullet is a pointer to a "new" Bullet object. then in a following function i erase an object...

Communicate between c++ applications and web applications

What are the various ways I can achieve communication (like function calls) from a web application to a c++ application? I've developed the c++ application to do image processing and want to display and transmit the result in real time to a web-page displayed on a browser. ...

Reading a process memory

I'm trying to read the process memory of a console program using ReadProcessMemory() API function. Updated Code: HWND hWnd = FindWindow(NULL, "Read Memory Window"); DWORD ProcessId; ProcessId = GetProcessId(hWnd); GetWindowThreadProcessId(hWnd, &ProcessId); HANDLE hProcess = OpenProcess(PROCESS_VM_READ,FALSE, Proce...

how to add many strings in c++

As I know that C++ only allows to add 2 strings together, i.e: s = s1 + s2 But I want to be able to add many strings together like: s = s1 + s2 + s3 + s4 + .... + sn How could I solve this problem? Can anybody help? Thanks. ...

C++ template syntax question: No specialization needed (template<>)

Hi, I was reading the STL source code (which turned out to be both fun and very useful), and I came across this kind of thing //file backwards/auto_ptr.h, but also found on many others. template<typename _Tp> class auto_ptr //Questio...

C++ - Checking for 3 in a row

I've got this 3 x 3 array of char that's supposed to represent a tic-tac-toe board, and before, I would use a bunch of "if" statements to see if there were 3 in a row. ... if ((board[0][0] == board[0][1]) && (board[0][1] == board[0][2])) { ... } ... I realized that this is a lot of typing, and quite error-prone, so is th...

Saving PNG images

I'm having trouble saving png images. I want to add some binary data into the png file, such as the following structure. struct Foo { int value; char str[10]; double val; double val2; }; It seems to save just fine with the following code. However, when I later load up the png file, I see that my chunk has not be...

Can I make a rather native C++ app with Android?

I'm interested in the following features: Writing an app for Android Market that is written completely in C++ (a port of existing product actually). Use fast screen-buffer pixel pushing (or rather using OpenGL ES for this). Grab user input and direct it to C++ code. Is it legal to write such an app for Market? Is Market policy someho...

Creating a unique, auto assigned variable with Microsofts Extensible Storage Engine

I'm using Extensible Storage Engine and want a unique column (32bits wide). I need the values in this column to be auto assigned by the database I'm hoping to find something like JET_bitIndexUnique that I can mask in? if there isnt such a mask whats the proper way to achieve the goal? ...

SendMessage Always returns ZERO ?

Why does Windows SendMessage() always return ZERO, even the message delivery is success? Is there anyway to check the message delivery failure with SendMessage() ? EDIT Forgot to mention that I'm using SendMessage() inside a c++ DLL LRESULT result = ::SendMessage(hwndOtherWindow,WM_COPYDATA, NULL/*(WPARAM)this->GetSafeHwnd()*/,(LPARAM...

Undefined/Unspecified/Implementation-defined behaviour warnings?

Can't a compiler warn (even better if it throws errors) when it notices a statement with undefined/unspecified/implementation-defined behaviour? Probably to flag a statement as error, the standard should say so, but it can warn the coder at least. Is there any technical difficulties in implementing such an option? Or is it merely imposs...

sorting vector with 3D points by a coordinate value -- syntax

hi, I want to sort points_vec vector as shown in the pseudocode below. I want to sort this vector, by a coordinate value like x or y or z class A{ std:vector<double*> points_vec; void doSomething(); } Then, in method A::doSomething, I want sort this vector: void A::doSomething() { std::sort(points_vec.begin(), points_ve...

mmap-loadable data structure library for C++ (or C)

I have a some large data structure (N > 10,000) that usually only needs to be created once (at runtime), and can be reused many times afterwards, but it needs to be loaded very quickly. (It is used for user input processing on iPhoneOS.) mmap-ing a file seems to be the best choice. Are there any data structure libraries for C++ (or C)?...

Class constructed only on stack; not with new. C++

Is there a way to create a class Foo so that I can do: Foo foo; but not Foo* foo = new Foo(); ? I don't want people to be able to allocate copies of Foo on the heap. Thanks! EDIT: Sorry, I was wrong on the "stack only, not heap". What I want to say is "can not use new operator". ...

measuring response time through packets?

good day! im developing an app in c++ and winpcap that will list all the URL accessed in the browser with its corresponding response time.. currently, i can now track or monitor all accessed url through capturing and analyzing packets.. is there any way of measuring the response time of a web page to load, from the request made to the se...

C++ Portable way of programmatically finding the executable root directory

Possible Duplicate: how to find the location of the executable in C Hi, I am looking for a portable way to find the root directory of a program (in C++). For instance, under Linux, a user could copy code to /opt, add it to the PATH, then execute it: cp -r my_special_code /opt/ export PATH=${PATH}:/opt/my_special_code/ cd /ho...

Tracking HDC from injected process

Hi, I'm facing quite a dilemma. I've injected my DLL into other process as well as hooked few WinAPI calls from there, ExtTextOutW@GDI32, DrawTextExW@GDI32 and AlphaBlend@Msimg32 to be specific. Now, the problem is that when the other application writes something with those two GDI32 functions, i don't know the exact location where it c...

checking if a point is already in a vector/list -- performance

hi This is related to this question I have a vector of points that will, for instance, store 100K+ points. std::vector<Point> point_vec; I want to check if a position (x, y, z) to be added is already in point_vec (represented by an instance of class Point ). The following function will check this (in a for loop) bool samePoints(...

Return an array in c++

Suppose I have an array int arr[] = {...}; arr = function(arr); I have the function as int& function(int arr[]) { //rest of the code return arr; } What mistake am I making over here?? ...