Results 1 to 1 of 1
Thread: LWJGL - Where to go from here
- 06-27-2012, 05:37 AM #1
Member
- Join Date
- Mar 2012
- Posts
- 10
- Rep Power
- 0
LWJGL - Where to go from here
I know this much about LWJGL and I'd like to continue learning but I can't find anywhere good. I just want to know what to do from here. I'd like to be able to move the square around with the mouse or something like that.
Main.java:
Shape.java:Java Code:package com.butterfield.mitchell; import static org.lwjgl.opengl.GL11.*; //imports import org.lwjgl.LWJGLException; import org.lwjgl.opengl.Display; import org.lwjgl.opengl.DisplayMode; public class Main { //Global Variables public static final int WD = 800; //the width of the screen public static final int HT = 600; //The height of the screen public static final String Title = "LWJGL"; //The title DisplayMode dm = new DisplayMode(WD, HT); //Initializing the display mode public Main(){ initDisplay(); //function for initializing the display initGl(); //function for initializing OpenGL gameLoop(); //function for initializing the game loop } private void initGl(){ glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, WD, 0, HT, 1, -1); glMatrixMode(GL_MODELVIEW); } private void gameLoop(){ while(!Display.isCloseRequested()){ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //Clear the buffer bits glColor3f(0.0f, 0.0f, 1.0f); //set the colors glBegin(GL_QUADS); //Begin drawing quad Shape.drawGlQuad(100, 100, 200, 200); glEnd();//end drawing Display.update(); } Display.destroy(); //destroy the window and clean up the memory it used } private void initDisplay(){ try{ Display.setDisplayMode(dm); //set the display mode to the variable created above Display.setTitle(Title); //set title to variable created above Display.create(); //create the window }catch(LWJGLException e){ //Handles exceptions where the window is not created and prints the exception System.err.println("The window could not be created!"); e.printStackTrace(System.err); } } public static void main(String[] args){ Main m = new Main(); //creates an object for the java file which runs it } }
Java Code:package com.butterfield.mitchell; import static org.lwjgl.opengl.GL11.*; public class Shape { public static void drawGlQuad(float x, float y, float width, float height){ glVertex2f(x, y); glVertex2f(x + width, y); glVertex2f(x + width, y + height); glVertex2f(x, y + height); } }
Similar Threads
-
Hey please could someone help me with this lwjgl code
By Josh1666 in forum Advanced JavaReplies: 1Last Post: 05-12-2012, 06:36 PM -
LWJGL question
By Brandon's java thingy in forum Advanced JavaReplies: 4Last Post: 01-24-2012, 04:00 AM -
LWJGL Collison
By Brandon@JavaForums in forum Advanced JavaReplies: 4Last Post: 01-14-2012, 09:16 PM -
LWJGL help please
By Brandon@JavaForums in forum Advanced JavaReplies: 12Last Post: 12-31-2011, 10:19 AM -
lwjgl help PLEASE!
By Brandon in forum New To JavaReplies: 1Last Post: 10-06-2011, 06:11 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks