Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (583)
Games in Android Showcase (163)
games submitted by our members
Games in WIP (633)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1] 2 3 ... 19
1  Discussions / Miscellaneous Topics / Re: What are your current personal projects? on: 2015-05-25 19:28:06
Game engine in java. right now i'm trying to integrate JavaFX with opengl.
2  Java Game APIs & Engines / OpenGL Development / Re: texture problems on: 2015-05-22 19:58:32
Thanks, that worked.
3  Java Game APIs & Engines / OpenGL Development / texture problems on: 2015-05-22 18:47:23
I am using the following java code

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
157  
158  
159  
160  
161  
162  
163  
164  
165  
166  
167  
168  
169  
170  
171  
172  
173  
174  
175  
176  
177  
178  
179  
180  
181  
182  
183  
184  
185  
186  
187  
188  
189  
190  
191  
192  
193  
194  
195  
196  
197  
198  
199  
200  
201  
202  
203  
204  
205  
206  
207  
208  
209  
210  
211  
212  
213  
214  
215  
216  
217  
218  
219  
220  
221  
222  
223  
224  
225  
226  
227  
228  
229  
230  
231  
232  
233  
234  
235  
236  
237  
238  
239  
240  
241  
242  
243  
244  
245  
246  
247  
248  
249  
250  
251  
252  
253  
254  
255  
256  
257  
258  
259  
260  
261  
262  
263  
264  
265  
266  
267  
268  
269  
270  
271  
272  
273  
274  
275  
276  
277  
278  
279  
280  
281  
282  
283  
284  
285  
286  
287  
288  
289  
290  
package SPAGE.engine.gui;

import java.io.File;
import java.io.FileNotFoundException;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.util.Random;
import java.util.Scanner;

import javafx.application.Platform;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.Text;

import org.lwjgl.BufferUtils;
import org.lwjgl.glfw.Callbacks;
import org.lwjgl.glfw.GLFWErrorCallback;
import org.lwjgl.glfw.GLFWKeyCallback;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL13;
import org.lwjgl.opengl.GL20;
import org.lwjgl.opengl.GLContext;

import static org.lwjgl.glfw.GLFW.*;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL15.*;
import static org.lwjgl.opengl.GL20.*;
import static org.lwjgl.opengl.GL30.*;
import static org.lwjgl.opengl.GL31.*;
import static org.lwjgl.opengl.GL32.*;
import static org.lwjgl.opengl.GL33.*;
import static org.lwjgl.system.MemoryUtil.*;


public class glembedtest {
   
   private GLFWErrorCallback errorCallback = Callbacks.errorCallbackPrint(System.err);
   
   long window;
   
