Preprocessor

http://www.cprogramming.com/tutorial/cpreprocessor.html

#define [identifier name] [value]

LNK2019: Unresolved external symbol [C++ importing C headers]

The problem with your project is that you are using a “C” style exported library in your C++ projects. When the compiler generates mangled names for C++ functions, they are different from unmangled names generated by the C compiler and hence the C++ compiler will not be able to link with the methods imported from coredll.lib.
The solution to this problem is – while including the header windbase_edb.h, you can explicitly tell the compiler that all functions included from this header are “C” style functions by changing your inclusion as below.
extern “C”
{
 #include <windbase_edb.h>
}

With this the C++ compiler when includes the declarations from the windbase_edb.h file, it does not do any name mangling for the functions declared in this file, and thus you should be able to link to EDB without any problems now.

C++ Pointer to Pointer

Let me surmarise what all those dereferencing are,

  • ppInt is the ptr-to-ptr, we will never modify this because if we do, we lose our grip on the pointer it is pointing to.
  • *ppInt points to the pointer, if we modify this, we are modifying the contents of this pointer which is an address, In other words, we are effectively modifying the pointer, ppInt points to.
  • **ppInt points to the pointer which in turn points to the variable. So by de-referencing twice, we get the variable.

http://www.codeproject.com/KB/cpp/PtrToPtr.aspx

A list of lists in C++

list<RiverNode> riverEthan;
list<RiverNode>::iterator it;
list<list<RiverNode> > riverOfRivers;

The 2 > operator has to be seperated by a whitespace, otherwise the compiler will take it as a >> shift right operator.

http://www.cplusplus.com/reference/stl/list/empty.html

http://bytes.com/forum/thread62117.html

Multitexturing

PFNGLMULTITEXCOORD2FARBPROC glMultiTexCoord2fARB = NULL;
PFNGLCLIENTACTIVETEXTUREARBPROC glClientActiveTextureARB = NULL;
PFNGLACTIVETEXTUREARBPROC glActiveTextureARB = NULL;
int maxTextureUnits = 0;

glMultiTexCoord2fARB = (PFNGLMULTITEXCOORD2FARBPROC) wglGetProcAddress(“glMultiTexCoord2fARB”);
glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC) wglGetProcAddress(“glActiveTextureARB”);
glClientActiveTextureARB = (PFNGLCLIENTACTIVETEXTUREARBPROC) wglGetProcAddress(“glClientActiveTextureARB”);

glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &maxTextureUnits);
cout << “!!!!!!” << maxTextureUnits << endl;

glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture[GRASS]);

glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture[SNOW]);
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB );
glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_INTERPOLATE_ARB );

glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB );
glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR );

glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE );
glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR );

glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE2_RGB_ARB, GL_PRIMARY_COLOR_ARB );
glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND2_RGB_ARB, GL_SRC_ALPHA );
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0f, 0.0f);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0f, 0.0f);

glTexCoord2f(0.0f, 0.0f);  <= similar to   glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0f, 0.0f);

OpenGL Texture

To load the texture data into memory, the texture must have dimensions of the power of 2.

For example, you can load a 64×64 texture, because 64 is equal to 2^6. Similarly, you can load a texture with the dimensions 256×256, because 256 is the same as 2^8.

OpenCV IplImage

IPL(Intel Image Processing Library) Image class.

IplImage is subclass of CvMat. IplImage support ROI(region of interest) and COI(color of interest). Most of CvMat method support ROI, and some of CvMat method support COI.
What is ROI?

region of interest.
What is COI?

color of interest.

http://doc.blueruby.mydns.jp/opencv/fr_method_index.html

C++ Pointers

Reference operator ( & )

andy = 25;
fred = andy;
ted = &andy;

Dereference operator (*)

beth = *ted;

Declaring variables of pointer types

type * name;

Drawing in OpenGL

glVertex2f(100.0f, 150.0f); defines a point at x = 100, y = 150, z = 0; this function takes only 2 parameters, z is always 0. glVertex2f can be used in special cases and won’t be used a lot unless you’re working with pseudo-2D sprites or triangles and points that always have to be constrained by the depth coordinate.

glVertex3f(100.0f, 150.0f, -25.0f); defines a point at x = 100, y = 150, z = -25.0f; this function takes 3 parameters, defining a fully 3D point in your world. This function will be used a lot to define any kind of shapes you will possibly want.

glVertex4f(100.0f, 150.0f, -25.0f, 1.0f); this is the same as glVertex3f, the only difference is in the last coordinate that specifies a scaling factor. The scaling factor is set to 1.0f by default. This won’t make a lot of use and I’m not going to explain this function in details. It can be used to make your 3D points look thicker than one pixel. I don’t want to sound pathetic but why would you want to use that functionality? (A few boring ideas creep into my mind but you’ll just have to trust me with this, we’re not going to use this function. If you’re really desperate, I recommend searching the net for it in hope that someone out there explained it).

Anyway, glVertex alone won’t draw anything on the screen, it merely defines a vertex, usually of a more complex object. To really start displaying something on the screen you will have to use two additional functions. These functions are

glBegin(int mode); and glEnd( void );

glBegin and glEnd delimit the vertices of a primitive or a group of like primitives. What this means is that everytime you want to draw a primitive on the screen you will first have to call glBegin, specifying what kind of primitive it is that you want to draw in the mode parameter of glBegin, and then list all vertices one by one (by sequentially calling glVertex) and finally call glEnd to let OpenGL know that you’re done drawing a primitive. The parameter mode of the function glBegin can be one of the following:

GL_POINTS
GL_LINES
GL_LINE_STRIP
GL_LINE_LOOP
GL_TRIANGLES
GL_TRIANGLE_STRIP
GL_TRIANGLE_FAN
GL_QUADS
GL_QUAD_STRIP
GL_POLYGON

OpenCV beta 1 Camera Capture and Save

#include <ImageFile/imagefile.h>
#include “CameraVFW/CameraVFW.h”

int main(int argc, char ** argv)
{
CameraVFW cam;
ImageBase testimage(320,240,3), testimage2(320,240,4);
cam.initialize(testimage);
cam.preview();
printf(“after preview()”);

Sleep(5000);
printf(“slept”);
cam.single_grab(&testimage2);
printf(“grabbed”);
RGBAImage dispimage(320,240);
iplMirror(testimage2,dispimage, 0);

//ImageFile::write(“c:/Temp/testimage2.jpg”, &testimage2);
ImageFile::write(“c:/Temp/testimage2.jpg”, &dispimage);

return 0;
}

Next Page »