Unexpected OpenGL Simple Movement

May 28, 2014

I am new to DreamInCode! I was creating a game using OpenGL (and slick for textures).

Using Vector3f, I make coordinates to where my camera is camera'ing (and rotation).

It was working... until I modified something. I only added shaders. When I took the shaders off I think I might of accidentally deleted something. Nonetheless the code looks perfect to me.

On the method "input()" everything runs. No errors are thrown anywhere. I have syso'd the hell outa my code. It shows no signs of breaks. I can, however, move elements I put into my program. I am 100% sure that no other class is breaking my game (soon to be).

What you should look out for: I am not really sure about the glLoadIdentity()'s and glMatrixMode(). I am, knowing a good part of, thinking it could be gluViewPort....

My problem: Can't move my camera even tho it was working before.

package com.Hydroque.OpenGlTest;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.util.glu.GLU.gluPerspective;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;

[Code] ....

View Replies


ADVERTISEMENT

Textures And OpenGL With Java

Mar 7, 2014

I was trying to understand Textures and OpenGL with Java. but the tutorials I find cover such a horribly broad area X_x.Basically I can get a window up, initialize openGL, and draw many repeating blocks on my screen.

I dont specifically care about minecraft. but I would like to learn how to get Many many blocks on the screenand how to apply more than one texture to a block. I cant seem to load two textures at a time without errors. I have a dumb while loop that includes a few For loops that repeat the blocks.I guess I should learn how to use Arrays to automate the block process ? Im not sure. I started reading about object buffers, but im not sure.

public static void initDisplay()
{
try {
Display.setFullscreen(true);
Display.setVSyncEnabled(true); // Drastically effects updates per second, Camera movement lowers by 98%

[code]....

View Replies View Related

JavaFX 2.0 :: Multiple Display Using OpenGL-ES2

Jul 15, 2014

I would like to know whether multiple displays are supported under (Windows/Linux/mac) when we use opengl-es2 pipeline?

View Replies View Related

JavaFX 2.0 :: Force Prism To Use OpenGL Version 4.1

Jun 25, 2014

Setting VM argument prism.verbose=true gives some insight of what happens.

There i see an old openGL version is used on OSX 10.9:
 
Graphics Vendor: ATI Technologies Inc.
Renderer: AMD Radeon HD 6630M OpenGL Engine
Version: 2.1 ATI-1.22.28
 
How do i force prism to a newer openGL version?

View Replies View Related

Swing/AWT/SWT :: How To Turn On Light Through ActionPerformed With OpenGL Java

Apr 29, 2015

I'm writing a java program with opengl and I'm trying to get it where the user would select something like lighting on in a JMenu and then it would turn the lighting on in the house/barn... I have a method called LightOn that I put gl.glEnable(gl.GL_LIGHT0); but it just doesn't seem to turn on when I call it from the action performed... Is there something I'm missing from my code that I'm supposed to use instead since I have tried it with a boolean.. So the boolean starts off as false and when the JMenuItem is clicked the actionPerformed will turn the boolean to true and call the method LightOn. In the display method I have what the light is supposed to be

Snippet of code in display method for lighting:

float [] whiteLight = {1.0f, 1.0f, 1.0f, 1.0f};
float [] ambientLight = {0.1f, 0.1f, 0.1f, 1.0f}; //default
gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_DIFFUSE, whiteLight,0);
gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_SPECULAR, whiteLight,0);
gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_AMBIENT, ambientLight,0);
float [] lightPosition = {25, 25, 25, 1};

[Code] ....

View Replies View Related

How To Attach OpenGL Display To JFrame And Dispose Off It Properly

Nov 12, 2014

How can i attach the OpenGl display to a JFrame and so that when i close the JFrame is destroys the display? Here is my code so far:

package test.core;
import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Component;
import java.awt.event.WindowAdapter;

[Code] .....

I had the opengl display attach to the JFrame before i did the runnable. But after adding the runnable the display now shows up the same size as my screen size. I have tried rearranging the

canvas.setSize();
and the
frame.setSize();

but nothing changes the opengl display is still the same size and when i try to close the JFrame first rather then close the display first i get this error:

Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: From thread Thread[AWT-EventQueue-0,6,main]: Thread[main,5,main] already has the context current

