Hi !
Featured games (85)
games approved by the League of Dukes
Games in Showcase (623)
Games in Android Showcase (176)
games submitted by our members
Games in WIP (676)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Draw between 2 layers of the same VBO  (Read 1505 times)
0 Members and 1 Guest are viewing this topic.
Offline vastrolorde

Junior Devvie

« Posted 2014-04-12 07:39:24 »

Is there a way to add objects to VBO that werent there before? Im trying to create a minimap. Black backround and then objects in the space are shows as arrows or squares or whatever shapes.
Offline quew8

JGO Knight

Medals: 48

« Reply #1 - Posted 2014-04-12 13:29:09 »

If the VBO is large enough then yes, you can use any of a couple of functions to change the data in the VBO.


If the VBO is no big enough then no you can't. But all you have to do is create a VBO big enough for whatever you might need in the future. Anything you aren't using you can just leave empty.

A little LWJGL tutorial here on glBufferSubData: It's part of a series but you can take a look at the source code at the end for a summary.
Offline vastrolorde

Junior Devvie

« Reply #2 - Posted 2014-04-12 15:35:32 »

I have used BufferSubData before. But how can i draw between the 2 layer of VBO. I have the black background and the frame that goes over it. And the part i want to add must be above the background but below the frame.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline quew8

JGO Knight

Medals: 48

« Reply #3 - Posted 2014-04-12 16:23:48 »

So disable depth testing. Draw the background, draw the foreground, draw the frame.
Offline vastrolorde

Junior Devvie

« Reply #4 - Posted 2014-04-14 14:18:19 »

BufferSubData doesent add data to buffer, it only changes them. But how can  i add data to buffer that wasnt there before. I have 16 entrys to the buffer. But now i would add another 40 entryes to the top of the 16 that are already there. And it would be nice also if i could use the same metohd to delete entryes that are no longer needed.
Offline quew8

JGO Knight

Medals: 48

« Reply #5 - Posted 2014-04-15 15:02:20 »

You need to change the way you think about VBOs. A VBO is just a list of numbers, think of it as an array on the GPU.

So if you have an array of data in Java and you wanted to add more data to it, how would you do it? You can't, you would have to reinitialize the array with a larger size and copy all of the original data into it and then put the new data in as well. Exactly the same with a VBO in OpenGL. If you want to add more entries, delete the VBO and create a new VBO with enough space.

And you can always create a VBO larger than you need at that moment. Leave the bits you aren't using empty and don't draw them.

So essentially what you need is a system to manage each VBO. It needs to remember what bits of the VBO are being used and which bits are not. When you want to "delete" an entry, mark it as not being used and don't draw it. When you want to "add" an entry, overwrite a section that isn't being used. If there are no sections that aren't being used then you have to reinitialize the VBO with more space or use a different VBO.
Offline vastrolorde

Junior Devvie

« Reply #6 - Posted 2014-04-15 15:42:49 »

I have initialized a VBO large enoug to fit 50 object. At first only 2 are inserted and drawn. Then with the first update, a separate buffer is written which has 20-30 object coordinates in it. Now i would like to add the second buffer to the first one. But for somereason it is not happening. If lucky i get only 1 object in. So something somewhere is wrong.
Offline quew8

JGO Knight

Medals: 48

« Reply #7 - Posted 2014-04-15 16:46:45 »

I agree but without code, I can't help diagnose bugs. If I were you, I would look at the contents of the VBO before adding the extra data versus after adding (you can use the glGetBufferSubData() function) for debugging purposes. It can be extremely tedious but often will reveal the pattern which will let you solve the bug.
Offline vastrolorde

Junior Devvie

« Reply #8 - Posted 2014-04-16 10:40:19 »

I have found the location of my problem, but i cant understand why it does that.

The buffer that holds the new data hold data only for 1 element. althoufgh there are 42 elements worth of data.

public void update(float dt) {
         Entitys = world.getVisualEntities();
         PLoc = player.getPosition();
         for(VisualEntity e: Entitys){
            if(e instanceof StaticEntity){
               Vector3f pos = e.getPosition();
               if(Entitydistance(PLoc, pos) < 1800){
                  pos.set(width/2 + (PLoc.x - pos.x)/5, heigth/2 + (PLoc.y - pos.y)/5, 0);
                  verticesChange.put(new float[]{
                     pos.x, pos.y - 2.5F,
                     pos.x - 2.5F, pos.y + 2.5F,
                     pos.x + 2.5F, pos.y + 2.5F,
                     pos.x, pos.y - 2.5F
                  texVerticesChange.put(new float[]{
Offline quew8

JGO Knight

Medals: 48

« Reply #9 - Posted 2014-04-16 18:02:51 »

I can't see any problems. All I would say is check the position of "verticesChange" and "texVerticesChange" before each "put." That's generally the cause of problems but I can't see any reason it wouldn't work here.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline vastrolorde

Junior Devvie

« Reply #10 - Posted 2014-04-18 11:39:48 »

I found the problem. My teamate, had made a hes own buffersubdata class. It uses the original stuff, but the methods you get to use are a bit different. He made it so that when you but data into buffer, then it automatically rewinds it. So i modified it so that it would rewind only when i order it to rewind.
Offline quew8

JGO Knight

Medals: 48

« Reply #11 - Posted 2014-04-18 12:39:54 »

Well my advice is in the future always document your code, especially when it has some unpredictable behaviour like that. It is very useful when working alone but when in a team it is, as you have just found at, a necessity. For most methods it is obvious what they do so just a note of any odd behaviour is needed, not the essays you find in the standard library.
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

BurntPizza (13 views)
2015-10-07 17:15:53

BurntPizza (27 views)
2015-10-07 02:11:23

KaiHH (25 views)
2015-10-06 20:22:20

KaiHH (12 views)
2015-10-06 19:41:59

BurntPizza (26 views)
2015-10-06 19:04:48

basil_ (44 views)
2015-09-30 17:04:40

shadowstryker (22 views)
2015-09-29 15:55:06

TheSpaceHedgehog (28 views)
2015-09-29 01:58:48

GamerC4 (54 views)
2015-09-24 21:10:38

GamerC4 (71 views)
2015-09-24 21:09:48
Math: Inequality properties
by Roquen
2015-10-01 13:30:46

Math: Inequality properties
by Roquen
2015-09-30 16:06:05

HotSpot Options
by Roquen
2015-08-29 11:33:11

Rendering resources
by Roquen
2015-08-17 12:42:29

Rendering resources
by Roquen
2015-08-17 09:36:56

Rendering resources
by Roquen
2015-08-13 07:40:51

Networking Resources
by Roquen
2015-08-13 07:40:43

List of Learning Resources
by gouessej
2015-07-09 11:29:36 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‑
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!