From: Rick van Haasen (rick.van.haasen++at++philips.com)
Date: 07/26/2005 03:14:43
Rajesh,
i haven't looked detailed at all parts:
some things however i noticed:
to me it looks like you have to negate the sign from your
outcommented part:
//glTranslatef(0.0f,0.0f,farPlaneLL[2]*0.9);
in OpenGL, positive z is toward the viewer
try
glTranslatef(0.0f,0.0f,-farPlaneLL[2]*0.9);
your call glTranslatef(0.0f,farPlaneLL[2]*0.005,2.0);
puts the object 2.0 behind the camera with a slight vertical offset.
The fact that you do "see the background image" is contributed to
the fact that the state just before for your "glTtranslatef" is the
current modelview matrix as setup by performer (the translation
and rotation defined in the while loop).
after the glPushMatrix() i would load the identity glLoadIdentity() first.
Then apply the translation, render the image and restore the stack.
further i would first render the backgound and after that your
scene, otherwise there will be no blending with transparant scene objects.
maybe that helps...
Rick
Rajesh R
Sent by:
owner-info-performer++at++performer.engr.sgi.com
2005-07-26 09:41
To
<info-performer++at++sgi.com>
cc
Subject
[info-performer] Background texture
Classification
Dear Performers,
My destiny with background skybox rendering is very poor. So far I have
not able to
render even a background texture. The code given below works. But the
texture is rendering as a front portion instead of a background texture.
Any suggestions pLease,
#include <stdlib.h>
#include <Performer/pf.h>
#include <Performer/pfutil.h>
#include <Performer/pfdu.h>
#include <Performer/prmath.h>
#include <gl.h>
#include <glut.h>
typedef struct
{
long val;
} PassData;
static pfMatrix idmat ={{1.0f, 0.0f, 0.0f, 0.0f},
{0.0f, 1.0f, 0.0f, 0.0f},
{0.0f, 0.0f, 1.0f, 0.0f},
{0.0f, 0.0f, 0.0f, 1.0f}};
void DrawChannel(pfChannel* chan,void *data);
int winWidth = 500;
int winHeight = 500;
void cullFunc(pfChannel *chan, void *data);
void drawFunc(pfChannel *chan, void *data);
int main()
{
PassData *pd;
float t = 0.0f;
char* filename = "esprit.pfb";
int i,j;
pfScene *scene;
pfNode *root;
pfPipe *p;
pfPipeWindow *pw;
pfChannel *chan;
pfSphere bsphere;
pfEarthSky *esky;
static int fbattr[] =
{PFFB_RGBA,PFFB_DOUBLEBUFFER,PFFB_DEPTH_SIZE, 24,
PFFB_RED_SIZE, 8,PFFB_SAMPLES,
8,PFFB_STENCIL_SIZE,
1,NULL,};
/* Initialize Performer */
pfInit();
/* Use default multiprocessing mode based on number of
* processors.
*/
pfMultiprocess( PFMP_DEFAULT );
/* Load all loader DSO's before pfConfig() forks */
pfdInitConverter(filename);
/* initiate multi-processing mode set in pfMultiprocess call
* FORKs for Performer processes, CULL and DRAW, etc. happen here.
*/
pfConfig();
/* Append to Performer search path, PFPATH, files in
* /usr/share/Performer/data */
pfFilePath(".:/usr/share/Performer/data");
/* Read a single file, of any known type. */
if ((root = pfdLoadFile(filename)) == NULL)
{
pfExit();
exit(-1);
}
/* Attach loaded file to a new pfScene. */
scene = pfNewScene();
pfAddChild(scene, root);
/* Create a pfLightSource and attach it to scene. */
pfAddChild(scene, pfNewLSource());
/* Configure and open GL window */
p = pfGetPipe(0);
pw = pfNewPWin(p);
pfPWinType(pw, PFPWIN_TYPE_X);
pfPWinName(pw, "OpenGL Performer");
pfPWinOriginSize(pw, 0, 0, winWidth,winHeight);
//pfPWinFBConfigAttrs(pw,fbattr);
/* Open and configure the GL window. */
pfOpenPWin(pw);
/* Create and configure a pfChannel. */
chan = pfNewChan(p);
pfChanScene(chan, scene);
pfChanFOV(chan, 45.0f, 0.0f);
/* determine extent of scene's geometry */
pfGetNodeBSphere (root, &bsphere);
pfChanNearFar(chan, 1.0f, 10.0f * bsphere.radius);
pfFrame();
/* allocate passthrough data */
pd = (PassData*)pfAllocChanData(chan,sizeof(PassData));
/* initialize channel callbacks */
/* Data intialization */
//pfChanTravFunc(chan, PFTRAV_CULL, cullFunc);
pfChanTravFunc(chan, PFTRAV_DRAW, drawFunc);
/* main simulation loop */
while(1)
{
pfCoord view;
float s, c;
pfSync();
//pd->val = 0;
pfPassChanData(chan);
pfFrame();
t = pfGetTime();
pfSinCos(45.0f*t, &s, &c);
pfSetVec3(view.hpr, 45.0f*t, -10.0f, 0);
pfSetVec3(view.xyz, 2.0f * bsphere.radius
*s ,
-2.0f * bsphere.radius
*c,
0.5f * bsphere.radius);
pfChanView(chan, view.xyz, view.hpr);
}
/* Terminate parallel processes and exit. */
pfExit();
return 0;
}
void cullFunc(pfChannel *chan, void *data)
{
PassData *pd = (PassData*)data;
pd->val++;
pfCull();
}
void drawFunc(pfChannel *chan, void *data)
{
GLubyte imagebuffer[500][500][3];
int i,j;
int c;
pfVec3 farPlaneLL,dummy;
for (i = 0; i < winWidth; i++) {
for (j = 0; j < winHeight; j++) {
c = ((((i&0x8)==0)^((j&0x8))==0))*255;
imagebuffer[i][j][0] = (GLubyte) c;
imagebuffer[i][j][1] = (GLubyte) c;
imagebuffer[i][j][2] = (GLubyte) c;
//imagebuffer[i][j][3] = (GLubyte) 255;
}
}
pfClearChan(chan);
pfDraw();
pfPushState();
pfBasicState();
glClearStencil(0x0);
glClear(GL_STENCIL_BUFFER_BIT);
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
glDepthFunc(GL_ALWAYS);
glDepthMask(GL_FALSE);
glPushMatrix();
pfGetChanFar(chan, farPlaneLL, dummy, dummy, dummy);
//glTranslatef(0.0f,0.0f,farPlaneLL[2]*0.9);
glTranslatef(0.0f,farPlaneLL[2]*0.005,2.0);
glRasterPos2i(0.0f,0.0f);
glDrawPixels(winWidth, winHeight,
GL_RGB,GL_UNSIGNED_BYTE,
imagebuffer);
glPopMatrix();
glDepthFunc(GL_LEQUAL);
glDepthMask(GL_TRUE);
pfPopState();
}
Rajesh.R
Virtual Reality
Institute for Robotics and Virtual Reality
c/o Centre for AI and Robotics
Defence Research and Development Organization (DRDO)
Ministry of Defence
Bangalore - 1
Scientists are people of very dissimilar temperaments
doing different things in very different ways. Among
scientists are collectors, classifiers and compulsive
tidiers-up; many are detectives by temperament and many
are explorers; some are artists and others artisans.
There are poet-scientists and philosopher-scientists and
even a few mystics."
-----------------------------------------------------------------------
List Archives, Info, FAQ: http://www.sgi.com/software/performer/
Open Development Project: http://oss.sgi.com/projects/performer/
Submissions: info-performer++at++sgi.com
Admin. requests: info-performer-request++at++sgi.com
-----------------------------------------------------------------------
This archive was generated by hypermail 2b29 : Tue Jul 26 2005 - 03:17:10 PDT