• Advertisement

Archived

This topic is now archived and is closed to further replies.

What to use ?

This topic is 5949 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

OpenGL provides a number of memory menagement / drawing functions ... but what to use for what kind of stuff ? I''m doing a 2D tile engine, for the tiles i will be using textured Quads, i decided that ... but what should i use to display fonts ? or large pics like a background for the console, or user interface, or menu ... Oh, and what will happen if i try to call glTexImage2D when there is no more VideoMemory available, will OpenGL start using normal mem automatically ? Last question: I''d like to specify the placement of the textures quads so that no stratching has to be done: like every pixel in the texture image will exactly match a pixel in the framebuffer, so i can get more speed by disabling texturefilters, without losing graphics quality ... And what would be the best way to aply lightning to my tiles, by using vertex colors and smooth shading, but i can''t really get a grip on the glTexEnvi Function ... and the last question: I normally just set my viewport to the dimentions of my window, but when i do so a quad (-0.5, -0.5, 0.5, 0.5 ) will come out as a rectangle it would be a great help to just have gl coordinates match screen pixel coordinates ... thx in advance for any help !

Share this post


Link to post
Share on other sites
Advertisement
quote:
Original post by Ertai
OpenGL provides a number of memory menagement / drawing functions ... but what to use for what kind of stuff ?

I''m doing a 2D tile engine, for the tiles i will be using textured Quads, i decided that ...

but what should i use to display fonts ? or large pics like a background for the console, or user interface, or menu ...



Just use textured tris or quads.

quote:

Oh, and what will happen if i try to call glTexImage2D when there is no more VideoMemory available, will OpenGL start using normal mem automatically ?



Texture management is black box. Just load them and let the driver do its job. It works for most cases.

quote:

Last question: I''d like to specify the placement of the textures quads so that no stratching has to be done: like every pixel in the texture image will exactly match a pixel in the framebuffer, so i can get more speed by disabling texturefilters, without losing graphics quality ...

And what would be the best way to aply lightning to my tiles, by using vertex colors and smooth shading, but i can''t really get a grip on the glTexEnvi Function ...

and the last question: I normally just set my viewport to the dimentions of my window, but when i do so a quad (-0.5, -0.5, 0.5, 0.5 ) will come out as a rectangle

it would be a great help to just have gl coordinates match screen pixel coordinates ...

thx in advance for any help !


Try fiddling with the glOrtho parameters.

The fanatic is incorruptible: if he kills for an idea, he can just as well get himself killed for one; in either case, tyrant or martyr, he is a monster.
--EM Cioran

Opere Citato

Share this post


Link to post
Share on other sites
Nope but you can have a bunch of 256*256 Textures to do the job, the only problem is that you have to draw more polys and other stuff, not a hard problem to deal with.

Also the max texture size depends on you Video Card, the most common is 256*256, also textures height or width should be Powers of 2:

2
4
8
16
32
64
128
256
512

Well i hope that Helps at least a Bit


Behold the Powers of 2!
W-Buffer

Share this post


Link to post
Share on other sites
I allready knew that, but thank you anyway, I just thought it would be possible because i read something about going around that limitation in one of the NeHe tutz ..

but wouldn''t it be better to just use a glDrawPixels command for drawing such a large picture in 2D .. and only use textured Quads for smaller pics ?

and one other thing, you guys where talking about using glOrtho for aligning screen coordinates with opengl coordinates, could you tell me a little bit more about that ?

Share this post


Link to post
Share on other sites
quote:
Original post by Ertai
I allready knew that, but thank you anyway, I just thought it would be possible because i read something about going around that limitation in one of the NeHe tutz ..



Technically it is still a power of 2 texture, you just use part of it for you nonpower of 2 texture.

quote:

but wouldn''t it be better to just use a glDrawPixels command for drawing such a large picture in 2D .. and only use textured Quads for smaller pics ?



glDrawPixels is slow. OpenGL is a 3D graphics api, using glDrawPixels bypasses all the hardware acceleration available on your videocard.

quote:

and one other thing, you guys where talking about using glOrtho for aligning screen coordinates with opengl coordinates, could you tell me a little bit more about that ?


When your screen is set to 800x600 it is not square. I bet you are setting glOrtho to a square. -5, 5, -5, 5, -1, 1. That means OpenGL is trying to fit a square onto a rectangle and you get your square polys stretched into rectangles. Just make sure you parallel viewing volume matches the aspect ration of your screen resolution. 800x600 == 4/3 -2, 2, -1.5, 1.5, -1, 1

The fanatic is incorruptible: if he kills for an idea, he can just as well get himself killed for one; in either case, tyrant or martyr, he is a monster.
--EM Cioran

Opere Citato

Share this post


Link to post
Share on other sites
Thank you! you are the best, an answer to all my questions !

There is still one thing i don''t get:

If i have tile of 64 * 64 pixels ( for example )
how do i make sure that when I render one, using a textured QUAD, every texel stored in the textures will be placed on one pixel in the framebuffer exactly, so my texture doesn''t become ugly when i disable all those beautifull texture filters ...

thx in advance, Ertai

Share this post


Link to post
Share on other sites
Hey !, i btw got my math teacher to tell me everything about matrices, so i might be able to figure that one out myself, but that is still to happen, and I would still very much like to see your reply !

Share this post


Link to post
Share on other sites
hmmm, so i called

glOrtho( 0.0f, SCREEN_X, SCREEN_Y, 0.0f, -1.0f, 1.0f );

on the Projection matrix, but it doesn''t seem to have any effect whatsoever ...

Share this post


Link to post
Share on other sites
If you can post the code here or send it to me it would be easier to fix your problem. I can''t believe that glOrtho has no effect. I use it to get exact screen coordinates with an editor I made.

The fanatic is incorruptible: if he kills for an idea, he can just as well get himself killed for one; in either case, tyrant or martyr, he is a monster.
--EM Cioran

Opere Citato

Share this post


Link to post
Share on other sites

  • Advertisement