[visionegg] Anti-aliasing - ibook G4
- From: Kevin MacKenzie <kjmacken@xxxxxxxxxx>
- To: visionegg@xxxxxxxxxxxxx
- Date: Wed, 01 Sep 2004 17:29:17 -0400
Hi everyone,
I'm hoping an OpenGL/OS X Guru maybe able to help me out.
I have pasted some example code, which simply opens an OpenGL window,
and sticks some red/green pixels onto the screen for the creation of a
stereogram.
I have simplified things for the example to illustrate the aliasing
problem I'm having.
I am under the impression (possibly wrong), that OpenGL will handle
anti-aliasing points that I am passing to the video card by using the
following methods:
[code]
glEnable(GL_POINT_SMOOTH) # hopefully this will enable antialiased
points
glHint( GL_POINT_SMOOTH_HINT, GL_NICEST )
[/code]
However, when the image is displayed, and viewed through red/green
glasses, it is apparent that there is a huge amount of disparity noise,
from aliasing the pixel placement.
So, I'm wondering if there needs to be some hardware enabled
anti-aliasing function? I have been scouring the web to try to find out
how to access the features of the Radeon Mobility 9200 that comes with
the iBook, but to no avail. If anyone has any hints on how to access
these card features, or how to better handle pixel aliasing using
Python/OpenGL etc. I would be very appreciative.
Thanks a lot,
kjm
------------------------------------------------------------------------------------------------
[code begins here]
#! /usr/bin/env python
FullScreen = 0;
################################################
# going to start with a simple rds.
###############################################################
# import required libraries
import sys
import string
from Numeric import *
from RandomArray import *
####################
# openGL libraries
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *
###############################################################
# Some misc paramaters
# define the ESC key
ESCAPE = '\033'
###############################################################
NUMDOTS = 1000;
x = random(NUMDOTS)*2-1;
y = random(NUMDOTS)*2- 1;
# handle keypress event
def Keyboard(*args):
global window
if args[0]==ESCAPE:
sys.exit()
# define a reshape function, in case it's needed
def Reshape(w,h):
if h == 0:
h = 1
def stereoproj(x,y):
xl = x
xr = x - 0.015
return xl,xr
def display(*args):
global x,y
# Calculate the disp. x array
(xl,xr) = stereoproj(x,y);
"""print shape(xl2), shape(y2)
Commented debugging code
print "size of (xl) = ", shape((xl))
print shape((y))
"""
xl = transpose([xl])
xr = transpose([xr])
yim = transpose([y])
#print "shape xl = ", shape(xl)
#print "shape xr = ", shape(xr)
#print "shape y = ", shape(yim)
lim = concatenate([xl,yim],1)
rim = concatenate([xr,yim],1)
#print lim - rim ;
#print "shape lim = ",shape(lim)
#print "shape rim = ",shape(rim)
glEnable(GL_POINT_SMOOTH) # hopefully this will enable antialiased
points
glHint( GL_POINT_SMOOTH_HINT, GL_NICEST )
# enabling these features does not seem to accomplish what I want.
glClearColor(0.0,0.0,0.0,0.0) # RGBA
glClear( GL_COLOR_BUFFER_BIT )
# draw (xl,y) on screen
glColor3f(1.0,0.0,0.0) # red
glVertexPointerd(lim)
glEnableClientState( GL_VERTEX_ARRAY )
glDrawArrays( GL_POINTS, 0, len(lim))
glDisableClientState( GL_VERTEX_ARRAY )
#glFlush()
#glutSwapBuffers
# draw (xr,y) on screen
glColor3f(0.0,1.0,0.0) # green
glVertexPointerd(rim)
glEnableClientState( GL_VERTEX_ARRAY )
glDrawArrays( GL_POINTS, 0, len(rim))
glDisableClientState( GL_VERTEX_ARRAY )
glFlush()
glutSwapBuffers()
def setup_viewport():
glMatrixMode( GL_PROJECTION )
glLoadIdentity()
def main():
glutInit( sys.argv )
glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGB )
glutInitWindowSize(600,600)
glutCreateWindow( 'RDS ')
setup_viewport()
glutReshapeFunc(Reshape)
glutDisplayFunc(display)
if FullScreen == 1:
glutFullScreen()
#glutIdleFunc(display)
glutKeyboardFunc( Keyboard )
glutMainLoop()
print "Hold on to your butts"
print "Hit ESC to exit."
# run the shit
main()
======================================
The Vision Egg mailing list
Archives: http://www.freelists.org/archives/visionegg
Website: http://www.visionegg.org/mailinglist.html
Other related posts:
- » [visionegg] Anti-aliasing - ibook G4
#! /usr/bin/env python FullScreen = 0; ################################################ # going to start with a simple rds.
############################################################### # import required libraries import sys import string
def display(*args):
"""print shape(xl2), shape(y2) Commented debugging code print "size of (xl) = ", shape((xl)) print shape((y)) """
#print "shape xl = ", shape(xl) #print "shape xr = ", shape(xr) #print "shape y = ", shape(yim)
#print "shape lim = ",shape(lim) #print "shape rim = ",shape(rim)
# draw (xl,y) on screen glColor3f(1.0,0.0,0.0) # red glVertexPointerd(lim) glEnableClientState( GL_VERTEX_ARRAY ) glDrawArrays( GL_POINTS, 0, len(lim)) glDisableClientState( GL_VERTEX_ARRAY ) #glFlush() #glutSwapBuffers
# draw (xr,y) on screen glColor3f(0.0,1.0,0.0) # green glVertexPointerd(rim) glEnableClientState( GL_VERTEX_ARRAY ) glDrawArrays( GL_POINTS, 0, len(rim)) glDisableClientState( GL_VERTEX_ARRAY ) glFlush() glutSwapBuffers()
print "Hold on to your butts" print "Hit ESC to exit."