which points me to my

Display.destroy();

which im guessing is telling me that i am not properly disposing the display? How to attach the opengl display to the JFrame and fix the error above?

View Replies View Related

Swing/AWT/SWT :: How To Rotate 2D Square Using Maths Equations Through OpenGL

Feb 23, 2015

So I need to create a square and make it rotate when the letter R is pressed and then make it stop when the letter R is pressed again. I need make it rotate using a maths equation that I can't figure it out myself right this moment.

Code for square:

package lab2;
public class Square {
public double [][] vertices = new double[4][2]; //not good to make this public
public Square(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) {
vertices[0][0]=x1;
vertices[0][1]=y1;
vertices[1][0]=x2;

[Code] ....

In the Square code there is a method to write an equation to rotate it but I can't figure that part out ....

View Replies View Related

Increment Array And Got Unexpected Result

Aug 16, 2014

Java Code:

char array[] = new char[10];
int i = 0;
array[i++] = (char)('A' + i);
System.out.println("char for array is: " + array[0]); mh_sh_highlight_all('java');

However, the result for array[0] is B. Not A. from my understanding, the array[0] should be 'A'.

View Replies View Related

Creating A Thread - Unexpected Output

Mar 18, 2014

Java Code:

package Threads;
public class Threads1 implements Runnable {
public void run(){
System.out.println("
* * * * *
");
}
public static void main(String[] args) {

[code]...

Java Code:

new Thread(new Threads1()).start(); mh_sh_highlight_all('java');

should execute the thread associated with the run() and then the control should return to the next statement in the calling thread (the thread from which the other thread (associated with run()) was called); isn't it?

View Replies View Related

Increment Array And Got Unexpected Result

Aug 16, 2014

char array[] = new char[10];
int i = 0;
array[i++] = (char)('A' + i);
System.out.println("char for array is: " + array[0]);

However, the result for array[0] is B. Not A. from my understanding, the array[0] should be 'A'.

View Replies View Related

Unexpected Type - A Returned Variable Required

Apr 2, 2014

I'm making a Hangman program for Java, here's my code:

import java.util.Scanner;
public class Hangman {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
String answerWord = WordList.getWord();

[Code] .....

The Compiler gives me this only error:

Hangman.java:39: error: unexpected type
displayWord.charAt(i)=userInput.charAt(0);
^
required: variable
found: value

I understand that charAt returns i as a value and not a variable. What do I use to return a variable as I intended?

View Replies View Related

IWAB0014E Unexpected Exception Occurred In Web Service Sample Program

Apr 8, 2014

I first time tried Java web service sample example using eclipse with axis2. First i wrote the provider class. Then by clicking create Web Service from the provider class It will show the following error "IWAB0014E Unexpected exception occurred." I have attached the screenshot for reference.

View Replies View Related

Converting Positive Binary Inputs Into Hex - Unexpected Output Java

Sep 30, 2014

I am trying to write a program for converting positive binary inputs into hex. in the hex output the point (".")is missing.

Suppose my expected output is e7.6 , but i am getting e76

only the "." is missing.

here is my BinToHex class..

import java.io.*;
public class BinToHex {
double tempDec,fractionpart;
long longofintpart,templongDec;
String input ="11100111.011";
String hexOutput=null,tempDecString,hex = null;
static int i = 1;

[Code] ....

View Replies View Related

Program For Converting Positive Binary Inputs Into Hex - Unexpected Output Java

Sep 30, 2014

I am trying to write a program for converting positive binary inputs into hex. in the hex output the point (".")is missing.

Suppose my expected output is e7.6 , but i am getting e76.

Only the "." is missing.

Here is my BinToHex class..

import java.io.*;
public class BinToHex {
double tempDec,fractionpart;
long longofintpart,templongDec;
String inpu ="11100111.011";
String hexOutput=null,tempDecString,hex = null;
 
[Code] .....

Here is how decimal fraction is converted into hex or here too...

View Replies View Related

Write Data For Three Products To Random Access File - Unexpected EOFException

Jul 11, 2014

I'm trying to write data for three products to a random access file, but I have a problem. Each product has a code and a price. After writing them to my file, I want to get to the second field or product. I do this by getting the length for each record, and multiplying it by the field number I want to go to. I use the result for the seek() method of the RandomAccessFile object. It is giving me an EOFException, but when I use 0 for the seek method i get the data for the first poduct or field.

Java Code:

public static void main(String[] args) {
final int RECORD_LENGTH = 16;
try(RandomAccessFile productsOutput = new RandomAccessFile("C:UsersalfonsoDesktopBinaryTestRandom.ran", "rw")) {
String[] codes = {"java", "jsps", "txtp"};
double[] prices = {49.5, 19.9, 29.9};
for(int i = 0; i < codes.length; i++) {

[Code] .....

View Replies View Related

Mouse Movement Code

Feb 11, 2014

I have been working on this mouse movement code that detects which direction the mouse moves in hope to use it in a game. The only problem is that I can not figure out how to make it move to the other side of the screen so I could continue turning to the right or left without having to stop. How would I actually get the x and y coordinants of the mouse to change?

PHP Code: if(x == xscreen){
//set x to 0
}else if(x == 0){
//set x to xscreen
}else if(y == yscreen){
//set y to 0
}else if(y == 0){
//set y to yscreen
} mh_sh_highlight_all('php');

View Replies View Related

How To Make Smoother Movement

Jan 23, 2014

First, I have a figure that moves around the screen. It uses keylisteners and just subtracts or adds pixels. However, I notice the movement is not smooth at all. It is very rigid and laggy movement. How can I make it smoother movement?

Second, you get three lives in the game. The lives are subtracting correctly, but I want the game to say "GAME OVER" on a dialog box. How would I get this to happen? My JFrame and my life int are in separate classes. I know I should use an if statement, saying if lives are at or less than zero, open the box, but how do I open the box?

Third, I want to display the time on the screen. I have a swing timer, but how do I put it on the screen? DrawString is not working for me.

Fourth, I want to set an icon for the game, the code is running, but not doing anything.

Java Code: frame.setIconImage(Toolkit.getDefaultToolkit().getImage("/Users/MW/Downloads/petericon.jpg")); mh_sh_highlight_all('java');

View Replies View Related

How To Do Movement In Text Based Game

Feb 13, 2015

I'm relatively new to Java, I'm trying to create a text based game, like those old ones where you type "north" or "east" to move as such, and "look" to inspect the area. My only problem thus far has been trying to figure out just how I should... "structure?" the movement. As in, what's the best overall way to approach this? I've tried making a new method for every area and just passing a variable called "location," but along with passing the inventory and stat arrays, it's just become messy. Or is this a good way to do it? I have a separate method for when the player enters something, but then how will it know which description to give when the player types "look?"

View Replies View Related

Snake Game Movement Algorithm

Jun 16, 2014

I am working on replicating this project: [URL] ....

What is wrong with the moveSnake method and the for loop within it?

View Replies View Related

Limit Object Movement Within A Window

Aug 31, 2014

I just started to learn Java. In my program, I created a GRect(paddle) and I would like to move it on the x axis whenever the mouse is moved.

import acm.graphics.*;
import acm.program.*;
import acm.util.*;
import java.awt.*;
import java.awt.event.*;
public class BreakoutClass extends GraphicsProgram {
/** Width and height of application window in pixels */
private static final int WIDTH = 400;
private static final int HEIGHT = 600;

[code]....

In this case, whenever the paddle reaches the right edge of the screen, it doesn't move off the windows, but it stops moving (even if you move the mouse).

View Replies View Related

Matrix Icon / Button Movement

Apr 30, 2015

I'm working on making a game in JAVA. To be brief, the game is on a 6x6 matrix called "blocks[][]". The game has two players and the objective is to capture the enemies pieces by moving your piece onto there's. The players do this by moving one piece per turn either forward/backward (Vertically) or right/left (horizontal) movements. Essentially checkers without jumps.I'm not very far into the development process here. So far I have the game board created and the pieces load by clicking the "Start" button (handled by the refresh function). However I'm having a few problems... Namely moving the pieces effectively at the moment.

Right now there's a lot to do:

(1) - Implement a turn system,
(2) - Only allow a player to click their pieces (I've a validation function already in place to only permit valid moves [horizontal/vertical only]),
(3) - getting the pieces to actually "move" what I mean by this is a player selects the piece they want to move, then they select the spot they want to move to and the icon I have placed on the button is supposed to be added to the new square and the icon for its previous position is to be made null.

Please see the "actionPerformed" section to see exactly what I'm trying to do and hopefully as well see what I'm missing as to why it is not working at the moment... Also see under the Refresh function where I commented out the for loops to add the pieces. I did this because it was resulting in an ArrayOutofBounds error so I just wrote each spot out manually where I wanted them to start.

/* Ghosts *
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;
import java.util.Random;
import javax.swing.JButton;
import javax.swing.border.*;
import java.io.*;

[code].....

View Replies View Related

Basic Sprite Character Movement

Aug 18, 2014

how I would go about having a moving sprite on a page, such as a virtual pet kind of thing. I've tried searching for it through the years and I've tried it with what I know on my own, but things just act up every time. Either:

A.) The sprite moves (respondent to key strokes, of course), but leaves a trail of its image behind itself.

B.) The background image writes, but for some reason the second image does not write, or is lost behind the background.

I'm sure these are simple issues for most of you, but I've tried going about this for a while now with no luck. What I'm trying to do I'm trying to write a virtual pet game, and I would eventually love to make it move around randomly like an A.I. that's pathfinding, but I've got ideas about that, just I need to know how to make it move period first, everything else I think I could figure out on my own.

View Replies View Related

Fading Trail And Random Movement Coding?

Oct 30, 2014

I need the following key controlled ellipse to leave a trail behind that vanishes after 10 frames. Also, I need to create a random moving ellipse not related to the preexisting one. How to separate the two ellipses ...

Current code:

boolean left, right, backward, forward;
boolean SPEED;
 PVector pos = new PVector(680, 400);
 void setup() {
size (680,400);
fill (0 ,0,0);
frameRate(100);
noCursor();

[Code] .....

View Replies View Related

Alien Movement In Space Invaders Game

Apr 13, 2014

I'm working on this space invaders game and I've been stuck trying to get the alien spaceships to move down in one group. The way we have to design the game is we have to implement at least these 3 classes. These classes are GameData,GamePanel, and Animator. GameData is all the action figures/models in the game. GamePanel draws all game action figures/ models on the screen. Animator updates periodicaly action figures positions,sizes, colors etc. I can get the aliens to move right but once they hit the end of the canvas I cannot figure out how to get them to move as a group down and then begin moving left. I tried to add alien objects to the GameFigures list and then have the update method in the Alien class be responsible for moving the alien ships, but I couldn't figure out how to make it work. So then I made an alienFigures list in the GameData class and I still cannot figure out what to do. Here is the GameData class

import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;

[code]....

View Replies View Related

Make Mouse Cursor Visible On Movement

Mar 25, 2014

I've been creating a digital clock using Java, and have made the mouse cursor invisible after a set period of time (40-seconds) and had the thought to make it visible again if mouse was moved.

Here's the code that makes it invisible:

ActionListener mouseTimeout = new ActionListener() {
public void actionPerformed(ActionEvent e) {
setCursor(blankCursor);
}
};
/* Make mouse cursor disappear after 40 seconds */
Timer mTimeout = new Timer(40000, mouseTimeout);
mTimeout.start();

And here is what I have so far for making it visible again:

MouseMotionListener mouse = new MouseMotionListener() {
@Override
public void mouseDragged(MouseEvent e)
{
}
@Override
public void mouseMoved(MouseEvent e)
{
}
};

I have tried using "setCursor(DEFAULT_CURSOR)" but NetBeans says that it "cannot find symbol" .....

View Replies View Related

Maze Game - Tracking Objects / Limit Movement

Jan 26, 2015

I made a kind of maze game that includes the class keylistener and orients a object, i can't find where the program tracks this object (where its x and y coordinates are). So now my object can move freely through all walls and i want it to bounce back or at least something to happen when the object reaches a wall.

I want to find a way to limit my objects movement and because i cant find where the coordinates or variable for this object is i cannot limit its movement

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved