mm.. yes
what exactly should i post?
sorry.. i'm pretty noob in c++.
here's everything in main, before functions begin:
Code:
/*
* This Code Was Created By Jeff Molofee 2000
* A HUGE Thanks To Fredric Echols For Cleaning Up
* And Optimizing This Code, Making It More Flexible!
* If You've Found This Code Useful, Please Let Me Know.
* Visit My Site At nehe.gamedev.net
*/
#include <windows.h> // Header File For Windows
#include <gl\gl.h> // Header File For The OpenGL32 Library
#include <gl\glu.h> // Header File For The GLu32 Library
#include <gl\glaux.h> // Header File For The Glaux Library
#include "poly.h" //polygon class
#include "polymanager.h" //polygon manager
#include <vector>
using namespace std;
HDC hDC=NULL; // Private GDI Device Context
HGLRC hRC=NULL; // Permanent Rendering Context
HWND hWnd=NULL; // Holds Our Window Handle
HINSTANCE hInstance; // Holds The Instance Of The Application
float ang=0;
bool keys[256]; // Array Used For The Keyboard Routine
bool active=TRUE; // Window Active Flag Set To TRUE By Default
bool fullscreen=TRUE; // Fullscreen Flag Set To Fullscreen Mode By Default
Poly patrat[4];
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); // Declaration For WndProc
it's actually NeHe's framework for opengl.
and here's my class: (poly.cpp)
Code:
#include <gl\gl.h> // Header File For The OpenGL32 Library
#include <gl\glu.h> // Header File For The GLu32 Library
#include <gl\glaux.h> // Header File For The Glaux Library
#include "poly.h"
void p3d::Set(float mx, float my, float mz)
{
x=mx;y=my;z=mz;
}
Poly::Poly ()
{
};
void Poly::Set(p3d *p, size_t size)
{
cnum=size;
corners=new p3d[cnum];
for (int i=0;i<size;i++) {
corners[i]=p[i];
}
}
void Poly::Render()
{
//a bit of optimisation
if (cnum==3) {glBegin(GL_TRIANGLES);}
if (cnum==4) {glBegin(GL_QUADS);}
if (cnum>4) {glBegin(GL_POLYGON);}
for (int i=0;i<=cnum;i++) {
glColor3f(corners[i].x*50,corners[i].y*50,corners[i].z*50);
glVertex3f(corners[i].x,corners[i].y,corners[i].z);
}
glEnd();
}
void Poly::Move(float nx, float ny, float nz)
{
for (int i=0;i<=cnum;i++) {
corners[i].x+=nx;
corners[i].y+=ny;
corners[i].z+=nz;
}
}
Poly::~Poly() {};