Irrlicht Engine Classes, and seperation

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

rogerborg wrote:Ubuntu. 1.4, then Blundering Dodo then Horny Echidna.
XD

I think that we really have enough problems to take care of at the moment, we don't need to start inventing new ones concerning "seperation". I'd rather have this other thing called, you know, functionality?

Cheers
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
FlyingIsFun1217
Posts: 219
Joined: Fri Apr 13, 2007 8:29 pm
Location: Illinois
Contact:

Post by FlyingIsFun1217 »

BlindSide wrote:I'd rather have this other thing called, you know, functionality?
Who needs that?!?!

FlyingIsFun1217
Halifax
Posts: 1424
Joined: Sun Apr 29, 2007 10:40 pm
Location: $9D95

Post by Halifax »

BlindSide wrote: I think that we really have enough problems to take care of at the moment, we don't need to start inventing new ones concerning "seperation". I'd rather have this other thing called, you know, functionality?
Yes, I agree, as I said in my other post, but is it not better to think of the future as well, rather than just living in the present?
TheQuestion = 2B || !2B
Saturn
Posts: 418
Joined: Mon Sep 25, 2006 5:58 pm

Post by Saturn »

And where do you put this new functionality if concerns aren't properly separated?
This is no end in itself, but a basic requisite for adding new functionality. Again, see the device example by hybrid.
vectorcorpse
Posts: 86
Joined: Thu Feb 14, 2008 7:30 pm
Location: Portugal

Post by vectorcorpse »

one thing that i think that would be extremely helpful to anyone that is starting to try to add new features to the engine was commenting the engine source code. another thing i don't really understand is why is a cross platform engine supporting a broken and non cross platform api such has directx, the way i see it is only slowing down development, has u have to maintain 3 versions of an api that only works for windows it's a wast of time since opengl can do anything dx can and will work on every platform not only that i see ppl asking of dx10 because of geometry shaders... (only vista will benefit from that for windows xp the only way u'll ever get geometry shaders is using opengl) opengl already supports geometry shaders on opengl2.1 besides theres also another problem, the only way a new feature goes mainstream is if it is supported by all drivers, that said irr ill be missing allot of features for a long time since at least 4 implementations of the feature will have to be made (dx7 dx8 dx9 and opengl) we could already have cube mapping or projective shadows or better yet cube shadow mapping if we only needed to do it once (ex: cube mapping is supported in opengl1.3 using fixed functions) i consider a good shadow system more important than bloom o any other high lvl shader and i'd rather have a good and fast shadow system than parallax.
this is a nvidia demo i changed to work with arb instead of ext extensions so it would work on my old radeon 9100 igp

Code: Select all

#include <stdio.h>

#include <stdlib.h>

#include <math.h>

#include <string.h>

#include <GL/glut.h>



/* In case your <GL/gl.h> does not advertise ARB_texture_cube_map... */

#ifndef GL_ARB_texture_cube_map

# define GL_NORMAL_MAP_ARB                   0x8511

# define GL_REFLECTION_MAP_ARB               0x8512

# define GL_TEXTURE_CUBE_MAP_ARB             0x8513

# define GL_TEXTURE_BINDING_CUBE_MAP_ARB     0x8514

# define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB  0x8515

# define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB  0x8516

# define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB  0x8517

# define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB  0x8518

# define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB  0x8519

# define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB  0x851A

# define GL_PROXY_TEXTURE_CUBE_MAP_ARB       0x851B

# define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB    0x851C

#endif



/* constants */

#ifndef M_PI

#define M_PI            (3.14159265358979f)

#endif

#define DTOR            (M_PI/180.0)

#define RTOD            (180.0/M_PI)



#define CUBE_MAP_SIZE 256



#define ZTRANS 4.0F



int exitAfterOneFrame = 0;



enum {CUBE_POS_X, CUBE_NEG_X, CUBE_POS_Y, CUBE_NEG_Y, CUBE_POS_Z, CUBE_NEG_Z};

static unsigned char CubeMap[6][CUBE_MAP_SIZE][CUBE_MAP_SIZE][4];

static void InitGraphics(void);

static void light_state(long, long);

static void DrawSphere(float);

static void vert(float, float);



static void

vert(float theta, float phi)

{

  float r = 0.75f;

  float x, y, z, nx, ny, nz;



  nx = sin(DTOR * theta) * cos(DTOR * phi);

  ny = sin(DTOR * phi);

  nz = cos(DTOR * theta) * cos(DTOR * phi);

  glNormal3f(nx, ny, nz);



  x = r * sin(DTOR * theta) * cos(DTOR * phi);

  y = r * sin(DTOR * phi);

  z = -ZTRANS + r * cos(DTOR * theta) * cos(DTOR * phi);

  glVertex4f(x, y, z, 1.0);

}



static void

DrawSphere(float del)

{

  float phi, phi2, theta;



  glColor4f(1.0, 1.0, 1.0, 1.0);

  for (phi = -90.0f; phi < 90.0f; phi += del) {

    glBegin(GL_TRIANGLE_STRIP);



    phi2 = phi + del;



    for (theta = -90.0f; theta <= 90.0f; theta += del) {

      vert(theta, phi);

      vert(theta, phi2);

    }

    glEnd();

  }

}



static float

Dot3(float *a, float *b)

{

  return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];

}