   private GLFWKeyCallback keyCallback = new GLFWKeyCallback() {
       @Override
       public void invoke(long window, int key, int scancode, int action, int mods) {
           if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) {
               glfwSetWindowShouldClose(window, GL_TRUE);
           }
       }
   };
   
   glStagePlatform plat = new glStagePlatform();
   
   int vbo;
   int tcb;
   int tex;
   int program;
   
   public void go()
   {
      glfwSetErrorCallback(errorCallback);
     
      if (glfwInit() != GL_TRUE) {
          throw new IllegalStateException("Unable to initialize GLFW");
      }
     
     
      glfwDefaultWindowHints();
      glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
      glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
      glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
      glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
     
       window = glfwCreateWindow(640, 480, "Simple example", NULL, NULL);
      if (window == NULL) {
          glfwTerminate();
          throw new RuntimeException("Failed to create the GLFW window");
      }
     
      glfwSetKeyCallback(window, keyCallback);
     
      glfwMakeContextCurrent(window);
      GLContext.createFromCurrent();
     
      /*
        Platform.runLater(new Runnable() {
            @Override
            public void run() {
           plat.setScene(createScene());
            }
       });
   
   plat.setsize(512, 512);
   */

   
   
   
   
   
   ByteBuffer buf= ByteBuffer.allocateDirect(512*512*3);
   Random r = new Random();
   for(int x=0;x<buf.capacity();x++)
   {
      buf.put((byte) r.nextInt(255));
     
   }
   
   buf.flip();
   
   
   
   tex=glGenTextures();
   glBindTexture(GL_TEXTURE_2D, tex);
   
   GL11.glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,512,512,0,GL_RGB,GL_UNSIGNED_BYTE,buf);

   
   int vao = glGenVertexArrays();
   glBindVertexArray(vao);
   
   //set up vbo
   
   float[] vbodata = {
         -0.9f, -0.9f, 0.0f,
         0.9f, -0.9f, 0.0f,
         -0.9f, 0.9f,0.0f,
         0.9f,  0.9f, 0.0f,
         
      };
   
   FloatBuffer fb= BufferUtils.createFloatBuffer(vbodata.length);
   fb.put(vbodata);
   fb.flip();
   
   vbo=glGenBuffers();
   
   glBindBuffer(GL_ARRAY_BUFFER,vbo);
   
    glBufferData(GL_ARRAY_BUFFER,fb,  GL_STATIC_DRAW);
   
    float[] tcs={0f,0f,
                    0f,1f,
                    1f,1f,
                    1f,0f};
   
    fb= BufferUtils.createFloatBuffer(tcs.length);
      fb.put(tcs);
      fb.flip();
   
      tcb=glGenBuffers();
     
      glBindBuffer(GL_ARRAY_BUFFER,tcb);
     
       glBufferData(GL_ARRAY_BUFFER,fb,  GL_STATIC_DRAW);
     
     
   
    program=createshaders("shaders/shader.vtex","shaders/shader.frag");
       
    glClearColor(0.0f, 0.0f, 0.4f, 0.0f);
     
      while (glfwWindowShouldClose(window) != GL_TRUE)
      {
       mainloop();
      }
     
      glfwDestroyWindow(window);
      keyCallback.release();
      glfwTerminate();
      errorCallback.release();
     
   }
   
   public static void main(String[] args)
   {
      new glembedtest().go();
     
   }

   
   public void mainloop()
   {
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      glUseProgram(program);
     
      glEnableVertexAttribArray(0);
      glEnableVertexAttribArray(1);
      glBindBuffer(GL_ARRAY_BUFFER, vbo);
      GL20.glVertexAttribPointer(0, 3, GL_FLOAT, false, 0, 0);
     
      glBindBuffer(GL_ARRAY_BUFFER, tcb);
      GL20.glVertexAttribPointer(1, 2, GL_FLOAT, false, 0, 0);
     
     
      GL13.glActiveTexture(GL13.GL_TEXTURE0);
      int texloc=glGetUniformLocation(program, "mytex");
      glUniform1i(texloc, 0);
      glBindTexture(GL_TEXTURE_2D, tex);
     
     
     
      glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
     


      glfwSwapBuffers(window);
      glfwPollEvents();
   }
   
   
   
    private static Scene createScene() {
        Group  root  =  new  Group();
        Scene  scene  =  new  Scene(root, Color.BLUE);
        Text  text  =  new  Text();
       
        text.setX(40);
        text.setY(100);
        text.setFont(new Font(25));
        text.setText("Welcome JavaFX!");

        root.getChildren().add(text);

        return (scene);
    }
   
   
   
    int createshaders(String vert, String frag)
    {
       int VertexShaderID = glCreateShader(GL_VERTEX_SHADER);
        int FragmentShaderID = glCreateShader(GL_FRAGMENT_SHADER);
       
        String code="";
        try {
         Scanner scan = new Scanner(new File(vert));
         
         while(scan.hasNext())
         {
            code+=scan.nextLine()+"\n";
         }
         scan.close();
         
      glShaderSource(VertexShaderID,code);
      glCompileShader(VertexShaderID);

      int result=glGetShaderi(VertexShaderID, GL_COMPILE_STATUS);
      String log=glGetShaderInfoLog(VertexShaderID);
      System.out.println("vtx shader returned: "+log);
     
     
       scan = new Scanner(new File(frag));
     
       code="";
      while(scan.hasNext())
      {
         code+=scan.nextLine()+"\n";
      }
      scan.close();
     
   glShaderSource(FragmentShaderID,code);
   glCompileShader(FragmentShaderID);

    result=glGetShaderi(FragmentShaderID, GL_COMPILE_STATUS);
    log=glGetShaderInfoLog(FragmentShaderID);
   System.out.println("frag shader returned: "+log);
     
     
   int ProgramID = glCreateProgram();
    glAttachShader(ProgramID, VertexShaderID);
    glAttachShader(ProgramID, FragmentShaderID);
    glLinkProgram(ProgramID);
   
    result=glGetProgrami(ProgramID, GL_LINK_STATUS);
    log=glGetProgramInfoLog(ProgramID);
    System.out.println("program link returned: "+log);
         
    return ProgramID;
         
      } catch (FileNotFoundException ex) {
         
         ex.printStackTrace();
      }
       
        return -1;
       
    }
   
}


and shaders
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
// vertex shader
#version 330 core
 
// Input vertex data, different for all executions of this shader.
layout(location = 0) in vec3 vertexPosition_modelspace;
layout(location = 1) in vec2 vertexUV;
 
// Output data ; will be interpolated for each fragment.
out vec2 UV;

 
void main(){
 
    // Output position of the vertex, in clip space : MVP * position
    gl_Position = vec4(vertexPosition_modelspace,1);
 
    // UV of the vertex. No special space for this one.
    UV = vertexUV;
}


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
//fragment shader
#version 330 core
 
