16
Graphics / Re: Efficiency question
« on: April 26, 2015, 10:22:47 am »
don't draw the sprites which are not visible. the current version draws them all, no matter, whether or not they fall into the game view.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
1366x768 BPP 32
1360x768 BPP 32
1280x720 BPP 32
1024x768 BPP 32
1024x576 BPP 32
960x540 BPP 32
864x486 BPP 32
800x600 BPP 32
720x405 BPP 32
680x384 BPP 32
640x480 BPP 32
640x360 BPP 32
1366x768 BPP 24
1360x768 BPP 24
1280x720 BPP 24
1024x768 BPP 24
1024x576 BPP 24
960x540 BPP 24
864x486 BPP 24
800x600 BPP 24
720x405 BPP 24
680x384 BPP 24
640x480 BPP 24
640x360 BPP 24
1366x768 BPP 16
1360x768 BPP 16
1280x720 BPP 16
1024x768 BPP 16
1024x576 BPP 16
960x540 BPP 16
864x486 BPP 16
800x600 BPP 16
720x405 BPP 16
680x384 BPP 16
640x480 BPP 16
640x360 BPP 16
1366x768 BPP 15
1360x768 BPP 15
1280x720 BPP 15
1024x768 BPP 15
1024x576 BPP 15
960x540 BPP 15
864x486 BPP 15
800x600 BPP 15
720x405 BPP 15
680x384 BPP 15
640x480 BPP 15
640x360 BPP 15
1366x768 BPP 8
1360x768 BPP 8
1280x720 BPP 8
1024x768 BPP 8
1024x576 BPP 8
960x540 BPP 8
864x486 BPP 8
800x600 BPP 8
720x405 BPP 8
680x384 BPP 8
640x480 BPP 8
640x360 BPP 8
1366x768 BPP 4
1360x768 BPP 4
1280x720 BPP 4
1024x768 BPP 4
1024x576 BPP 4
960x540 BPP 4
864x486 BPP 4
800x600 BPP 4
720x405 BPP 4
680x384 BPP 4
640x480 BPP 4
640x360 BPP 4
1366x768 BPP 1
1360x768 BPP 1
1280x720 BPP 1
1024x768 BPP 1
1024x576 BPP 1
960x540 BPP 1
864x486 BPP 1
800x600 BPP 1
720x405 BPP 1
680x384 BPP 1
640x480 BPP 1
640x360 BPP 1
X Extensions:
Generic Event Extension - First event: 0
SHAPE - First event: 64
MIT-SHM - First event: 65
XInputExtension - First event: 66
XTEST - First event: 0
BIG-REQUESTS - First event: 0
SYNC - First event: 83
XKEYBOARD - First event: 85
XC-MISC - First event: 0
SECURITY - First event: 86
XFIXES - First event: 87
RENDER - First event: 0
RANDR - First event: 89
XINERAMA - First event: 0
Composite - First event: 0
DAMAGE - First event: 91
MIT-SCREEN-SAVER - First event: 92
DOUBLE-BUFFER - First event: 0
RECORD - First event: 0
DPMS - First event: 0
Present - First event: 0
DRI3 - First event: 0
X-Resource - First event: 0
XVideo - First event: 93
XFree86-VidModeExtension - First event: 0
XFree86-DGA - First event: 95
DRI2 - First event: 102
GLX - First event: 104
SGI-GLX - First event: 104
Unhandled event type: 85
Report this to the SFML maintainers if possible
sf::Style::Fullscreen. When I press an ESC it hangs and doesn't close. In order to close it I had to switch to another virtual console (pressing CTRL+ALT+F2) and come back, then it closes and shows that message in the console.
else if (dir = 2)change it to
else if (dir == 2)
else if (dir = 3)
g++ ./test.cpp -lsfml-window -lsfml-system -lsfml-graphics
So you might argue: Render entire lines instead single cells. But an object might also overlap a tile from the next line.it is not a problem if you separate tiles draws and objects draws: draw all the visible tiles, then draw all the visible objects (as a result they will be drawn "upon" the tiles; achievement unlocked .
So, culling first, drawing then seems more suitable
...
for each object at this tile:
add pointer to the object's sprite to the array
...
for each sprite pointer in array:
draw sprite
for each visible tile:?
draw tile
for each object in tile:
draw object
end
end
//1 = grass; 2 = dirt; 3 = water
tileMapVertexArray = [
1,2,1,1,1,1,1,2,2,2, //10 items
3,3,3,3,3,1,2,2,2,2 //10 items
...
]
here, if the first and second rows fall into the view area/screen region, you can draw them (if you still want to draw the tiles one by one) using 7 draw operations only, not 20.pushing all object's vertices (as mentioned: only colored, not textured) to a huge vertex array while drawing.is not a good idea. it is unrelated to the draw purpose IMHO. now you have a lot of problems coming from performing operations on a vector (vector grows -> it has a dramatic impact on performance, i.e. it needs to reallocate a new chunk of memory big enough to hold the new data, then it must shift all the present items around, append the newly created ones in the end, etc).
To make the object move into camera view, it's position needs to be upated. Hence the transformation needs to be applied.