summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorConstantin Riß <constantin.riss@dre.de>2010-01-16 22:57:50 +0100
committerConstantin Riß <constantin.riss@dre.de>2010-01-16 22:57:50 +0100
commitf382c18643d16bf6656e508d611817aaf0c29704 (patch)
tree2063914afb33989ec416e427d5c608eeba7f3282
parentac9295f8f9ec5efa475fa8f2a56b3d975d6acc01 (diff)
downloadc3d-f382c18643d16bf6656e508d611817aaf0c29704.tar
c3d-f382c18643d16bf6656e508d611817aaf0c29704.zip
Bisschen geändert.
-rw-r--r--DisplayClass.cpp27
-rw-r--r--DisplayClass.h7
-rw-r--r--Temparray.cpp6
-rw-r--r--Temparray.h8
-rw-r--r--main.cpp23
5 files changed, 46 insertions, 25 deletions
diff --git a/DisplayClass.cpp b/DisplayClass.cpp
index 0a833c9..d5d6b50 100644
--- a/DisplayClass.cpp
+++ b/DisplayClass.cpp
@@ -2,9 +2,9 @@
#include "gl.h"
-DisplayClass::Renderer DisplayClass::renderer;
+DisplayClass::Renderer DisplayClass::render;
-DisplayClass::DisplayClass() : angle(0) {
+DisplayClass::DisplayClass(int x, int y, int z) : angle(0) {
/*cubehole0 = Cubehole(3.0, 6.0, 3.0, 0.0, 0.0, 0.0, 2.5, 2.5,
vmml::vec4f(1.0, 0.85, 0.06, 0.5),
vmml::vec4f(1.0, 0.85, 0.06, 0.5),
@@ -48,14 +48,14 @@ DisplayClass::DisplayClass() : angle(0) {
std::list<Triangle> t5 = cubehole5.getTriangles();
triangles.splice(triangles.end(), t5);*/
- Temparray temp(20, 5, 5, 5);
- std::list<Triangle> triangles=temp.getTriangles();
+ Temparray temp(20, x, y, z);
+ triangles=temp.getTriangles();
- tree = new BSPTree(triangles);
+ //tree = new BSPTree(triangles);
}
DisplayClass::~DisplayClass() {
- delete tree;
+ //delete tree;
}
void DisplayClass::renderScene(unsigned long delta) {
@@ -72,15 +72,20 @@ void DisplayClass::renderScene(unsigned long delta) {
glRotatef(angle*3, 0.0, 0.0, 1.0);
glRotatef(-angle*5, 1.0, 1.0, 1.0);
- vmml::mat4f transform, inverseTransform;
- glGetFloatv(GL_MODELVIEW_MATRIX, transform.array);
+ //vmml::mat4f transform, inverseTransform;
+ //glGetFloatv(GL_MODELVIEW_MATRIX, transform.array);
- transform.inverse(inverseTransform);
+ //transform.inverse(inverseTransform);
- vmml::vec3f viewPoint = inverseTransform*vmml::vec3f::ZERO;
+ //vmml::vec3f viewPoint = inverseTransform*vmml::vec3f::ZERO;
glBegin(GL_TRIANGLES);
- tree->visit(renderer, viewPoint);
+ //tree->visit(render, viewPoint);
+
+ for(std::list<Triangle>::iterator t = triangles.begin(); t != triangles.end(); ++t) {
+ render(*t);
+ }
+
glEnd();
glFlush();
diff --git a/DisplayClass.h b/DisplayClass.h
index 688e2f6..ab9add0 100644
--- a/DisplayClass.h
+++ b/DisplayClass.h
@@ -8,7 +8,7 @@
class DisplayClass
{
public:
- DisplayClass();
+ DisplayClass(int x, int y, int z);
virtual ~DisplayClass();
void renderScene(unsigned long delta);
@@ -20,11 +20,12 @@ class DisplayClass
}
};
- static Renderer renderer;
+ static Renderer render;
float angle;
//Cubehole cubehole0, cubehole1, cubehole2, cubehole3, cubehole4, cubehole5;
- BSPTree *tree;
+ std::list<Triangle> triangles;
+ //BSPTree *tree;
};
#endif /*_DISPLAYCLASS_H_*/
diff --git a/Temparray.cpp b/Temparray.cpp
index a2303ab..16335f9 100644
--- a/Temparray.cpp
+++ b/Temparray.cpp
@@ -16,7 +16,7 @@ Temparray::Temparray(float initialtemp, int x0, int y0, int z0){
for(int j = 0; j < y0; ++j) {
for(int k = 0; k < z0; ++k) {
for(int l = 0; l < 6; ++l) {
- cubehole(i, j, k, l).setSize((6-l)/6*0.9, 0.9, (6-l)/6*0.9, (5-l)/6*0.9, (5-l)/6*0.9);
+ cubehole(i, j, k, l).setSize((6-l)/6.0*0.9, 0.9, (6-l)/6.0*0.9, (5-l)/6.0*0.9, (5-l)/6.0*0.9);
float x, y, z;
if(x0 % 2 == 0) x = -(x0/2)+i+0.5;
@@ -35,6 +35,10 @@ Temparray::Temparray(float initialtemp, int x0, int y0, int z0){
}
}
}
+ cubehole(0, 0, 0, 0).setColor(vmml::vec4f(1.0, 0.5, 1.0, 1.0),
+ vmml::vec4f(0.5, 0.5, 1.0, 1.0),
+ vmml::vec4f(1.0, 0.5, 0.0, 1.0),
+ vmml::vec4f(0.0, 0.0, 0.0, 1.0));
}
void Temparray::calcTemp(int x, int y, int z, int line, int pos){
diff --git a/Temparray.h b/Temparray.h
index ac082b4..cae1e6f 100644
--- a/Temparray.h
+++ b/Temparray.h
@@ -19,13 +19,13 @@ class Temparray
float& temperaturenew(int x, int y, int z, int line, int pos) {
return temparraynew[x*sy*sz*6*4 + y*sz*6*4 + z*6*4 + line*4 + pos];
}
- void deactivateCube(int x, int y, int z){
+/* void deactivateCube(int x, int y, int z){
for(int i=0; i<6; i++){
for(int j=0; j<4; j++){
setTemp(-100, x, y, z, i, j);
}
}
- }
+ }*/
std::list<Triangle> getTriangles();
private:
@@ -44,8 +44,8 @@ class Temparray
for(int k=0; k<z0; k++){
for(int l=0; l<6; l++){
for(int m=0; m<4; m++){
- temperaturenew(x, y, z, line, pos) = temp;
- temperatureold(x, y, z, line, pos) = temp;
+ temperaturenew(i, j, k, l, m) = temp0;
+ temperatureold(i, j, k, l, m) = temp0;
}
}
}
diff --git a/main.cpp b/main.cpp
index 632c3b9..8d59951 100644
--- a/main.cpp
+++ b/main.cpp
@@ -1,5 +1,6 @@
#include "DisplayClass.h"
#include "gl.h"
+#include <cstdlib>
#ifdef _WIN32
#else
@@ -20,15 +21,15 @@ void resize(int width, int height);
void initGL(bool multisample) {
glClearColor(0.0, 0.0, 0.0, 1.0);//glClearColor(1.0, 0.85, 0.06, 1.0);
glClearDepth(1.0);
- //glEnable(GL_DEPTH_TEST);
- //glDepthFunc(GL_LEQUAL);
+ glEnable(GL_DEPTH_TEST);
+ glDepthFunc(GL_LEQUAL);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
#ifndef _WIN32
if(multisample)
- glEnable(GL_MULTISAMPLE_ARB);
+ glDisable(GL_MULTISAMPLE_ARB);
#endif
resize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
@@ -221,6 +222,11 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
}
}
+ void resize(int width, int height);
+
+ void initGL(bool multisample) {
+ glClearColor(0.0, 0.0, 0.0, 1.0);//glClearColor(1.0, 0.85, 0.06, 1.0);
+ glClearDepth(1.0);
delta = GetTickCount()-ticks;
if(delta < MIN_FRAME_DELTA) {
@@ -230,7 +236,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
ticks += delta;
- static DisplayClass render;
+ static DisplayClass render();
render.renderScene(delta);
SwapBuffers(hDC);
}
@@ -335,12 +341,17 @@ bool GLXinit(Display *disp, Atom windele, Window *wnd, GLXContext *gc, bool *mul
return ok;
}
-int main() {
+int main(int argc, char *argv[]) {
Display *disp = XOpenDisplay(0);
Atom windele = XInternAtom(disp, "WM_DELETE_WINDOW", False);
Window wnd;
GLXContext gc;
+ if(argc != 4) {
+ std::cerr << "Wrong paramter count" << std::endl;
+ return 1;
+ }
+
bool multisample;
if(!GLXinit(disp, windele, &wnd, &gc, &multisample))
return 1;
@@ -376,7 +387,7 @@ int main() {
if(!running) break;
- static DisplayClass render;
+ static DisplayClass render(std::atoi(argv[1]), std::atoi(argv[2]), std::atoi(argv[3]));
render.renderScene(delta);
glXSwapBuffers(disp, wnd);