Java-Gaming.org Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (552)
Games in Android Showcase (139)
games submitted by our members
Games in WIP (593)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 ... 6 7 [8] 9 10
 71 
 on: 2015-02-01 00:05:59 
Started by ExcelledProducts - Last post by ExcelledProducts
I have been developing code to display VBOs with textures. The problem is no texture gets displayed. I know the texture is loaded. I can display the model in wireframe. And I can display it in polygon mode, but when I add textures nothing appears. If I remove the line
1  
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
it displays in polygon mode and I can change it to wire frame.

My Main Loop:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
while(!Display.isCloseRequested())
      {
         //I just removed the camera stuff
         
         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
         glLoadIdentity();
         
         //glLight(GL_LIGHT0, GL_POSITION, Utility.asFlippedFloatBuffer(new float[]{cam.getX(), cam.getY(), cam.getZ(), 1}));
         cam.useView(); //<-- this is part of the camera stuff
         for (VBO vbo : TexturedGroupedObjects) {
            vbo.renderObject();
         }
         updateFPS();
         Display.update();
      }


This is my VBO class:
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  
public class VBO {
   
   int vertexHandle;
   int normalHandle;
   int textureHandle;
   int facesCount;
   
   private static Texture vboTexture;
   private static boolean containsTexture;
   
   public VBO(ArrayList<Group> group, String textureLocation) {
      //Load texture
      try {
         vboTexture = TextureLoader.getTexture("JPG", ResourceLoader.getResourceAsStream(textureLocation));
      } catch (IOException e) {
         e.printStackTrace();
      }
     
      facesCount = 0;
      //Get faces count in multiGroup
      for (Group gg : group) {
         facesCount += gg.Faces.size();
      }
      System.out.println(facesCount);
     
      vertexHandle = glGenBuffers();
      normalHandle = glGenBuffers();
      textureHandle = glGenBuffers();
     
      FloatBuffer vertices = reserveData(facesCount * 36);
      FloatBuffer normals  = reserveData(facesCount * 36);
      FloatBuffer texture  = reserveData(facesCount * 36);
      //Load all the vertex data into the floatbuffer
     
      for (Group g : group) {
         for (Face f : g.Faces) {
            for (Vertex3f v3f : f.vertexData) {
               vertices.put(asFloatsVertex(v3f));
            }
            for (Normal3f n3f : f.normalData) {
               normals.put(asFloatsNormal(n3f));
            }
            if(f.textureData != null) {
               for (Texture3f t3f : f.textureData) {
                  normals.put(asFloatsTexture(t3f));
               }
            }
         }
      }
     
      vertices.flip();
      normals.flip();
      texture.flip();
     
      glBindBuffer(GL_ARRAY_BUFFER, vertexHandle);
      glBufferData(GL_ARRAY_BUFFER, vertices, GL_STATIC_DRAW);
      glBindBuffer(GL_ARRAY_BUFFER, 0);
     
      glBindBuffer(GL_ARRAY_BUFFER, normalHandle);
      glBufferData(GL_ARRAY_BUFFER, normals, GL_STATIC_DRAW);      
      glBindBuffer(GL_ARRAY_BUFFER, 0);
     
      glBindBuffer(GL_ARRAY_BUFFER, textureHandle);
      glBufferData(GL_ARRAY_BUFFER, texture, GL_STATIC_DRAW);      
      glBindBuffer(GL_ARRAY_BUFFER, 0);
     
   }
   
   public void renderObject() {
      vboTexture.bind();
      glBindBuffer(GL_ARRAY_BUFFER, vertexHandle);
      glVertexPointer(3, GL_FLOAT, 0, 0L);
         
      glBindBuffer(GL_ARRAY_BUFFER, normalHandle);
      glNormalPointer(GL_FLOAT, 0, 0L);
         
      glBindBuffer(GL_ARRAY_BUFFER, textureHandle);
      glTexCoordPointer(3, GL_FLOAT, 0, 0L);
         
      glEnableClientState(GL_VERTEX_ARRAY);
      glEnableClientState(GL_NORMAL_ARRAY);
      glEnableClientState(GL_TEXTURE_COORD_ARRAY);
         
      glDrawArrays(GL_TRIANGLES, 0, facesCount * 3);

      glDisableClientState(GL_TEXTURE_COORD_ARRAY);
      glDisableClientState(GL_VERTEX_ARRAY);
      glDisableClientState(GL_NORMAL_ARRAY);
         
      glBindBuffer(GL_ARRAY_BUFFER, 0);
      vboTexture.release();  
   }
   