static float *

Scale3(float *result, float *a, float scale)

{

  result[0] = a[0] * scale;

  result[1] = a[1] * scale;

  result[2] = a[2] * scale;

  return result;

}



static float *

Normalize3(float *result, float *a)

{

  float length;



  length = (float) sqrt(Dot3(a, a));

  return Scale3(result, a, 1 / length);

}



static unsigned char *

CubeFunc(unsigned char resultColor[3], float vec[3])

{

  int i;

  float faceVec[3];



  if (vec[0] == 1.0) {

    resultColor[0] = 255;

    resultColor[1] = 0;

    resultColor[2] = 0;

  } else if (vec[1] == 1.0) {

    resultColor[0] = 0;

    resultColor[1] = 255;

    resultColor[2] = 0;

  } else if (vec[2] == 1.0) {

    resultColor[0] = 0;

    resultColor[1] = 0;

    resultColor[2] = 255;

  } else if (vec[0] == -1.0) {

    resultColor[0] = 255;

    resultColor[1] = 0;

    resultColor[2] = 255;

  } else if (vec[1] == -1.0) {

    resultColor[0] = 255;

    resultColor[1] = 255;

    resultColor[2] = 0;

  } else if (vec[2] == -1.0) {

    resultColor[0] = 0;

    resultColor[1] = 255;

    resultColor[2] = 255;

  }

  return resultColor;



  Normalize3(faceVec, vec);

  for (i = 0; i < 3; i++) {

    resultColor[i] = 255 * (sin(6 * (faceVec[i] + faceVec[(i + 1) % 3])) + 1) / 2.0;

  }

  return resultColor;

}



GLenum cubefaces[6] = {

  GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB,

  GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB,

  GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB,

  GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB,

  GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB,

  GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB,

};



static void 

InitGraphics(void)

{

  int i, j, k;



  glMatrixMode(GL_PROJECTION);

  glLoadIdentity();

  glFrustum(-1.0, 1.0, -0.75, 0.75, ZTRANS - 1.0, ZTRANS + 1.0); // match 

                                                                 // 640x480



  glMatrixMode(GL_MODELVIEW);;

  glLoadIdentity();



  for (i = 0; i < CUBE_MAP_SIZE; i++) {

    float t = 1.0 / (2 * CUBE_MAP_SIZE) + (float) i / CUBE_MAP_SIZE;

    t = 2.0 * t - 1.0;

    for (j = 0; j < CUBE_MAP_SIZE; j++) {

      float s = 1.0 / (2 * CUBE_MAP_SIZE) + (float) j / CUBE_MAP_SIZE;

      float pt[3];

      s = 2.0 * s - 1.0;

      pt[0] = 1;

      pt[1] = t;

      pt[2] = -s;

      CubeFunc(CubeMap[CUBE_POS_X][i][j], pt);

      pt[0] = -1;

      pt[1] = t;

      pt[2] = s;

      CubeFunc(CubeMap[CUBE_NEG_X][i][j], pt);



      pt[1] = 1;

      pt[0] = s;

      pt[2] = -t;

      CubeFunc(CubeMap[CUBE_POS_Y][i][j], pt);

      pt[1] = -1;

      pt[0] = s;

      pt[2] = t;

      CubeFunc(CubeMap[CUBE_NEG_Y][i][j], pt);



      pt[2] = 1;

      pt[0] = s;

      pt[1] = t;

      CubeFunc(CubeMap[CUBE_POS_Z][i][j], pt);

      pt[2] = -1;

      pt[0] = -s;

      pt[1] = t;

      CubeFunc(CubeMap[CUBE_NEG_Z][i][j], pt);

      for (k = CUBE_POS_X; k <= CUBE_NEG_Z; k++) {

        CubeMap[k][i][j][3] = 255;

      }

    }

  }



  glEnable(GL_DEPTH_TEST);



  glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);



  for (i = 0; i < 6; i++) {

    glTexImage2D(

      cubefaces[i],

      0,                  // level

      GL_RGBA8,          // internal format

      CUBE_MAP_SIZE,     // width

      CUBE_MAP_SIZE,     // height

      0,                 // border

      GL_RGBA,           // format

      GL_UNSIGNED_BYTE,   // type

      CubeMap[CUBE_POS_X + i]); // pixel data

  }



  glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

  glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);



  glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB);

  glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB);

  glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB);

  glEnable(GL_TEXTURE_CUBE_MAP_ARB);

  glEnable(GL_TEXTURE_GEN_S);

  glEnable(GL_TEXTURE_GEN_T);

  glEnable(GL_TEXTURE_GEN_R);

  glEnable(GL_NORMALIZE);

}



