ThrottleMonkey
2003.03.12, 09:09 PM
Hi again :)
I've been messing around with the NEHE tutorials and have been able to draw all sorts of neato colored shapes and stuff.
I've been doing so with just typing the below kind of code (my sample code) from lesson 4 and I've been happy with it.
Now, having been able to do that (and totally forgetting that at the bottom of each NEHE page, they have the Cocoa version of the code... so I've been doing things kind of bland.
What am I getting at? Here it is:
I don't understand everything and I don't claim to... but is there an easier way to make objects rotate?
Having looked at the Cocoa code, they do all the "full screen" stuff that makes everything complicated.
Here's some sample code of mine:
-----
#import "MyOpenGLView.h"
#include <OpenGL/gl.h>
@implementation MyOpenGLView
- (void) drawRect: (NSRect) bounds
{
glClearColor( 1.0, 1.0, 1.0, 1.0 ) ;
glClear( GL_COLOR_BUFFER_BIT ) ;
glBegin(GL_TRIANGLES);
glColor3f( 0.0, 0.0, 1.0 ) ;
glVertex3f( 0.0, 1.0, 0.0);
glColor3f( 0.0, 1.0, 0.0 ) ;
glVertex3f(-1.0,-1.0, 0.0);
glColor3f( 1.0, 0.0, 0.0 ) ;
glVertex3f( 1.0,-1.0, 0.0);
glEnd() ;
glColor3f( 0.5, 0.5, 1.0 ) ;
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
glBegin(GL_QUADS);
glVertex3f (0.25, 0.25, 0.0);
glVertex3f (0.75, 0.25, 0.0);
glVertex3f (0.75, 0.75, 0.0);
glVertex3f (0.25, 0.75, 0.0);
glEnd();
glFlush();
}
@end
------
Now, it would seem pretty easy to add some kind of increment (in the samples, they have "rtri" and "rquad") without having to do all the "full screen" checks that NEHE tutorials do.
Is all that stuff really needed or can you just add:
rquad+=0.2f;
and have some goto routine that starts a loop and keeps redrawing it?
Or do I need to sit down and actually learn what all going to "full screen" does?
I've been messing around with the NEHE tutorials and have been able to draw all sorts of neato colored shapes and stuff.
I've been doing so with just typing the below kind of code (my sample code) from lesson 4 and I've been happy with it.
Now, having been able to do that (and totally forgetting that at the bottom of each NEHE page, they have the Cocoa version of the code... so I've been doing things kind of bland.
What am I getting at? Here it is:
I don't understand everything and I don't claim to... but is there an easier way to make objects rotate?
Having looked at the Cocoa code, they do all the "full screen" stuff that makes everything complicated.
Here's some sample code of mine:
-----
#import "MyOpenGLView.h"
#include <OpenGL/gl.h>
@implementation MyOpenGLView
- (void) drawRect: (NSRect) bounds
{
glClearColor( 1.0, 1.0, 1.0, 1.0 ) ;
glClear( GL_COLOR_BUFFER_BIT ) ;
glBegin(GL_TRIANGLES);
glColor3f( 0.0, 0.0, 1.0 ) ;
glVertex3f( 0.0, 1.0, 0.0);
glColor3f( 0.0, 1.0, 0.0 ) ;
glVertex3f(-1.0,-1.0, 0.0);
glColor3f( 1.0, 0.0, 0.0 ) ;
glVertex3f( 1.0,-1.0, 0.0);
glEnd() ;
glColor3f( 0.5, 0.5, 1.0 ) ;
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
glBegin(GL_QUADS);
glVertex3f (0.25, 0.25, 0.0);
glVertex3f (0.75, 0.25, 0.0);
glVertex3f (0.75, 0.75, 0.0);
glVertex3f (0.25, 0.75, 0.0);
glEnd();
glFlush();
}
@end
------
Now, it would seem pretty easy to add some kind of increment (in the samples, they have "rtri" and "rquad") without having to do all the "full screen" checks that NEHE tutorials do.
Is all that stuff really needed or can you just add:
rquad+=0.2f;
and have some goto routine that starts a loop and keeps redrawing it?
Or do I need to sit down and actually learn what all going to "full screen" does?