Bonjour,

J'essaie depuis quelques jours de crées un namespace dans code.
Mais malgré avoir parcourue des tuto, je ne comprend pas comment les intégrer.

En effet j'ai mon code source qui est dans un .cpp et les déclaration dans un .h.
Voila mon code (ce qui sera plus simple):

.h
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
 
 
#ifdef _WIN32
#include <windows.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#ifndef __APPLE__
#include <GL/gl.h>
#include <GL/glut.h>
#else
#include <OpenGL/gl.h>
#include <GLUT/glut.h>
#endif
#include <AR/gsub.h>
#include <AR/video.h>
#include <AR/param.h>
#include <AR/ar.h>
 
//
// Camera configuration.
//
#ifdef _WIN32
char			*vconf = "Data\\WDM_camera_flipV.xml";
#else
char			*vconf = "";
#endif
 
 
 
 
namespace simple {
 
 
int             xsize, ysize;
int             thresh = 100;
int             count = 0;
 
char           *cparam_name    = "Data/camera_para.dat";
ARParam         cparam;
 
char           *patt_name      = "Data/patt.hiro";
int             patt_id;
double          patt_width     = 80.0;
double          patt_center[2] = {0.0, 0.0};
double          patt_trans[3][4];
 
int go(int argc, char **argv);
static void   init(void);
static void   cleanup(void);
static void   keyEvent( unsigned char key, int x, int y);
static void   mainLoop(void);
static void   draw( void );
}
.cpp
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#include "simple.h"
 
 
int simple::go(int argc, char **argv)
{
	printf("%d",patt_id);
	glutInit(&argc, argv);
	init();
 
    arVideoCapStart();
    argMainLoop( NULL, keyEvent, mainLoop );
	return (0);
}
 
static void   simple::keyEvent( unsigned char key, int x, int y)
{
    /* quit if the ESC key is pressed */
    if( key == 0x1b ) {
        printf("*** %f (frame/sec)\n", (double)count/arUtilTimer());
        cleanup();
        exit(0);
    }
}
 
/* main loop */
static void simple::mainLoop(void)
{
    ARUint8         *dataPtr;
    ARMarkerInfo    *marker_info;
    int             marker_num;
    int             j, k;
 
    /* grab a vide frame */
    if( (dataPtr = (ARUint8 *)arVideoGetImage()) == NULL ) {
        arUtilSleep(2);
        return;
    }
    if( count == 0 ) arUtilTimerReset();
    count++;
 
    argDrawMode2D();
    argDispImage( dataPtr, 0,0 );
 
    /* detect the markers in the video frame */
    if( arDetectMarker(dataPtr, thresh, &marker_info, &marker_num) < 0 ) {
        cleanup();
        exit(0);
    }
 
    arVideoCapNext();
 
    /* check for object visibility */
    k = -1;
    for( j = 0; j < marker_num; j++ ) {
        if( patt_id == marker_info[j].id ) {
            if( k == -1 ) k = j;
            else if( marker_info[k].cf < marker_info[j].cf ) k = j;
        }
    }
    if( k == -1 ) {
        argSwapBuffers();
        return;
    }
 
    /* get the transformation between the marker and the real camera */
    arGetTransMat(&marker_info[k], patt_center, patt_width, patt_trans);
	printf("%f %f\n",patt_trans[1][1],patt_trans[1][2]);
    draw();
 
    argSwapBuffers();
}
 
static void simple::init( void )
{
    ARParam  wparam;
 
    /* open the video path */
    if( arVideoOpen( vconf ) < 0 ) exit(0);
    /* find the size of the window */
    if( arVideoInqSize(&xsize, &ysize) < 0 ) exit(0);
    printf("Image size (x,y) = (%d,%d)\n", xsize, ysize);
 
    /* set the initial camera parameters */
    if( arParamLoad(cparam_name, 1, &wparam) < 0 ) {
        printf("Camera parameter load error !!\n");
        exit(0);
    }
    arParamChangeSize( &wparam, xsize, ysize, &cparam );
    arInitCparam( &cparam );
    printf("*** Camera Parameter ***\n");
    arParamDisp( &cparam );
 
    if( (patt_id=arLoadPatt(patt_name)) < 0 ) {
        printf("pattern load error !!\n");
        exit(0);
    }
 
    /* open the graphics window */
    argInit( &cparam, 1.0, 0, 0, 0, 0 );
}
 