static void 

display(void)

{

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);



  DrawSphere(9.0);



  glutSwapBuffers();

  if (exitAfterOneFrame) {

    exit(0);

  }

}



static void

keyboard(unsigned char c, int x, int y)

{

  switch (c) {

  case 27:

    exit(0);

    break;

  case ' ':  /* Space bar redraws. */

    glutPostRedisplay();

    break;

  }

}



int

main(int argc, char **argv)

{

  int i;



  glutInitWindowSize(640, 480);

  glutInit(&argc, argv);

  for (i = 1; i < argc; i++) {

    if (!strcmp("-e", argv[i])) {

      exitAfterOneFrame = 1;

    }

  }

  glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH | GLUT_RGB);

  glutCreateWindow("cubemap");



  /* Run-time extension check. */

  if (!glutExtensionSupported("GL_ARB_texture_cube_map")) {

    fprintf(stderr,

      "cubemap: Requires the ARB_texture_cube_map OpenGL extension to run.\n");

    exit(0);

  }



  glutDisplayFunc(display);

  glutKeyboardFunc(keyboard);

  InitGraphics();

  glutMainLoop();

  return 0;

}
(i didn't posted the demo with the textures and the reflective pot because u can easily find it on nvidia and the modifications are the same replace all EXT with ARB)
i think it would be great to get this in the engine with this it would be possible to mix blindside's xeffects with his virtual cube map code to get cube shadow mapping, and also get better reflections. the only problem is dx, i have no idea how we could get the same for lets say dx7 or dx8 with fixed functions, neither i know why ppl bother. i never saw anyone complaining about return to castel wolfenstein or unreal tornument 2004 being opengl. i thing dx is like a fashion everybody love it and don't even know why. (i gess it can be easyer on some parts for programmers but at what cost???)
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Please no FUD. While your OpenGL feature description is mainly correct, neither your DX assessment, nor the problems with integrating cubemaps into Irrlicht were making a point. Moreover, your example doesn't really help with integrating anything into Irrlicht. Finally, there's no dx7 driver in Irrlicht, and changing EXT to ARB doesn't help with supporting other gfx cards, but only to overcome shortcomings in your header files.
FlyingIsFun1217
Posts: 219
Joined: Fri Apr 13, 2007 8:29 pm
Location: Illinois
Contact:

Post by FlyingIsFun1217 »

Jeeze, that was the next thing to a spam...

FlyingIsFun1217
vectorcorpse
Posts: 86
Joined: Thu Feb 14, 2008 7:30 pm
Location: Portugal

Post by vectorcorpse »

I'm really sorry for my rude behavior, it wasn't my intension annoy or hurt anyone, but after 4 days in the hospital with my 1 year old daughter sick i was a bit crankie ended hurting innocent ppl and only now that she's out of danger i realized what i did. i really think the best of u all and that irrlicht is one of the best graphics engines available and with the potential for much more that i am anxious to see what will be the next feature. i guess another reason for my rude behavior was me feeling frustrated for not being able to help more with irr development, i'v been away from programing for some years and fell behind specially on c++ (that i am restudying to get back on track) opengl and shaders (that i never studied, at least not in school) i made e few small 2d and pseudo 3d software rendering games and apps back in the 90's before accelerated cards flooded the market, but thats all useless now and really small compared to what is being done now.
again sorry for my behavior, it won't happen again.
FlyingIsFun1217
Posts: 219
Joined: Fri Apr 13, 2007 8:29 pm
Location: Illinois
Contact:

Post by FlyingIsFun1217 »

vectorcorpse wrote:4 days in the hospital with my 1 year old daughter sick
Hope she's feeling ok; just remember that there are bigger things to focus on in situations like those than computer stuff ;)

FlyingIsFun1217
vectorcorpse
Posts: 86
Joined: Thu Feb 14, 2008 7:30 pm
Location: Portugal

Post by vectorcorpse »

she is much better now thx, i'll have to wait 6 month to make another exam and see if there are no scars on her kidneys, at the moment things are getting back on track she is already happy and playing and i'm allot more reliefed to see her well.
Post Reply