CGfxOpenGL.cpp: In member function `bool CGfxOpenGL::Init()':
CGfxOpenGL.cpp:62: error: expected primary-expression before '.' token
CGfxOpenGL.cpp:63: error: expected primary-expression before '.' token
CGfxOpenGL.cpp: In member function `bool CGfxOpenGL::Shutdown()':
CGfxOpenGL.cpp:76: error: expected primary-expression before '.' token
CGfxOpenGL.cpp: In member function `void CGfxOpenGL::Render()':
CGfxOpenGL.cpp:166: error: expected primary-expression before '.' token
make.exe: *** [CGfxOpenGL.o] Error 1
Execution terminated
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The errors reported in the log bear no obvious relationship to the code you posted, ther refer to an entirely different functions in a different class.
Try reading teh error messages!
For example in CGfxOpenGL.cpp at line 62 (in the CGfxOpenGL::Init() function), I reckon it is a fair bet that whatever you have before the '.' is not a primary expression! i.e. whatever the left-hand-side evaluates to is not something for which the member operator makes any sense.
Unless you post the code that the log is referring to, we cannot help you.
With respect to the m_skybox::Initialize() function:
void m_skybox::Initialize( void )
{
// function body here.
}
What kind of naming convention does m_skybox adhere too!? The prefix m_ is most often used to indicate class member variables. Why not cSkybox?
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
fread(&heightmap, TERRAIN_SIZE * TERRAIN_SIZE, 1, pFile);
fclose(pFile);
CTargaImage image;
image.Load("grass.tga");
glGenTextures(1, &m_grassTexture);
glBindTexture(GL_TEXTURE_2D, m_grassTexture);
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, image.GetWidth(), image.GetHeight(), GL_RGB, GL_UNSIGNED_BYTE, image.GetImage());
image.Release();
image.Load("water.tga");
glGenTextures(1, &m_waterTexture);
glBindTexture(GL_TEXTURE_2D, m_waterTexture);
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, image.GetWidth(), image.GetHeight(), GL_RGB, GL_UNSIGNED_BYTE, image.GetImage());
image.Release();
m_skybox.Initialize(10.0); // these are the types that i have problems declaring in the Skybox.h but i do believe that they should be defined in the CGfxOpenGL.h because of what the error log states
m_skybox.LoadTextures("up.tga", "dn.tga", "ft.tga", "bk.tga", "lt.tga", "rt.tga");
glEnable(GL_DEPTH_TEST);
glEnable(GL_TEXTURE_2D);
return true;
glLoadIdentity();
gluLookAt(cameraX, cameraY, cameraZ, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
// skybox origin should be same as camera position
m_skybox.Render(cameraX, cameraY, cameraZ);
DrawTerrain();
};
so how would i go about including these statements into the header file(s)?
should i go about renaming m_skybox.Intialize() to cSkybox.Intialize() which unsurprisinly gave me the same result.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It has been said before that you are being too ambitious. You have obviously not grasped the basics of C++.
In your code m_skybox is a (badly nemed) data type, despite being named like a variable. In that context the statement:
m_skybox.Initialize(10.0);
makes no sense, the symbol on teh left-hand-side of the dot must represent a data instance not a data type.
So for example:
m_skybox SkyboxInstance ;
SkyboxInstance.Initialise( 10.0 ) ;
Of course this begs the question of why you would not do the initialisation in a constructor so you could simply write:
m_skybox SkyboxInstance( 10.0 ) ;
Now this also highlights why your naming convention is so flawed, it even confused you, and since you are asking others to help, it will confuse them. It is named like a data member but is in fact a data type. So of course renaming it alone won't solve your problem - I never claimed it would - but flouting convention is seldom a good idea, especially whan you don't understand the convention or why it exists in the first place!
What did you intend the m_ prefix to mean!? I am guessing that you 'copied' it from somewhare else without understanding what it was for, and then subsequently misused it.
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
which makes varaibles such as Initialize(); to be declared.
idk how to declare them :(
What puzzles me is that i deleted void Render(); from what was already provided and i see that it is undeclared. so i added Init() but i got the same result of needing a declaration. Although if i keep the void Render();
it says in the error log that 'it is not a type'
CGfxOpenGL.cpp: In member function bool CGfxOpenGL::Init()':
CGfxOpenGL.cpp:60: error:Initialize' has not been declared
CGfxOpenGL.cpp:60: error: request for member of non-aggregate type before '(' token
CGfxOpenGL.cpp:61: error: `LoadTextures' has not been declared
CGfxOpenGL.cpp:61: error: request for member of non-aggregate type before '(' token
CGfxOpenGL.cpp: In member function bool CGfxOpenGL::Shutdown()':
CGfxOpenGL.cpp:74: error:Release' has not been declared
CGfxOpenGL.cpp:74: error: request for member of non-aggregate type before '(' token
CGfxOpenGL.cpp: In member function void CGfxOpenGL::Render()':
CGfxOpenGL.cpp:164: error:Render' is not a type
CGfxOpenGL.cpp:164: error: request for member of non-aggregate type before '(' token
make.exe: *** [CGfxOpenGL.o] Error 1
Execution terminated
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
that fixed the problem with Render(); not having a type.
although i am still left with the problem of Init() still needing to be defined-somehow in the CGfxOpenGL.h
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Starcreek,
You are missing the point here. OpenGL application are to complex if you dont understand the C++ language. You are having problems with simple C++ basics such as classes. Why are you so insistant on trying to make this work without knowing all the things you need to know? Why do you appear to be completely ignorant of responses back to you pointing out that you NEED MORE KNOWLEDGE. What the hell are you trying to accomplish that you can not take a little bit of time and study up on programming basics? It will only help you to do this. If you can not do that then quit wasting peoples time because you are not going to understand the answer you get anyways. Which means you will post again like you are doing here...ignoring what you have already been told and pissing off your help.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
i would really like to know how to declare m_skybox.Initialize() in the header file.
i tried having a new class with specific varaible names. So far i have
class m_skybox
{
public:
m_skybox();
virtual ~m_skybox();
void Initialize ( void );
};
// right here i would want to implement the function?
void m_skybox::Initialize( void )
int main()
{
m_skybox varaibleName;
variableName.Initialize();
}
But it just gives me the same errors that i already have. Could you help please?
Compiler: Default compiler
Building Makefile: "C:\ATimetoKill\Makefile.win"
Executing make...
make.exe -f "C:\ATimetoKill\Makefile.win" all
g++.exe -c CGfxOpenGL.cpp -o CGfxOpenGL.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" -g3 -O0
CGfxOpenGL.cpp: In member function `bool CGfxOpenGL::Init()':
CGfxOpenGL.cpp:62: error: expected primary-expression before '.' token
CGfxOpenGL.cpp:63: error: expected primary-expression before '.' token
CGfxOpenGL.cpp: In member function `bool CGfxOpenGL::Shutdown()':
CGfxOpenGL.cpp:76: error: expected primary-expression before '.' token
CGfxOpenGL.cpp: In member function `void CGfxOpenGL::Render()':
CGfxOpenGL.cpp:166: error: expected primary-expression before '.' token
make.exe: *** [CGfxOpenGL.o] Error 1
Execution terminated
I told you the answer. It seems that you still don't understand. You are a lost cause.
The errors reported in the log bear no obvious relationship to the code you posted, ther refer to an entirely different functions in a different class.
Try reading teh error messages!
For example in CGfxOpenGL.cpp at line 62 (in the CGfxOpenGL::Init() function), I reckon it is a fair bet that whatever you have before the '.' is not a primary expression! i.e. whatever the left-hand-side evaluates to is not something for which the member operator makes any sense.
Unless you post the code that the log is referring to, we cannot help you.
With respect to the m_skybox::Initialize() function:
void m_skybox::Initialize( void )
{
// function body here.
}
What kind of naming convention does m_skybox adhere too!? The prefix m_ is most often used to indicate class member variables. Why not cSkybox?
Clifford
ok i have tired many times at an attempt to what i thought would work but it hasnt.
so heres the code:
ifdef _WINDOWS
include <windows.h>
endif
include <gl/gl.h>
include <gl/glu.h>
include <math.h>
include <time.h>
include "glext.h"
include "CGfxOpenGL.h"
include <cmath>
include <cstdio>
include "CTargaImage.h"
include "Skybox.h"
pragma warning(disable:4244)
const char heightmapFilename[] = "heightmap.raw";
const float MAX_HEIGHT = 30.0f;
const float MAX_FOG_HEIGHT = MAX_HEIGHT * 0.5f;
const float SCALE_FACTOR = 256.0f / MAX_HEIGHT;
const float WATER_HEIGHT = 2.0f;
CGfxOpenGL::CGfxOpenGL()
{
m_grassTexture = m_waterTexture = 0;
cameraX = cameraY = cameraZ = 0.0f;
m_angle = 0.0;
m_height = 10.0;
}
CGfxOpenGL::~CGfxOpenGL()
{
}
bool CGfxOpenGL::Init()
{
FILE *pFile = fopen(heightmapFilename, "rb");
if(!pFile)
return false;
}
bool CGfxOpenGL::Shutdown()
{
glDeleteTextures(1, &m_waterTexture);
glDeleteTextures(1, &m_grassTexture);
}
void CGfxOpenGL::SetupProjection(int width, int height)
{
if (height == 0) // don't want a divide by zero
{
height = 1;
}
}
void CGfxOpenGL::Prepare(float dt)
{
cameraX = sin(DEG2RAD(m_angle))TERRAIN_SIZE/2.0f;
cameraY = m_height;
cameraZ = cos(DEG2RAD(m_angle))TERRAIN_SIZE/2.0f;
}
void CGfxOpenGL::DrawTerrain()
{
// draw terrain!
}
}
void CGfxOpenGL::Render()
{
glClearColor(0.0f, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
};
so how would i go about including these statements into the header file(s)?
should i go about renaming m_skybox.Intialize() to cSkybox.Intialize() which unsurprisinly gave me the same result.
It has been said before that you are being too ambitious. You have obviously not grasped the basics of C++.
In your code m_skybox is a (badly nemed) data type, despite being named like a variable. In that context the statement:
m_skybox.Initialize(10.0);
makes no sense, the symbol on teh left-hand-side of the dot must represent a data instance not a data type.
So for example:
m_skybox SkyboxInstance ;
SkyboxInstance.Initialise( 10.0 ) ;
Of course this begs the question of why you would not do the initialisation in a constructor so you could simply write:
m_skybox SkyboxInstance( 10.0 ) ;
Now this also highlights why your naming convention is so flawed, it even confused you, and since you are asking others to help, it will confuse them. It is named like a data member but is in fact a data type. So of course renaming it alone won't solve your problem - I never claimed it would - but flouting convention is seldom a good idea, especially whan you don't understand the convention or why it exists in the first place!
What did you intend the m_ prefix to mean!? I am guessing that you 'copied' it from somewhare else without understanding what it was for, and then subsequently misused it.
Clifford
ok, i threw in void Skybox in the CGfxOpenGL.h
which makes varaibles such as Initialize(); to be declared.
idk how to declare them :(
What puzzles me is that i deleted void Render(); from what was already provided and i see that it is undeclared. so i added Init() but i got the same result of needing a declaration. Although if i keep the void Render();
it says in the error log that 'it is not a type'
Error Log:
Compiler: Default compiler
Building Makefile: "C:\ATimetoKill\Makefile.win"
Executing make...
make.exe -f "C:\ATimetoKill\Makefile.win" all
g++.exe -c CGfxOpenGL.cpp -o CGfxOpenGL.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" -g3 -O0
CGfxOpenGL.cpp: In member function
bool CGfxOpenGL::Init()': CGfxOpenGL.cpp:60: error:
Initialize' has not been declaredCGfxOpenGL.cpp:60: error: request for member of non-aggregate type before '(' token
CGfxOpenGL.cpp:61: error: `LoadTextures' has not been declared
CGfxOpenGL.cpp:61: error: request for member of non-aggregate type before '(' token
CGfxOpenGL.cpp: In member function
bool CGfxOpenGL::Shutdown()': CGfxOpenGL.cpp:74: error:
Release' has not been declaredCGfxOpenGL.cpp:74: error: request for member of non-aggregate type before '(' token
CGfxOpenGL.cpp: In member function
void CGfxOpenGL::Render()': CGfxOpenGL.cpp:164: error:
Render' is not a typeCGfxOpenGL.cpp:164: error: request for member of non-aggregate type before '(' token
make.exe: *** [CGfxOpenGL.o] Error 1
Execution terminated
i was able to change the CGfxOpenGL.h file to where it read:
class Skybox;
class Skybox;
class CSkybox
{
public:
CSkybox();
~CSkybox();
protected:
unsigned int m_textures[6]; // 6 texture objects
float m_size;
};
that fixed the problem with Render(); not having a type.
although i am still left with the problem of Init() still needing to be defined-somehow in the CGfxOpenGL.h
Starcreek,
You are missing the point here. OpenGL application are to complex if you dont understand the C++ language. You are having problems with simple C++ basics such as classes. Why are you so insistant on trying to make this work without knowing all the things you need to know? Why do you appear to be completely ignorant of responses back to you pointing out that you NEED MORE KNOWLEDGE. What the hell are you trying to accomplish that you can not take a little bit of time and study up on programming basics? It will only help you to do this. If you can not do that then quit wasting peoples time because you are not going to understand the answer you get anyways. Which means you will post again like you are doing here...ignoring what you have already been told and pissing off your help.