Show Posts
|
|
Pages: [1]
|
|
2
|
Java Game APIs & Engines / JOGL Development / Can someone help find the bug here?
|
on: 2006-04-20 13:28:02
|
|
This original from my c++ code was an inclass quiz...the java version I'm doing just for the heck of it. Not for a grade. Can someone point out what I need to do to get display draw Triangle in a loop - should print the # of triangles specified by the variable "num"
thanks..Bernie
import javax.media.opengl.*; import javax.swing.*;
public class Quiz1{
public static void main (String []args){ final int num = 1; JFrame.setDefaultLookAndFeelDecorated(true); JFrame jframe = new JFrame(Quiz1.class.getSimpleName()); jframe.setSize(500,500); jframe.setLocationRelativeTo(null);//center of screen GLCanvas canvas = new GLCanvas(); canvas.addGLEventListener(new GLEventListener(){ public void init(GLAutoDrawable drawable){} public void display(GLAutoDrawable drawable){ GL gl = drawable.getGL(); for (int i = 0; i< num; i++){ gl.glPushMatrix(); gl.glScalef(1/num,1/num,1); gl.glTranslatef((1/num*i), 0, 0); drawTriangle(); gl.glPopMatrix(); } } public void drawTriangle(){ gl.glClearColor(0.0f,0.0f,0.0f,0.0f); gl.glClear(GL.GL_COLOR_BUFFER_BIT); gl.glColor3f(1.0f,1.0f,0.0f); gl.glMatrixMode(GL.GL_PROJECTION); gl.glLoadIsentity(); gl.glOrtho2D(0,1,0,1); gl.glBegin(GL.GL_POLYGON); gl.glVertex2f(0.0,0.0); gl.glVertex2f(.5,1.0); gl.glVertex2f(1.0,0.0); gl.glEnd(); gl.glFlush(); } public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {} public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged){} }); jframe.add(canvas); jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jframe.setVisible(true); } }
|
|
|
|
|
4
|
Java Game APIs & Engines / JOGL Development / GLDisplay error
|
on: 2006-03-29 18:43:25
|
|
Hi all, what do I need to change not to get this error?
@hum301-09 ~]$ javac Lesson01.java Lesson01.java:10: cannot find symbol symbol : class GLDisplay location: class Lesson01 GLDisplay neheGLDisplay = GLDisplay.createGLDisplay("Lesson 01: An OpenGL Window"); ^ Lesson01.java:10: cannot find symbol symbol : variable GLDisplay location: class Lesson01 GLDisplay neheGLDisplay = GLDisplay.createGLDisplay("Lesson 01: An OpenGL Window"); ^
|
|
|
|
|
6
|
Java Game APIs & Engines / JOGL Development / NeHe tutorials for JoGL
|
on: 2006-03-24 03:45:18
|
|
hi all.. having recently installed the JOGL libraries on Ubuntu, I still dont have it working. I get a lot of "depreciated" this and that when trying NEHE tutorials. Are they in fact out of date with the current standard?
thanks, bernie
|
|
|
|
|
8
|
Java Game APIs & Engines / JOGL Development / My first JOGL program ...advice anyone?
|
on: 2006-03-14 19:28:57
|
|
hi folks...question: this program doesnt work yet, what's wrong with it... this is my first Java program with JOGL (i've only been programming for 6months in my life, so I'm new at this. any advice will be appreciated.)
import java.awt.*; import java.awt.event.*; import net.java.games.jogl.*; import javax.*; public class Simple { public static void main (Strng args []){
Frame simpleFrame = new Frame ("simple"); //awt window GLCapabilities glc = new GLCapabilities();//config OPen GL glc.setDoubleBuffered(false); GLCanvas drawable = GLDrawableFactory.getFactory().createGLCanvas(glc); drawable.addGLEventListener(new simpleRnderer()); simpleFrame.add(drawable);
simpleFrame.setLocation(100,100); simpleFrame.setSize(500,500); simpleFrame.show();}
public void init(GLDrawable drawable){ GL gl = drawable.getGL(); GLU glu = drawable.getGLU();
gl.glClearColor(0f,0f,0f,0f); glglColor3f(1.0f,1.0f,1.0f,1.0f);
gl.glMatrixMode(GL.GL_PROJECTION); gl.glLoadIdentity(); gl.glOrtho(-1.0,1.0,-1.0,1.0,1.0); }
static class SimpleRenderer implements GLEventListener{ public void display(GlDrawable drawable){ GL gl = drawable.getGL(); GLU glu = drawable.getGLU(); gl.glClear(GL.GL_COLOR_BUFFER_BIT); gl.glBegin(GL.GL_POLYGON); gl.glVertex2f(-0.5f,-0.5f); gl.glVertex2f(-0.5f,0.5f); gl.glVertex2f(0.5f,0.5f); gl.glEnd(); gl.glFlush(); } } }
|
|
|
|
|
9
|
Java Game APIs & Engines / JOGL Development / Re: Rotation and Translation
|
on: 2006-03-07 17:09:30
|
So, here's some code, but what this does, every time I resize the window, It re calculates the origin, and moves right off the screen.. so what gives....thanks bernie (yes, I know its c code, but you people are so nice  ) #include <iostream> #include <cstdlib> #include <glut.h> #include <math.h> const float DEG2RAD = 3.1416/180; void init(void){ glClearColor(1.0,1.0,1.0,0.0); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0,1.0,0,1.0); glMatrixMode (GL_MODELVIEW); glLoadIdentity(); } void disp(void){ glClear(GL_COLOR_BUFFER_BIT); glColor3f(0.0,0.0,0.0); float xradius = 0.25; float yradius = 0.125; glBegin(GL_LINE_LOOP); for (int i = 0; i<360; i++){ float degInRad = i*DEG2RAD; glVertex2f(cos(degInRad)*xradius, sin(degInRad)*yradius); } glEnd(); glRotatef (45,0,0,1); glTranslatef(.75,.25,0); glBegin(GL_LINE_LOOP); for (int j = 0; j<360; j++){ float degInRad = j*DEG2RAD; glVertex2f(cos(degInRad)*xradius, sin(degInRad)*yradius); } glEnd(); glFlush(); } void main(int argc, char** argv){ glutInit (&argc, argv); // Initialize GLUT. glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); // Set display mode. glutInitWindowPosition (50, 100); // Set top-left display-window position. glutInitWindowSize (400, 300); // Set display-window width and height. glutCreateWindow ("ellipse"); // Create display window. init ( ); // Execute initialization procedure. glutDisplayFunc (disp); // Send graphics to display window. glutMainLoop ( ); // Display everything and wait. }
|
|
|
|
|
10
|
Java Game APIs & Engines / JOGL Development / Rotation and Translation
|
on: 2006-03-07 16:40:40
|
|
Hi people, please help me understand how to make the following:
I have an ellipse, centered at the origin, defined by the parametric equation (x (t ), y (t )) = (a cos(t), b(sin(t)), t being from {0, 2pi}
what is the parametric representation of the same figure translated by +2 along the x-axis, +3 along the y-axis and then rotated by 45 degrees
I get,
x' = cos(pi/4) -sin(pi/4) |x| + |2| y' sin(pi/4) cos(pi/4) |y| |3|
to be read as the matrix multiplication of cos, -sin by original coordinates plus the vector 2, 3 yielding the new coordinates....but this is not in homogeneous coordinates....how to make it homogeneous.....
and any additional info will be appreciated for the Math-phobic among us...
thanks,
bernie
|
|
|
|
|
17
|
Java Game APIs & Engines / JOGL Development / Re: Making the transition from C++ to Java
|
on: 2006-02-19 02:27:48
|
|
Below, my current C++ code for this assignment (see pdf attachement earlier) ..please comment if you are willing to look at c code thanks bernie
ps, yes, I've pulled down the Gears demo and am getting into it. Thanks
#include<iostream> #include <cstdlib> #include <glut.h> using namespace std;
class Point{ double x; double y; Point (double x=0, double y=0){this.x=x;this.y=y;} //constructor connects x and y values of the calling object //'this'
};
class House{ private: double w; //width double h; // height double p; //the peak Point O; //House origin. bottom left corner of the shell of //the house
public: House(double w, double h, double p, Point origin); // constructor //for a house
/* void draw_shell(); void draw_door(); void draw_chimney(); void draw_window(); */
void draw_shell(){ glClear (GL_COLOR_BUFFER_BIT); glColor3f (0.0, 0.0, 1.0); . glBegin (GL_LINES); glVertex2i(O.x, O.y); //vertices of shell in terms of origin(O.x, O.y) glVertex2i(O.x, O.y+h); glVertex2i(O.x+w, O.y); glVertex2i(O.x+(1/2)w, p); glVertex2i(O.x+w, O.y+h);
glEnd ( ); glFlush ( ); }
void draw_door(){ glClear (GL_COLOR_BUFFER_BIT); glColor3f (0.0, 0.0, 1.0); . glBegin (GL_LINES); glVertex2i(O.x+(1/8)w, O.y); glVeretex2i(O.x+(1/8)w, O.y+h); glVertex2i(O.x+(1/4)w, O.y+h); glVertex2i(O.x+(1/4)w, O.y);
glEnd ( ); glFlush ( ); } void draw_window(){ glClear (GL_COLOR_BUFFER_BIT); glColor3f (0.0, 0.0, 1.0); . glBegin (GL_LINES); glVertex2i(O.x+(5/8)w, O.y+(1/2)h); glVertex2i(O.x+(5/8)w, O.y+(3/4)h); glVertex2i(O.x+(7/8)w, O.y+(3/4)h); glVertex2i(O.x+(7/8)w, O.y+(1/2)h);
glEnd ( ); glFlush ( ); }
void draw_chimney(){ glClear (GL_COLOR_BUFFER_BIT); glColor3f (0.0, 0.0, 1.0); . glBegin (GL_LINES); glVertex2i(O.x+(1/8)w, O.y+((1/4)*(p-h)+h); glVertex2i(O.x+(1/8)w, O.y+p); glVertex2i(O.x+(3/16)w, O.y+p); glVertex2i(O.x+(3/16)w, O.y+((3/8)*(p-h)+h);
glEnd ( ); glFlush ( ); }
void init(){
glClearColor (1.0, .0, .0, 0.6); //glMatrixMode (GL_PROJECTION); gluOrtho2D (0.0, 200.0, 0.0, 200.0); }
void display_house(){ draw_shell(); draw_door(); draw_window(); draw_chimney();
}
void display(){ House h1(100, 150, 200, Point (0,0) ); House h2 (100, 200, 280, Point(150,0) ); House h3 (50, 70, 90, Point (0, 300) ); //some gl code
h1.display_house(); //maybe some more gl code h2.display_house(); h3.display_house(); }
};
void main (int argc, char** argv) { Point origin(20,20); House h4(2, 10, 15, origin); glutInit (&argc, argv); glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); glutInitWindowPosition (50, 100); glutInitWindowSize (400, 300); glutCreateWindow ("Bernie Project 1"); //init ( ); // glutDisplayFunc (display_house); glutMainLoop ( ); }
|
|
|
|
|
22
|
Java Game APIs & Engines / JOGL Development / Re: Making the transition from C++ to Java
|
on: 2006-02-17 19:03:30
|
|
Hi, no, I havent done any Java before, thus I am more like asking, what Development environments are you using, how to install a jogl library to said environment, and are the functions the same...you could say, in a sense I need help more with Java than with open GL. I think that is reasonable. Meanwhile I'm doing the assignment in C++ myself. So, I guess if someone could just help me get an openGL for Java environment up and running, that would be good.
bernie
|
|
|
|
|
23
|
Java Game APIs & Engines / JOGL Development / Making the transition from C++ to Java
|
on: 2006-02-17 17:14:42
|
|
Hello everyone, I'm a student in a computer graphics course at SUNY Newpaltz, and our instructor is using C++. He said he will give extra credit if I can learn to do it with Java, but he will provide no support, as his focus is C. He has given me permission to use any help I can find to do it in Java, and so I come to you people. I attach a file of my current exercise I wish to accomplish with OpenGL for your help and viewing pleasure..Its to draw a simple house.
Most appreciatively,
bernie
|
|
|
|
|