// Interpolated values from the vertex shaders
in vec2 UV;
 
// Ouput data
out vec3 color;
 
// Values that stay constant for the whole mesh.

uniform sampler2D mytex;

 
void main(){
 
    // Output color = color of the texture at the specified UV
    color = texture( mytex, UV ).rgb;
 
}


I'm expecting a rectangle with random noise in it (i'm actually trying to make a gui, but i'm just loading noise into my texture to test the shader), but all i get is a black rectangle. any ideas what i'm doing wrong here?
4  Discussions / General Discussions / Re: What's your day job? on: 2015-05-07 14:22:06
just got a job for the summer teaching at a tech summer camp
5  Java Game APIs & Engines / OpenGL Development / javafx render to texture on: 2015-04-25 22:09:01
is there any way get an image from javafx that could be loaded into a texture and feed in events from the engine? I'd like to use it for my menu and possibly a doom3 style GUI.
6  Discussions / General Discussions / Re: The Khronos Group announces "Vulkan": the successor to OpenGL on: 2015-03-15 15:51:28
I'm wondering if this might make VGA passthrough possible without having to have 2 graphics cards. since this would move control of the graphics card away from the driver, that would make it less complex for the driver on the guest OS to be modified to share the graphics card?
7  Discussions / Miscellaneous Topics / version control for ported project. on: 2015-03-14 15:43:55
I am intending to port a project from c++ to java. I would like to be able to keep track of the other project in my repository too, so i can see how it changes and keep my own parallel version updated. I'm using eclipse EGit. any recommendations?
8  Discussions / General Discussions / Re: What's your day job? on: 2015-03-13 14:58:49
- so please, when you all get filthy rich, don't go buy a Lambo!
Wouldn't dream of anything other than an AMC javelin or 1970 Roadrunner
9  Discussions / General Discussions / Re: What's your day job? on: 2015-02-17 00:15:42
it does come at a slight cost and that is incompetent teachers.

Beats Texas. We have teachers that are incompetent AND psycho.
10  Discussions / General Discussions / Re: What's your day job? on: 2015-02-16 16:05:25
the usual college-level jobs. studying robotics.
11  Game Development / Newbie & Debugging Questions / Re: convert expression for use with vecmath on: 2015-02-15 19:54:17
javax.vecmath creates so much garbage that it is best avoided

Unfortunately I need it for jbullet
12  Game Development / Newbie & Debugging Questions / Re: convert expression for use with vecmath on: 2015-02-15 15:30:09
Javax.vecmath

It doesn't. For example adding vectors v1 and v2 with v1.add(v2) stores the result in v1
13  Game Development / Newbie & Debugging Questions / convert expression for use with vecmath on: 2015-02-14 01:48:31
since all the math operations in vecmath apply the result to the object they're called on instead of returning the result, i can't just replace + with add() and make sure the parentheses are in the right place. How should i convert a mathematical expression to vecmath without using a bunch of temporary variables?
14  Java Game APIs & Engines / OpenGL Development / Re: LWJGL 3; how's it getting along? on: 2015-02-13 21:50:51
any significant advantages over JOGL2?
15  Game Development / Shared Code / Source Engine MDL code on: 2015-01-19 17:27:35
http://www.java-gaming.org/user-generated-content/members/18483/crowbar-port.jar

This code loads up data from SourceEngine model files. for examples on how to use the data, check the Core/Filedatacompiled code

crowbar_.24_vb contains the original Visual Basic code
/crowbar_pidgin_.24 contains a bastardized VB/java version output by a program I cobbled together to make porting easier.
crowbar contains the converted code.

the Decompiler.readcompiledfiles method reads the model files.
16  Discussions / Community & Volunteer Projects / porting VB code for source engine MDL files on: 2015-01-16 15:45:46
I am working on porting a VB program that decompiles Source Engine MDL files into Java.  If anybody wants to load MDL files or is interested in helping, I can put up the VB code and my current progress
17  Discussions / General Discussions / Re: Simple 3D modeling software suitable for games? on: 2015-01-15 02:54:48
true, but i've been using it and Roadkill on WINE with no problems
18  Discussions / General Discussions / Re: Simple 3D modeling software suitable for games? on: 2014-12-16 23:53:12
Try one called Anim8or. It is EXTREMELY simple to use, but you can make some very great models using it. It can export to OBJ. Also, its native an8 format is easy to parse, and supports skeletal animation.
19  Discussions / General Discussions / Re: Reasons for using a scripting language in your game? on: 2014-12-05 03:55:47
It makes your game easier to mod because your users won't have to compile java code and get the clsspath to the game's libraries right, they can just edit the script files.

