Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (120)
games submitted by our members
Games in WIP (577)
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  
  Rendering multiply VBOs  (Read 1240 times)
0 Members and 1 Guest are viewing this topic.
Offline Giovanni

Junior Duke




chop!


« Posted 2012-04-19 20:52:55 »

Hi!
Before I have switched to VBOs I was using immediate mode and Display lists. Since both ways are either depreciated or slow I decided to start using VBOs. Now I got a little problem, which is not really related to VBOs but more to drawing in 3D room.

I have done quite a bit of research and figured out that you got basically 2 coord. systems in OpenGL, a static one, and one which you are able to move around etc.
However, I somehow could not figure out how to do render loops for a single object (entity, w/e you wanna call it). I tried it the following way:

1  
2  
3  
4  
5  
6  
7  
8  
9  
//1.)
//Render loop for a single entity
glPushMatrix();
glTranslatef(x-pos-of-my-entity,y,z);
glPopMatrix();

//2.)
//Main render loop:
glDrawArrays( ...);





Yes, this way does not really work. The objects only get drawn a single time and disappear afterwards. Also, I am not exactly sure (or: I highly doubt) if moving the coord. system for every render loop is really smart.


My question: How to do efficient render loops for several objects/entities ?

Thanks in advance!
Offline theagentd
« Reply #1 - Posted 2012-04-20 10:01:02 »

glDrawArrays uses the current matrix for everything it renders. Your current matrix code therefore does nothing.

Myomyomyo.
Offline Giovanni

Junior Duke




chop!


« Reply #2 - Posted 2012-04-20 14:19:06 »

I have done a little mistake.

The line would of course be

1  
glTranslatef(x-pos-of-my-entity,y,z);



So what you said is, that the code should look like following?:

1  
2  
3  
4  
glPushMatrix();
glTranslatef(x-pos-of-my-entity,y,z);
glDrawArrays();
glPopMatrix();


This is what I would use for the rendering loop of a single object or what?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline theagentd
« Reply #3 - Posted 2012-04-20 15:30:50 »

Yes, that's the only way to get a different matrix for each object without OpenGL 3+. The best solution is instancing, but you need a custom shader, manual matrix calculations, something to hold the matrix data (a UBO or TBO) and a OpenGL 3 capable graphics card for...

Myomyomyo.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

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

The first screenshot will be displayed as a thumbnail.

Longarmx (52 views)
2014-10-17 03:59:02

Norakomi (43 views)
2014-10-16 15:22:06

Norakomi (33 views)
2014-10-16 15:20:20

lcass (37 views)
2014-10-15 16:18:58

TehJavaDev (68 views)
2014-10-14 00:39:48

TehJavaDev (66 views)
2014-10-14 00:35:47

TehJavaDev (59 views)
2014-10-14 00:32:37

BurntPizza (73 views)
2014-10-11 23:24:42

BurntPizza (45 views)
2014-10-11 23:10:45

BurntPizza (86 views)
2014-10-11 22:30:10
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

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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!