Jump to content
  • Advertisement
Sign in to follow this  
soconne

what does this error mean?

This topic is 4769 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

E2462: 'virtual' can only be used with non-template member functions. I'm getting this error with C++ Builder for the following code

class RenderSystem
{
        friend class RenderSystemOpenGL;
public:
        virtual bool start(HDC hdc, const int width, const int height, const int bpp, const int depthBpp) = 0;
        virtual void create(const int width, const int height, const int bpp, const int depthBpp, char caption[], bool fullScreen, bool vsync) = 0;
        virtual void changeContext(HDC hdc, const int width, const int height) = 0;
        virtual void resize(const int width, const int height)=0;
        virtual void displayUpdate(float elapsedTime)=0;
        virtual void release() = 0;
        virtual void exit() = 0;
        
public:
        virtual void getVideoInfo() = 0;

public:
        virtual void setMousePosition(const int x, const int y) = 0;
        virtual void getMousePosition(int &x, int &y) = 0;

        virtual void getWorldCoordinates(const int x, const int y, double *worldX, double *worldY, double *worldZ) = 0;
        virtual void getScreenCoordinates(const double x, const double y, const double z, double *screenX, double *screenY, double *screenZ) = 0;
        virtual void getScreenData(const int x, const int y, int type, void *data) = 0;
        virtual double getWorldScaleFromScreenSpace(int pixelCount, double z) = 0;

public:
        virtual void setMatrixMode(int mode) = 0;
        virtual int getMatrixMode() = 0;

        virtual void getMatrix(float m[16]) = 0;

        virtual void pushMatrix() = 0;
        virtual void popMatrix() = 0;

        virtual void loadIdentityMatrix() = 0;
        virtual void loadMatrix(float m[16]) = 0;

        virtual void rotateMatrix(float angle, float x, float y, float z) = 0;
        virtual void translateMatrix(float x, float y, float z) = 0;
        virtual void scaleMatrix(float x, float y, float z) = 0;

        virtual void multiplyMatrix(float m[16]) = 0;

        virtual void lookAt(float x, float y, float z, float ux, float uy, float uz, float upx, float upy, float upz) = 0;

        virtual void perspectiveMatrix(float fov, float nearClip, float farClip) = 0;
        virtual void orthogonalMatrix(float left, float top, float right, float bottom, float nearClip, float farClip) = 0;
public:
        virtual void applyCamera(Camera *camera) = 0;
public:
        virtual int getFPS() = 0;
public:
        virtual void clearColor( unsigned int color ) = 0;
        virtual void clear( int clearMode ) = 0;

        virtual void setFogMode(int mode) = 0;
        virtual void setFogStart(float start) = 0;
        virtual void setFogEnd(float end) = 0;
        virtual void setFogDensity(float density) = 0;
        virtual void setFogColor(float r, float g, float b) = 0;

        virtual void setLight(int index, bool enable) = 0;
        virtual void setLightPosition(float x, float y, float z, float w) = 0;
        virtual void setLightAmbientColor(float r, float g, float b) = 0;
        virtual void setLightDiffuseColor(float r, float g, float b) = 0;
public:
        virtual void setColorMaterialState(int face, int mode) = 0;
        virtual void setMaterialState(int face, int mode, float *values) = 0;
public:
        virtual void beginPrimitiveRender(int state) = 0;
        virtual void endPrimitiveRender() = 0;
        virtual void renderVertex2(float x, float y) = 0;
        virtual void renderVertex3(float x, float y, float z) = 0;
        virtual void renderColor3(float r, float g, float b) = 0;
        virtual void renderColor4(float r, float g, float b, float a) = 0;
        virtual void renderTexCoord2(float u, float v) = 0;
        virtual void renderNormal3(float x, float y, float z) = 0;
public:
        virtual Texture *createTexture() = 0;
        virtual Texture *createTexture(char *filename, int filter=RENDERSYSTEM::LINEAR, bool clamp=false, bool compressed=false) = 0;
        virtual Texture *createTexture(Image *image, int filter=RENDERSYSTEM::LINEAR, bool clamp=false, bool compressed=false) = 0;
        virtual Texture *createTexture(unsigned char *buffer, int width, int height, int bpp, int filter=0, bool clamp=false, bool compressed=false) = 0;

