Fonction locale dans api wizzard

jfk20004 Messages postés 39 Date d'inscription mercredi 25 août 2004 Statut Membre Dernière intervention 13 novembre 2004 - 11 nov. 2004 à 20:57
jfk20004 Messages postés 39 Date d'inscription mercredi 25 août 2004 Statut Membre Dernière intervention 13 novembre 2004 - 13 nov. 2004 à 11:07
JFK,
J'utilise une api wizzard.exe de windows:
Là où il y a ecrit //code TODO:j'ai insere mon code:
prob:erreur:local definition of fonction not valid
Qu'est ce qu'une definition locale de fonction et comment resoudre le prob?

c'est un prog de raytrace:est ce que l'api wizzard est adpatée pour gerer le graphisme.Y a t il un autre moyen?

11 réponses

BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019
11 nov. 2004 à 21:10
C'est d'un wizzard MFC (et non Windows) dont tu parles je pense.

ciao...
BruNews, MVP VC++
0
jfk20004 Messages postés 39 Date d'inscription mercredi 25 août 2004 Statut Membre Dernière intervention 13 novembre 2004
11 nov. 2004 à 22:32
JFK
oui non , je croyais que MFC c'etait justement windows!
Peux tu m'eclairer 8-) .
Le prob est de faire tourner un prog de raytrace avec un l'environement le plus simple sous windows...
Je dois prendre quoi???
0
BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019
11 nov. 2004 à 22:39
Avant de penser a raytrace ou quoi que ce soit, faut d'abord apprendre l'interface graphique Win.
Prends Petzold, suis bien et refais tous ses exemples, ensuite devrait aller mieux.
http://brunews.free.fr/brunews/download/CP5.zip
http://brunews.free.fr/brunews/download/CP5Sources.zip

ciao...
BruNews, MVP VC++
0
jfk20004 Messages postés 39 Date d'inscription mercredi 25 août 2004 Statut Membre Dernière intervention 13 novembre 2004
12 nov. 2004 à 09:53
JFK

le prob est que les ex qui sont donnés je les comprends et je ne vais pas passer ma vie à les refaire d'autant que ça ne me sert
à rien :il y a toujours une phase de transition qui est difficile à
gerer c'est pour ça que je viens sur un forum pour aller au delà des exemples et autres tuto qui t'aident generalement pas!!!! :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :( :(
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
ymca2003 Messages postés 2070 Date d'inscription mardi 22 avril 2003 Statut Membre Dernière intervention 3 juillet 2006 7
12 nov. 2004 à 10:37
une fonction locale, c'est un fct dans un autre :
int fct1()
{
int fctloc()
{
return 12;
}
}

ce qui n'est pas valide

pour t'aider, il faudrait un min de code à l'endroit de l'erreur
0
jfk20004 Messages postés 39 Date d'inscription mercredi 25 août 2004 Statut Membre Dernière intervention 13 novembre 2004
12 nov. 2004 à 13:16
JFKvoilà le code en question:
MERCI DE TON AIDE
:big) :big) :big) :big) :big)
il ya 4 unresolved external pour les 4 fonctions :
init();
hitsphere();
draw();
main();

#include "stdafx.h"
#include "raywin.h"

#include "MainFrm.h"
#include "raywinDoc.h"
#include "raywinView.h"

#include "Raytrace.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CRaywinApp

BEGIN_MESSAGE_MAP(CRaywinApp, CWinApp)
//{{AFX_MSG_MAP(CRaywinApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
// Standard file based document commands
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CRaywinApp construction

CRaywinApp::CRaywinApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance

