Jump to content

C++ question


Raul
 Share

Recommended Posts

In order to use correctly the boom, hdr, etc effects and to render the sbx file I saw I have to use the framewerk. Looking at Marleys Ghost post I used that code and everything is working fine, but I need to make some modification:

 

I have a class (cPlayer) which I have to make it use the fw object. Also from my Main.cpp I need to access it. Where do I have to define this line:

leadwerks::Framewerk fw;

If I declare it to the start of my Main.cpp when updating my player and accessing it I receive the

error C2065: 'fw' : undeclared identifier

error

 

What should I do?

i5 2.7Ghz, GTS 450, 8GB Ram, Win7 x64; Win8 x64

rvlgames.com - my games

RVL Games Facebook Page, YouTube Channel

 

Blitzmax :)

Link to comment
Share on other sites

Two simple solutions are as follows:

 

declare fw as an extern in your player class header (not so nice)

 

pass it as a parameter to your player class constructor from your main routine

Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++

Link to comment
Share on other sites

@Lumooja: I tried to add the leadwerks::Framewerk fw; into a separate .h file and to include the file in every class and main.cpp but I receive the message "fw already declared" (or something like that)

 

You said "global fw variable. " How to do that?

 

 

@Pixel Perfect:

How exactly can I pass it?

i5 2.7Ghz, GTS 450, 8GB Ram, Win7 x64; Win8 x64

rvlgames.com - my games

RVL Games Facebook Page, YouTube Channel

 

Blitzmax :)

Link to comment
Share on other sites

// define a private member variable in your class

Framewerk* m_pFramewerk;

 

// pass a pointer to your framewerk object as a parameter to the constructor and assign it to the member variable

cPlayer::cplayer(Framework* pFramewerk)

{

m_pFramewerk= pFramewerk;

}

 

// Access the framewerk in your class via m_pFramewerk->

Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++

Link to comment
Share on other sites

@Lumooja: I tried to add the leadwerks::Framewerk fw; into a separate .h file and to include the file in every class and main.cpp but I receive the message "fw already declared" (or something like that)

You need to add the extern keyword in the .h file.

 

// fwglobal.h
#pragma once
#include "framewerk.h"
extern leadwerks::Framewerk fw;

// fwglobal.cpp
#include "fwglobal.h"
leadwerks::Framewerk fw;

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...