   public void deleteBuffers() {
      glDeleteBuffers(vertexHandle);
      glDeleteBuffers(normalHandle);
      glDeleteBuffers(textureHandle);
   }
   
   private static float[] asFloatsTexture(Texture3f v) {
      return new float[]{v.v, v.u};
   }
   
   private static float[] asFloatsNormal(Normal3f v) {
      return new float[]{v.x, v.y, v.z};
   }
   
   private static float[] asFloatsVertex(Vertex3f v) {
      return new float[]{v.x, v.y, v.z};
   }
   
   private static FloatBuffer reserveData(int size) {
      return BufferUtils.createFloatBuffer(size);
   }

 72 
 on: 2015-02-01 00:04:12 
Started by Ogdan - Last post by lcass
Hi , this is not an ad forum , you have posted no other things than this post.

 73 
 on: 2015-01-31 23:52:20 
Started by BurntPizza - Last post by Olo
Trying my best to make a gui for my rpg Smiley

 74 
 on: 2015-01-31 23:45:19 
Started by BurntPizza - Last post by Slyth2727
oh, is that a fender-amp ?

It is indeed.

 75 
 on: 2015-01-31 22:43:44 
Started by Andre Lopes - Last post by Riven
If it doesn't work, then there's indeed something wrong with the code.



What did you do to narrow down the problem, apart from noticing it didn't work and dumping it on JGO.

 76 
 on: 2015-01-31 22:33:03 
Started by BurntPizza - Last post by Mike
First I think I only one, who put the monitor on the stand(books, etc ^^)
But now when I see same like 10 times from different ppl I think its normal XD

It's all about ergonomics Smiley

https://www.youtube.com/watch?v=CqOheOnMLe4#t=53

Mike

 77 
 on: 2015-01-31 22:25:34 
Started by BurntPizza - Last post by basil_
I set up my new desk and cleaned things up. I'm loving the look.


oh, is that a fender-amp ?

 78 
 on: 2015-01-31 22:15:30 
Started by Ogdan - Last post by Ogdan
Hey Everyone,

I just released a new game to Android and iOS. Check it out and let me know what you think!

Android: https://play.google.com/store/apps/details?id=com.wobble.radius.android

iOS: https://appsto.re/ca/7Jcg3.i



Radius is a game of timing, estimation, and accuracy.



Tap your way through levels packed with pulsating shapes and colors, but keep an eye on your lives. Time your clicks carefully, and you'll be rewarded with new levels and music!
Each level consists of various shapes and colours pulsing on your screen. Tap to make them stop and aim for the target score. The closer you get, the better the score. Aim for an Ace on each level as you work your way through Radius!
Features include:
- Over 100 different levels consisting of 3 different shapes and 4 different colours
- Three different sound tracks
- Three different difficulty modes
Try to collect stars and aces in order to unlock additional levels.
Check us out at:
www.wobbleapps.com


 79 
 on: 2015-01-31 22:12:02 
Started by lcass - Last post by Andre Lopes
Again another point , if you arnet interested in programming , as a lot of people arnet , then trying to give them it as a continuous option will just leave you with a bunch of shoddy coders.

Which will give a bad image to good programmers and flood with no-skill coders.


 80 
 on: 2015-01-31 22:08:21 
Started by BurntPizza - Last post by Icecore
I set up my new desk and cleaned things up. I'm loving the look.


First I think I only one, who put the monitor on the stand(books, etc ^^)
But now when I see same like 10 times from different ppl I think its normal XD

Pages: 1 ... 6 7 [8] 9 10
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Archive (30 views)
2015-01-29 04:26:08

theagentd (26 views)
2015-01-28 15:33:52

GamerIDGoesHere (37 views)
2015-01-27 01:23:23

GamerIDGoesHere (38 views)
2015-01-27 01:22:15

CopyableCougar4 (48 views)
2015-01-27 00:34:41

CopyableCougar4 (31 views)
2015-01-26 04:47:56

Olo (23 views)
2015-01-25 21:26:00

Olo (29 views)
2015-01-25 18:44:22

Robo11 (47 views)
2015-01-25 06:14:26

basil_ (40 views)
2015-01-17 22:29:32
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

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17
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!