How to calculate stereo object using ... Log Out | Topics | Search
Moderators | Register | Edit Profile

stereo3d.com webboard » General 3D Discussion » How to calculate stereo object using open gl? « Previous Next »

Author Message
Top of pagePrevious messageNext messageBottom of page Link to this message

apit

Rating: N/A
Votes: 0 (Vote!)

Posted on Monday, August 11, 2003 - 6:45 pm:   Edit PostDelete PostView Post/Check IPPrint Post

i have create a simple program that have two view using open gl...the problem is, how to make it look stereo...the code above is my program..

#include
#include
#include
#include
#include
#include "split.h"


void changeSize(int w1, int h1)
{

// elakkan devide by zero
ratio = 1.0f * w1 / h1;

// Reset koordinat gl_projection sebelum diubahsuai
glMatrixMode(GL_PROJECTION);
glLoadIdentity();

// Set viewport kpd keseluruhan window
glViewport(0, 0, w1, h1); //(0,0)=specifies lower-left coner of the viewport

// Set the clipping volume
gluPerspective(45,ratio,0.1,1000);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();


}

void SeparateWindow(int w1,int h1)
{
if(h1 == 0)
h1 = 1;

w = w1;
h = h1;

//Separate Window Sebelah Kiri
glutSetWindow(subWindowKiri);
glutPositionWindow(border,border);
glutReshapeWindow(w/2-border*3/2,h-2*border);//w-2*border, h/2 - border*3/2);-devide atas bawah
changeSize(w/2-border*3/2,h-2*border);//w-2*border, h/2 - border*3/2);-devide atas bawah

//Separate Window Sebelah Kanan
glutSetWindow(subWindowKanan);
glutPositionWindow((w+border)/2,border);
glutReshapeWindow(w/2-border*3/2,h-2*border);//w-2*border, h/2 - border*3/2);
changeSize(w/2-border*3/2,h-2*border);//w-2*border,h/2 - border*3/2);

}


void DrawTriangle(int x)
{

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();

//glRotatef(angle,0.0,1.0,0.0);
glColor3f(0.0,0.0,1.0);
//glScalef(10.0,0.0,0.0);
//glTranslatef(0.0f, 0.0f, -2.0f);
//draw triangle
glBegin(GL_TRIANGLES);
glVertex3f(-2.0,1.0,0.0);
glVertex3f(3.0,1.0,0.0);
glVertex3f(0.0,3.0,0.0);
glEnd();


glPopMatrix();
angle++;

glutSwapBuffers();
}

void renderScene()
{
glutSetWindow(mainWindow);
glClear(GL_COLOR_BUFFER_BIT);
glutSwapBuffers();
}

void renderSceneKiri()
{
glutSetWindow(subWindowKiri);
glLoadIdentity();
gluLookAt(x, y, z,
0.11285,y+ly,0.222,//x + lx,y + ly,z + lz,
0.0f,1.0f,0.0f);


DrawTriangle(subWindowKiri);
}

void renderSceneKanan()
{
glutSetWindow(subWindowKanan);
glLoadIdentity();

gluLookAt(x, y, z, //lokasi kamera - nilai (0,0,0)= asalan
-0.11285,y+ly,0.222,//x + lx,y + ly,z + lz, //dimana camera halakan/point = line of sight
0.0f,1.0f,0.0f); //vektor yg menerangkan arah atas
DrawTriangle(subWindowKanan);
}

void renderSceneAll()
{

renderSceneKiri();
renderSceneKanan();
}

int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(100,100);
glutInitWindowSize(w,h);
mainWindow = glutCreateWindow("Two View");
glutReshapeFunc(SeparateWindow);
glutDisplayFunc(renderScene);
glutIdleFunc(renderSceneAll);

//Separate Window Sebelah Kiri
//identifier |window |window |width in |height
//sub window |x location |y location |pixel |in pixel
subWindowKiri = glutCreateSubWindow(mainWindow, border ,border ,w/2-border*3/2,h-2*border);//w-2*border, h/2 - border*3/2);
glutDisplayFunc(renderSceneKiri);

//Separate Window Sebelah Kanan
subWindowKanan = glutCreateSubWindow(mainWindow, (w+border)/2,border,w/2-border*3/2,h-2*border);//w-2*border, h/2 - border*3/2);
glutDisplayFunc(renderSceneKanan);
glutMainLoop();

return(0);
}
Top of pagePrevious messageNext messageBottom of page Link to this message

M.H.

Rating: N/A
Votes: 0 (Vote!)

Posted on Monday, August 11, 2003 - 7:20 pm:   Edit PostDelete PostView Post/Check IPPrint Post

Have a look on Stereographics WWW ...
http://www.stereographics.com/
Thy have ther OpenGl sample codes showing what you need ...
My server with stereoscopic OpenGl tutorials is unfortunately down :-(
Top of pagePrevious messageNext messageBottom of page Link to this message

apit

Rating: N/A
Votes: 0 (Vote!)

Posted on Tuesday, August 12, 2003 - 7:51 am:   Edit PostDelete PostView Post/Check IPPrint Post

i wonder how to calculate stereo object?
i'll try modify the glulookat parameter and it's work..but it just my assume..i want the real calculation... can you help me with this problem.. i'll try surfing at the stereographics website but not really help me..(for beginner like ne perhaps..) ...

Add Your Message Here
Post:
Bold text Italics Underline Create a hyperlink Insert a clipart image

Username: Posting Information:
This is a private posting area. Only registered users and moderators may post messages here.
Password:
Options: Enable HTML code in message
Automatically activate URLs in message
Action:

Topics | Last Day | Last Week | Tree View | Search | User List | Help/Instructions | Program Credits Administration