Note, that in the vertex shader, you have to convert integer vertex coords to float, if floats are passed, you should round() them before. This is where things usually get odd => an appropriate search term may be 'pixel perfect OpenGL'.Īdding 0.5 to pixel coordinates in the vertex shader, which then can be supplied as whole numbers, should do the trick. The tricky part is, that pixels (the center of them) aren't located at whole numbers in this case! You can apply an appropriate transform using an orthogonal projection matrix with extents set to your resolution.Īpplying this transform in the vertex shader, allows you to directly supply pixel coords in vertex data. So I didn't want to continue going forward if there was a more accurate, faster method that could use pixel coordinates. However, it ended up being 24x23 pixels on the screen. I tried crunching the numbers (using the regular grid and floats) to draw a right triangle that was 24x24 pixels. I do not want to split any pixels in this game everything (textures, player movement, camera movement) will conform to whole-pixel coordinates. This would be much easier to work with because I plan to make a 2D platformer game. Is it possible to change this? I would like to use integers instead of floats, and have the lower-left corner of the screen be (1,1) while the upper-right corner is (960,540). I see that the triangle has been drawn with floats, and that the lower-left corner of the screen is (-1,-1) while the upper-right corner of the screen is (1,1). The demo I'm currently using is 960x540 pixels with a simple 2D triangle drawn in the middle of the screen. I'm using some demos that came with my OpenGL ES emulator as a starting point.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |