Sign in to follow this  
Daos

friend function

Recommended Posts

how can i call the LoadGLTextures() from within friend function?

class CTexture  
{
public:
	
	CTexture();
	virtual ~CTexture();
    GLuint texture[2];   
friend bool COpenGL::init(HDC hdc,GLint colorBits,GLint depthBits,CTexture& texture);	



private:
   AUX_RGBImageRec* LoadBMP(const char* const fileName);
    int LoadGLTextures();


};

i tryed :texture.LoadGLTexture() but i'm given the error:
error C2653: 'COpenGL' : is not a class or namespace name





[Edited by - Daos on August 17, 2004 7:10:19 AM]

Share this post


Link to post
Share on other sites
How does your call look now? It should be something like texture.LoadGLTextures() (if texture is an object of type CTexture.)
It looks like you're just calling LoadGLTextures(), which won't work since it's a member function of another class.

Share this post


Link to post
Share on other sites
I have "OpenGL " header included in "Texture" class header

but the presence of

friend bool COpenGL::init(HDC hdc,GLint colorBits,GLint depthBits,CTexture& texture);
/*doesn't seem allright.Have any idea why?instead when i declare */
friend class COpenGL;
/* it compiles without errors*/

/*I don't wont to make CTexture class visible for all COpenGL class*/


Share this post


Link to post
Share on other sites
Quote:
error C2653: 'COpenGL' : is not a class or namespace name


It seems COpenGL is not defined. Just make sure you define COpenGL BEFORE CTexture (example: #include "COpenGL.h" just before class CTexture).

If you want further help, you'll have to post more of your code. It's impossible to help you better since you didn't post enough of it.

Share this post


Link to post
Share on other sites
Code ,code code,enybody wants code....here it is!

COpenGL class.............



#include"Texture.h"

class COpenGL
{
public:
COpenGL();
virtual ~COpenGL();


public:
void end();
void begin();
bool setViewPort(GLint wid, GLint hgt);
bool init(HDC hdc,GLint colorBits,GLint depthBits,CTexture& texture);

HDC hDC;
HGLRC hRC;
HWND hWnd;
HINSTANCE hInstance;
bool keys[256];
bool fullscreen;
bool active;

private:
bool setRenderContext();
bool setPixelFormat(GLint colorBits,GLint depthBits);
};





CTexture class...........



#include"OpenGL.h"


class CTexture
{
public:

CTexture();
virtual ~CTexture();
GLuint texture[2];
friend bool COpenGL::init(HDC hdc,GLint colorBits,GLint depthBits);
//friend class COpenGL;



private:
AUX_RGBImageRec* LoadBMP(const char* const fileName);
int LoadGLTextures();


};





ERROR:
f:\visualc++\myprojects\firstgame\opengl.h(26) : error C2061: syntax error : identifier 'CTexture'



Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this