Jump to content
  • Advertisement
Sign in to follow this  
Bow_vernon

Is glRotatef and glTranslatef fast enough?

This topic is 2774 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, Im making 3d tile map editor, by arranging 3d tiles(translating and rotating it), but that means there will be N calls of those functions(N is num of tile). Now will that be a major slowdown? Im too affraid to code after I kept failing for two days :(
Best Regards,
Bow Vernon

Share this post


Link to post
Share on other sites
Advertisement
I'd only worry about it being slow if it actually turns out to be slow when you implement it. Just draw how many objects you're going to have on screen and translate and rotate every one and see what FPS you get. If you worry about every function call being slow then it will take forever to get anything done.

FWIW most 3d engines will call a translate/rotate before displaying an object. Some will apply a matrix. As long as you don't do it for every triangle you'll be ok :)

If you're looking for the 'fastest' way of doing it you will probably want to pre-rotate and translate all the tile vertices and put them into a vertex buffer, then it's down to one function call per frame for all stuff in the buffer. But this might not work with the way you are doing things.

D

Share this post


Link to post
Share on other sites
If I pre-transform those tiles it will eat too much memory perhaps. Well basically Im worried because drawing a tile is like drawing an object. Hmm I'll try to implement it tonight :(
But Im faced with the shading at the edge of the tiles now x(

Share this post


Link to post
Share on other sites
Are you trying to do something like this?
Map Editor

Im using glVertex3f calls, i know i could use VBOs or vertex arrays, but im too lazy to rethink the whole renderer atm.
I constantly get FPS 64. My monitor is 85Hz. And atm im satisfied with performance.

If you limit yourself to specific portion of screen and use additional culling like i do, then you shouldn't worry so much about performance.
If you want to show your whole map then VBO's may be better.

Im able to rotate the tiles, flip, animate and CPU is 0% and FPS is 64.
Flipping, rotation is just basically changing vertex co-ordinates when rendering.
It creates illusion that it flipped texture, but actually it just changed vertex co-ordinates a bit.

I think it depends how you render and draw the things with OpenGL.

The FPS drops of course if you record video.

The map you see on the video of course could be called tiled map because whole map is made of tiles.
But also you can call them objects, because it involves vertices etc.

So i recommend you to code it and see how it works.

As they say: first make it work, then optimize.

Share this post


Link to post
Share on other sites
@BytePtr dats cool :D yeah Im trying to do that. Anyway, is there elevation in the tile map?
You said you change coordinate? Manually or do you use glTranslate/glRotate? And is there any gap between tiles?

Share this post


Link to post
Share on other sites
@ is there any gap between tiles?


If i understood you correctly, then there is no gaps. For this game, it's not used and not needed.
Well for texture coordinates i use some own tricks if you can call them so (basically saving few old coords, storing them in tmp variable and assigning them again, just using different order), still all done with glTexcoord2f but for drawing tiles / blocks i indeed use glTranslatef.
glRotatef is used for rotating scene with mouse, like you see from vid.

And the higher and lower level tiles / blocks are all thanks to glTranslatef, it's very nice command in OpenGL, solves many many problems.
I couldn't imagine if i had to do the hard work all by myself.


Btw, because it's map editor, it's all done in every frame. It just reads the data from array and renders it. It may sound ugly but it works and im satisfied with it.When user modifies array, the changes are immediately displayed.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!