bool init(char* inputName, scene &myScene) {
int nbMat, nbSphere, nbLight;
int i;
ifstream sceneFile(inputName);
if (!sceneFile)
return false;
sceneFile >> myScene.sizex >> myScene.sizey;
sceneFile >> nbMat >> nbSphere >> nbLight ;
myScene.matTab.resize(nbMat);
myScene.sphTab.resize(nbSphere);
myScene.lgtTab.resize(nbLight);
for (i=0; i<nbMat; ++i)
sceneFile >> myScene.matTab[i];
for (i=0; i<nbSphere; ++i)
sceneFile >> myScene.sphTab[i];
for (i=0; i<nbLight; ++i)
sceneFile >> myScene.lgtTab[i];
return true;
}

bool hitSphere(const ray &r, const sphere& s, float &t) {
// intersection rayon/sphere
vecteur dist = s.pos - r.start;
float B = r.dir * dist;
float D = B*B - dist * dist + s.size * s.size;
if (D < 0.0f) return false;
float t0 = B - sqrtf(D);
float t1 = B + sqrtf(D);
bool retvalue = false;
if ((t0 > 0.1f ) && (t0 < t)) {
t = t0;
retvalue = true;
}
if ((t1 > 0.1f ) && (t1 < t)) {
t = t1;
retvalue = true;
}
return retvalue;
}

bool draw(char* outputName, scene &myScene) {
ofstream imageFile(outputName,ios_base::binary);
if (!imageFile)
return false;

// Ajout du header TGA
imageFile.put(0).put(0);
imageFile.put(2); /* RGB non compresse */
imageFile.put(0).put(0);
imageFile.put(0).put(0);
imageFile.put(0);
imageFile.put(0).put(0); /* origine X */
imageFile.put(0).put(0); /* origine Y */
imageFile.put((myScene.sizex & 0x00FF)).put((myScene.sizex & 0xFF00) / 256);
imageFile.put((myScene.sizey & 0x00FF)).put((myScene.sizey & 0xFF00) / 256);
imageFile.put(24); /* 24 bit bitmap */
imageFile.put(0);
// fin du header TGA

// balayage
for (int y = 0; y < myScene.sizey; ++y) {
for (int x = 0 ; x < myScene.sizex; ++x) { float red 0, green 0, blue = 0;
float coef = 1.0f;
int level = 0;

// lancer de rayon
ray viewRay = { {float(x), float(y), -10000.0f}, { 0.0f, 0.0f, 1.0f}};
do {
// recherche de l'intersection la plus proche
float t = 20000.0f;
int currentSphere=-1;
for (unsigned int i = 0; i < myScene.sphTab.size() ; ++i) {
if (hitSphere(viewRay, myScene.sphTab[i], t)) {
currentSphere = i;
}
}
if (currentSphere == -1)
break;
point newStart = viewRay.start + t * viewRay.dir;

// la normale au point d'intersection
vecteur n = newStart - myScene.sphTab[currentSphere].pos;
float temp = n * n;
if (temp == 0.0f)
break;
temp = 1.0f / sqrtf(temp);
n = temp * n;

material currentMat = myScene.matTab[myScene.sphTab[currentSphere].material];

// calcul de la valeur d'éclairement au point
for (unsigned int j = 0; j < myScene.lgtTab.size() ; ++j) {
light current = myScene.lgtTab[j];
vecteur dist = current.pos - newStart;
if ( n * dist <= 0.0f )
continue;
float t = sqrtf(dist * dist);
if ( t <= 0.0f )
continue;
ray lightRay;
lightRay.start = newStart;
lightRay.dir = (1/t) * dist;

// calcul des ombres
bool inShadow = false;
for (unsigned int i = 0; i < myScene.sphTab.size() ; ++i) {
if (hitSphere(lightRay, myScene.sphTab[i], t)) {
inShadow = true;
break;
}
}
if (!inShadow) {
// lambert
float lambert = (lightRay.dir * n) * coef;
red += lambert * current.red * currentMat.red;
green += lambert * current.green * currentMat.green;
blue += lambert * current.blue * currentMat.blue;
}
}

// on itére sur la prochaine reflexion
coef *= currentMat.reflection;
float reflet = 2.0f * (viewRay.dir * n);
viewRay.start = newStart;
viewRay.dir = viewRay.dir - reflet * n;
level++;
} while ((coef > 0.0f) && (level < 10));
imageFile.put(min(blue*255.0f,255.0f)).put(min(green*255.0f, 255.0f)).put(min(red*255.0f, 255.0f));
}
}
return true;
}