/* cleanup function called when program exits */
static void simple::cleanup(void)
{
    arVideoCapStop();
    arVideoClose();
    argCleanup();
}
 
static void simple::draw( void )
{
    double    gl_para[16];
    GLfloat   mat_ambient[]     = {0.0, 0.0, 1.0, 1.0};
    GLfloat   mat_flash[]       = {0.0, 0.0, 1.0, 1.0};
    GLfloat   mat_flash_shiny[] = {50.0};
    GLfloat   light_position[]  = {100.0,-200.0,200.0,0.0};
    GLfloat   ambi[]            = {0.1, 0.1, 0.1, 0.1};
    GLfloat   lightZeroColor[]  = {0.9, 0.9, 0.9, 0.1};
 
    argDrawMode3D();
    argDraw3dCamera( 0, 0 );
    glClearDepth( 1.0 );
    glClear(GL_DEPTH_BUFFER_BIT);
    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_LEQUAL);
 
    /* load the camera transformation matrix */
    argConvGlpara(patt_trans, gl_para);
    glMatrixMode(GL_MODELVIEW);
    glLoadMatrixd( gl_para );
 
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);
    glLightfv(GL_LIGHT0, GL_POSITION, light_position);
    glLightfv(GL_LIGHT0, GL_AMBIENT, ambi);
    glLightfv(GL_LIGHT0, GL_DIFFUSE, lightZeroColor);
    glMaterialfv(GL_FRONT, GL_SPECULAR, mat_flash);
    glMaterialfv(GL_FRONT, GL_SHININESS, mat_flash_shiny);	
    glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
    glMatrixMode(GL_MODELVIEW);
    glTranslatef( 0.0, 0.0, 25.0 );
    glutSolidCube(50.0);
    glDisable( GL_LIGHTING );
 
    glDisable( GL_DEPTH_TEST );
}

Mais voila, j'obtiens l'erreur de compil suivante:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
------ Build started: Project: simple, Configuration: Debug Win32 ------
Build started 13/05/2010 15:21:24.
ClCompile:
  simpleTest.c
c:\dev\ra\ra\simple\include\simple.h(31): error C2061: syntax error : identifier 'simple'
c:\dev\ra\ra\simple\include\simple.h(31): error C2059: syntax error : ';'
c:\dev\ra\ra\simple\include\simple.h(31): error C2449: found '{' at file scope (missing function header?)
c:\dev\ra\ra\simple\include\simple.h(53): error C2059: syntax error : '}'
c:\dev\artoolkit\examples\simple\simpletest.c(15): error C2143: syntax error : missing '{' before ':'
c:\dev\artoolkit\examples\simple\simpletest.c(15): error C2059: syntax error : ':'
c:\dev\artoolkit\examples\simple\simpletest.c(26): error C2143: syntax error : missing '{' before ':'
c:\dev\artoolkit\examples\simple\simpletest.c(26): error C2059: syntax error : ':'
c:\dev\artoolkit\examples\simple\simpletest.c(73): error C2143: syntax error : missing '{' before ':'
c:\dev\artoolkit\examples\simple\simpletest.c(73): error C2059: syntax error : ':'
c:\dev\artoolkit\examples\simple\simpletest.c(103): error C2143: syntax error : missing '{' before ':'
c:\dev\artoolkit\examples\simple\simpletest.c(103): error C2059: syntax error : ':'
c:\dev\artoolkit\examples\simple\simpletest.c(110): error C2143: syntax error : missing '{' before ':'
c:\dev\artoolkit\examples\simple\simpletest.c(110): error C2059: syntax error : ':'
 
Build FAILED.
 
Time Elapsed 00:00:02.10
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
ce que je ne comprend pas du tout car j'ai suivit les tuto. Pourriez vous m'orianter sur mon erreur?
Merci d'avance pour votre aide.