I also remember seeing somewhere that it's easier to secure than classes loaded by reflection
20  Discussions / Miscellaneous Topics / Re: Is drinking half a bottle of vodka safe? on: 2014-11-16 21:39:38
drimking alcohol just for the sake of drinking and/or getting drunk is is stupid. and a great way to end up drowning on your own vomit
21  Discussions / Miscellaneous Topics / Re: Full Visual Studio for free on: 2014-11-16 21:24:22
I found VS to be rather slow. Also since i also do coding on linux, might as well just use code::blocks
22  Game Development / Game Mechanics / Re: SMD skeleton problems on: 2014-11-16 20:14:52
I noticed some strange stuff in my SMD file.

1  
2  
3  
4  
5  
2 3.890447 0.000000 0.000000 -1.570796 0.051836 -1.565574 // left thigh
5 -3.890447 0.000000 0.000000 -1.570796 0.051836 -1.576018 //right thigh

14 2.059528 0.977921 1.937661 1.589740 -1.286515 2.950147//left clavicle
 18 2.059528 0.977922 -1.937661 -1.661569 1.286515 2.950147//right clavicle


both the thighs (which are really where the hips are) and clavicles are mirror images of each other.
notice how the thighs are done using negated position but same rotation, but the clavicles have a different axis inverted and have 2 inverted angles.

as far as the bone format goes, the position refers to where the end of the bone is. Also, because in anim8or, the root bone can't own objects, so i have to add the smd root bone to the an8 root bone.
23  Game Development / Game Mechanics / Re: SMD skeleton problems on: 2014-11-14 21:02:34
the only thing i use position for is calculating of the bone. switching values won't make a difference.
I found an SMD loader for JMonkey, which has the same coordinate system as anim8or..

this is the code used to create a rotation matrix for the bone.
 
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
Matrix3f m1 = null;
        Matrix3f m2 = null;
        Matrix3f m3 = null;
        try {
            m1 = new Matrix3f();
            m1.fromAngleAxis(rot.x, Vector3f.UNIT_X);
            m2 = new Matrix3f();
            m2.fromAngleAxis(rot.y, Vector3f.UNIT_Y);
            m3 = new Matrix3f();
            m3.fromAngleAxis(rot.z, Vector3f.UNIT_Z);
        } catch (Exception Ex) {
            logger.log(Level.SEVERE, "Error, building rotation Matrix3f from "
                    + "rotation vector.", Ex);
        }
        return m3.mult(m2).mult(m1);


this is the same as what I've been doing in my code, and also in theagentd's code.
there must be something stupidly simple we're missing.
24  Game Development / Game Mechanics / Re: SMD skeleton problems on: 2014-11-14 16:25:55
i tried switching roty and rotz. just got a different weird looking skeleton
25  Game Development / Game Mechanics / Re: SMD skeleton problems on: 2014-11-08 23:19:37
for SMD x is left, y is forward, z is up.
in anim8or, x is left, y is up, z is forward.
how do i convert rotation between these 2 systems?
26  Game Development / Game Mechanics / Re: SMD skeleton problems on: 2014-11-08 20:36:07
thanks. too bad ani2pov can't save anim8or files with a skeleton.
I'm going to try asking on the anim8or forum for some insight.
27  Game Development / Game Mechanics / Re: SMD skeleton problems on: 2014-11-08 00:43:24
the translation component of the matrix wouldn't have any effect, would it?
where did you get that code from?
28  Game Development / Game Mechanics / Re: SMD skeleton problems on: 2014-11-03 21:52:20
According to https://developer.valvesoftware.com/wiki/Studiomdl_Data the angles given are in radians.
29  Game Development / Game Mechanics / Re: SMD skeleton problems on: 2014-11-02 16:11:40
no joy. would it be a problem if the coordinate systems ware different? I would think the result should at least look like the input, but oriented along a different axis.
30  Game Development / Game Mechanics / Re: SMD skeleton problems on: 2014-11-02 14:28:46
sorry, that didn't work.
I think the problem is with the orientation code.
Pages: [1] 2 3 ... 19
 
Ralphanese (22 views)
2015-05-29 13:07:55

Gibbo3771 (18 views)
2015-05-29 06:54:17

Ralphanese (23 views)
2015-05-28 16:52:52

theagentd (31 views)
2015-05-27 22:21:17

theagentd (38 views)
2015-05-27 22:21:08

CopyableCougar4 (27 views)
2015-05-27 19:24:50

MrMapcom (24 views)
2015-05-23 20:26:16

MrMapcom (33 views)
2015-05-23 20:23:34

Waterwolf (39 views)
2015-05-20 15:01:45

chrislo27 (46 views)
2015-05-20 03:42:21
Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21

Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!