4 OpenGL Questions

Started by
4 comments, last by leehairy 21 years, 8 months ago
I started using opengl last night so i am VERY inexperienced and soem of these questions may seem silly. I have managed to draw and move some textured objects around a background.. However.. i have a few simple questions 1) In every redraw do i have to .. a) bind a texture b) regenerate a quad (at the correct place) or can i a) bind the texture once at initialisation b) use the bound texture by name or something else c) just translate the stored quad instead of redrawing at the correct place What is the best method of reproducing blitted sprites?? 2) I tried spinning the textured quad around its centre point .. However it always spun around its top left when i created it using (0,0) (0, 128), (128,128), (128,0) .. so to get the quad to rotate around its centre point i created it so that (0,0) was at its centre as in (-64, -64), (64,64), (-64,64), (64,-64).. Does glRotatef() rotate an object around (0,0) or am i missing the point entirely ? 3) Usually when i do any 2D graphics i have to manually maintain a list of dirty rectangles for blitting. Do i need to bother with this when using OpenGL? Should i just manually clip all objects that fall outside the scene and just redraw every object? What are the generice techniques used? 4) Do i only get hardware acceleration when using OpenGL in fullscreen mode ? Thankyou in advance for any help and suggestions..
Advertisement
1 - If you are only using one texture then you could bind it at initialisation, but you would have to draw it every frame (translating only changes where things are going to be drawn, not the position of things that have been drawn)

2 - Opengl rotates around whatever the current center point is, when there have been no translations this is (0,0) but if you translate by (10,5) then the new center point is (10,5) and opengl will rotate around that.

3 - Not really sure about this, I dont use opengl for 2d, sry.

4 - No you can get hardware acceleration in a window

Hope I helped
--24 Beers in a Case.24 Hours in a Day.Coincedence? I think not!www.gramb0.co.uk
2 - u should read about the different kinds of martixs OpenGL has,what the matrix stack is, how to use it and how transformations work.

From the redbook:
Thinking about Transformations
Let's start with a simple case of two transformations: a 45-degree counterclockwise rotation about the origin around the z-axis, and a translation down the x-axis. Suppose that the object you're drawing is small compared to the translation (so that you can see the effect of the translation), and that it's originally located at the origin. If you rotate the object first and then translate it, the rotated object appears on the x-axis. If you translate it down the x-axis first, however, and then rotate about the origin, the object is on the line y=x, as shown in Figure 3-4. In general, the order of transformations is critical. If you do transformation A and then transformation B, you almost always get something different than if you do them in the opposite order.

Heres an image that explains it:
http://ask.ii.uib.no/library/SGI_bookshelves/SGI_Developer/books/OpenGL_PG/figures/chap3-9.gif

[edited by - Jonus on August 14, 2002 7:33:56 AM]
Thankyou for the help
Oh you're relativly new to GD.NET.

I don't know if you already know this page:
http://www.gamedev.net/reference/list.asp?categoryid=31

There you can download the OpenGL1.2 version of the redbook in pdf format for free:
http://www.gamedev.net/reference/count.asp?LinkID=993

The redbook is a great book, i learned so much from it!

[edited by - Jonus on August 14, 2002 2:16:21 PM]
3/dont clip anything (let the hardware do it) u will want to cull things (not send them to opengl) though if the fall completely ouside the window

http://uk.geocities.com/sloppyturds/gotterdammerung.html

This topic is closed to new replies.

Advertisement