int main(int argc, char* argv[]) {
if (argc < 3)
return -1;
scene myScene;
if (!init(argv[1], myScene))
return -1;
if (!draw(argv[2], myScene))
return -1;

return 0;

}

}

/////////////////////////////////////////////////////////////////////////////
// The one and only CRaywinApp object

CRaywinApp theApp;

/////////////////////////////////////////////////////////////////////////////
// CRaywinApp initialization

BOOL CRaywinApp::InitInstance()
{
AfxEnableControlContainer();

// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.

#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif

// Change the registry key under which our settings are stored.
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization.
SetRegistryKey(_T("Local AppWizard-Generated Applications"));

LoadStdProfileSettings(); // Load standard INI file options (including MRU)

// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.

CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CRaywinDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CRaywinView));
AddDocTemplate(pDocTemplate);

// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);

// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;

// The one and only window has been initialized, so show and update it.
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();

return TRUE;
}

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
CAboutDlg();

// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA

// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL

// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
// No message handlers
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

// App command to run the dialog
void CRaywinApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}

/////////////////////////////////////////////////////////////////////////////
// CRaywinApp message handlers
0
ymca2003 Messages postés 2070 Date d'inscription mardi 22 avril 2003 Statut Membre Dernière intervention 3 juillet 2006 7
12 nov. 2004 à 14:01
Pourquoi t'as mis tous le code (main y compris) dans le TODO du constructeur ????

Ce qu'il faut c'est créer un projet VIDE, créer un fichier source et y mettre le code dedans et non pas créer le squelette d'une appli MFC et de coller le code au premier TODO trouvé.
0
ymca2003 Messages postés 2070 Date d'inscription mardi 22 avril 2003 Statut Membre Dernière intervention 3 juillet 2006 7
12 nov. 2004 à 15:04
Petite précision :
il faut créer un projet Win32 console (main).
si tu fait un projet Win32 normal sans console, le point d'entrée sera WinMain au lieu de main.
0
jfk20004 Messages postés 39 Date d'inscription mercredi 25 août 2004 Statut Membre Dernière intervention 13 novembre 2004
12 nov. 2004 à 16:25
JFK
prob brunew me dit que justememtn pour le graphisme il ne faut pas utiliser de win console!!!

j'ai mis mon code parce qu'il y a ecrit apres toto :inserer son code!
es tu sur qu'une win32 console supprote le passege en mode graphique
0
ymca2003 Messages postés 2070 Date d'inscription mardi 22 avril 2003 Statut Membre Dernière intervention 3 juillet 2006 7
12 nov. 2004 à 16:41
j'ai dit console car dans le code que tu ajoute j'ai vu un 'main' et pas 'WinMain'.

dans un prog console, tu peut très bien créer des fenêtres mais si tu n'as pas besoin de la console , il faut faire directement une apli Win32 standard (ça dépend de ce que tu veux faire).

en ce qui concerne les todo en MFC, il y a en a un peu partout mais il faut savoir quand même ce que lon fait.
0
jfk20004 Messages postés 39 Date d'inscription mercredi 25 août 2004 Statut Membre Dernière intervention 13 novembre 2004
13 nov. 2004 à 11:07
JFK
brunew m'a donné ses tutos qui fonctionne avec win32 app
:est ce que tu penses que mon code peut fonctionner avec.
à l'originr ce bout de code est livré "brut" où avec une version gtk.
J'essaie de l'implementer sous windows.à termes,je veux implementer des bout de code de povra sous windows.
0
Rejoignez-nous