        virtual void setTextureStage(int stage, bool enable=true) = 0;
        virtual void setTextureState(int paramName, int paramValue) = 0;
        virtual void setTextureState(int paramName, float *paramValue) = 0;
        virtual void setTextureState(int param0, int param1, void *param2) = 0;

        virtual void setTexture(Texture *texture) = 0;

        virtual void copyToTexture(Texture *texture) = 0;

public:
        virtual void pushRenderState(int state) = 0;
        virtual void popRenderState() = 0;

        virtual bool getRenderState(int state) = 0;
        virtual void setRenderState(int state, bool enable) = 0;
        virtual void setRenderState(int state, float *value) = 0;
        virtual void setBlendState(int blendSrc, int blendDst) = 0;
        virtual void setAlphaState(int mode, float value) = 0;
        virtual void setCullState(int mode) = 0;
public:
        virtual void beginScene( ) = 0;
        virtual void endScene( ) = 0;

public:
        virtual DataBuffer *createDataBuffer(const bool dynamic, const int size) = 0;
        virtual void bindDataBuffer(int mode, DataBuffer *buffer, int param = 0) = 0;
        virtual void renderDataBuffer(int mode, DataBuffer *indices, int count) = 0;

public:
        //virtual Shader *createShader(char *vp, char *ventry, char *fp, char *fentry) = 0;
public:
        virtual TextureReflection *createTextureReflection(int size) = 0;

};

Specifically it goes to the first line of this section
public:
        virtual Texture *createTexture() = 0;
        virtual Texture *createTexture(char *filename, int filter=RENDERSYSTEM::LINEAR, bool clamp=false, bool compressed=false) = 0;
        virtual Texture *createTexture(Image *image, int filter=RENDERSYSTEM::LINEAR, bool clamp=false, bool compressed=false) = 0;
        virtual Texture *createTexture(unsigned char *buffer, int width, int height, int bpp, int filter=0, bool clamp=false, bool compressed=false) = 0;

        virtual void setTextureStage(int stage, bool enable=true) = 0;
        virtual void setTextureState(int paramName, int paramValue) = 0;
        virtual void setTextureState(int paramName, float *paramValue) = 0;
        virtual void setTextureState(int param0, int param1, void *param2) = 0;

        virtual void setTexture(Texture *texture) = 0;

        virtual void copyToTexture(Texture *texture) = 0;

Now Texture is another abstract class that is replaced by TextureOpenGL and TextureDirectX. This was all compiling fine before a few minutes ago and now its giving me this. Any ideas ?

Share this post


Link to post
Share on other sites
Advertisement
It means what it says, you can't use virtual with templates. Are you by any chance trying to inherit this class from a templated class?

Share this post


Link to post
Share on other sites
it looks like it thinks the class definition is over, or another error above it happened to make it think that hte class definition is over and your methods are outside of a class.

Cheers
Chris

Share this post


Link to post
Share on other sites
Do you mean inherit RenderSystem from a template class? Then no, I am not. Its defined exactly how I posted it. Another class, RenderSystemOpenGL, is derived from RenderSystem though.

Share this post


Link to post
Share on other sites
What I meant was if any classes that you derive from this class is templated. Is RenderSystemOpenGL templated? That would propably produce that error.

Share this post


Link to post
Share on other sites
It's not actually anything to do with templates. This is one of the few bad error messages I've encountered from BCC. You've just forgotten to forward declare your texture class. This code snippet reproduces the problem:
// uncomment this to fix
//class Texture;

class RenderSystem
{

public:

virtual Texture * createTexture() = 0;

};

Enigma

Share this post


Link to post
Share on other sites
I never declare

class Texture;

above my RenderSystem class. I only include "Texture.h", which has the entire class declaration.

Share this post


Link to post
Share on other sites
Do you have a circular include? As in, does texture.h include the header that you're getting the error in?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!