Hello,
Unfortunately I learnt OpenGL from NeHe tutorials, which means that all of my current methods for OpenGL-ing are extremely deprecated. I tried to find a more up-to-date tutorial, but all they seem to do is teach how to get really complicated stuff out of OpenGL. I just want to know: What is the current method of drawing 3D triangles with either coloured or textured vertices to the screen?
I know how to use the simple:
glBegin(GL_TRIANGLES);
//Draw a colourful triangle:
glNormal3f(nx,ny,nz);//where nx,ny,nz are calculated based on the vertices
glColour3b(a,b,c);//I usually use a preprocessor to allow my canadian spelling
glVertex3f(a,b,c);
glColour3b(a,b,c);
glVertex3f(a,b,c);
glColour3b(a,b,c);
glVertex3f(a,b,c);
//Draw a textured triangle:
//I actually forget how to load a new texture for each triangle, since I usually use 1 texture for all my triangles
glNormal3f(nx,ny,nz);//again
glTexCoord3f(a,b,c);
glVertex3f(a,b,c);
glTexCoord3f(a,b,c);
glVertex3f(a,b,c);
glTexCoord3f(a,b,c);
glVertex3f(a,b,c);
glEnd();
I also know how to embed the above into a display list and then call that.
From what I have read, both of the above are considered depricated since they really don't use much effective hardware accelleration. I want to know what the current technique for doing this simple task is, without having to include a ton of extra files.
Basically, I need to be able to implement a function like this: (here by 'like' I mean similar to, I realize my data structures may not 'agree' with OpenGL)
struct Vector3D
{
float x,y,z;
};
struct Coord2D
{
int x,y;
};
typedef uint32_t Colour;//0xAARRGGBB
struct ColourTriangle
{
Vector3D a,b,c,n;//n is normal, its length is how shiny the triangle should be?
Colour ac,bc,cc;
};
struct Texture
{
vector<Colour> cols;
int width;//height can be determined from cols.size()
};
struct TextureTriangle
{
Vector3D a,b,c,n;//n is normal, length is how shiny?
Coord2D at,bt,ct;
Texture *tex;//NULL==do not draw
};
struct Light
{
Vector3D position;
Colour specularCol;
Colour ambientCol;
Colour diffuseCol;
//not sure what else I need?
};
struct Camera
{
Vector3D position,rotation;//rotation its clockwise about the .?-axis
float vFOV,hFOV;//vertical and horizontal field of view
};
void draw(vector<ColourTriangle> ctris,
vector<TextureTriangle> ttris,
vector<Light> lights,
Camera cam,
Coord2D topLeft,
Coord2D bottomRight,
Texture? destination);//Is this even possible? and if so how do I get the 'destination' Texture?
My 1 rule is that I do not wish to have to include any additional libraries, just <GL/GL.h>.
Is this even possible? Am I approaching rendering from the wrong perpective maybe? What other 'things' are commonly drawn in OpenGL and how do they work?