Advertisement

I have a sit'ya'ation

Started by August 26, 2003 12:28 PM
7 comments, last by LabRat404 21 years, 6 months ago
I have a questions: I have a program that loads groups of triangles fron a file, and draws them on screen. it loads some lines which tells it whether or not to rotate a secific group of triangles, what directions, and what speed. I also need to be able to lead a specific texture for each triagle. my problem is this: glrotatef() and glBindTexture() both have to be outside the bounds of a glBegin() anda glEnd(). for example, this is what my program must do: for each group: { glRotate(); glBegin();{ for each triangle: { glBindTexture(); /* ERROR, MUST BE OUTSIDE glBegin(); */ /* draw each triangle */ } }glEnd(); } if you can interpret that, the problem is that I need to use glBindTexture() within glBegin, but I cannot. I am stuck on a solution, I have tried nested glBegin(); ... glEng();''s, but that doesn''t seem to work--textures end up on the wrong triangle. if you want to see some real code I can post it. ( I am using C, not C++ ) 0x52 0x65 0x61 0x6C 0x69 0x74 0x79 0x43 0x72 0x61 0x73 0x68
0x52 0x65 0x61 0x6C 0x69 0x74 0x79 0x43 0x72 0x61 0x73 0x68
Do something like this instead.
for each group:{    glRotate();    for each texture in this group:    {        glBindTexture();        glBegin();        {            for each triangle using this texture:            {            /* draw each triangle */            }        }        glEnd();    }}
Advertisement
delete this..accidentally reposted

[edited by - labrat404 on August 26, 2003 9:36:35 PM]
0x52 0x65 0x61 0x6C 0x69 0x74 0x79 0x43 0x72 0x61 0x73 0x68
I did that, but that just spins each triangle respectively, not each group. glRotate() has to be outside glBegin() to rotate the whole group of triangles (which represents a cube, or whatever.)

0x52 0x65 0x61 0x6C 0x69 0x74 0x79 0x43 0x72 0x61 0x73 0x68
0x52 0x65 0x61 0x6C 0x69 0x74 0x79 0x43 0x72 0x61 0x73 0x68
quote:
I did that, but that just spins each triangle respectively, not each group. glRotate() has to be outside glBegin() to rotate the whole group of triangles (which represents a cube, or whatever.)

Then you did not do what Brother Bob posted and should read it again.
_______________________________________Pixelante Game Studios - Fowl Language
woops! yea. sorry, man. I misread your code. It works now. I dunno why I found this so hard...I''ve been coding for so long my head hurts. thanks for the help guys.

also, there is one more problem that I''ve been having. Perhaps its just another miniscule mistake like the last -- I can plot groups of tirangles anywhere. I currently have a large square (2 triangles) as a floor underneath a spining cube. I can move the cube up, down, left, etc, without disturbing other groups.
my question is this: how can I change the origin or the spinning cube? origin as in the origin the cube spins around, not where it gets drawn... for example, to make the cube spin around one of its own corners, the very tip of the corner remaining stationary.
0x52 0x65 0x61 0x6C 0x69 0x74 0x79 0x43 0x72 0x61 0x73 0x68
Advertisement
I didn''t understand what u meant, but the glRotate rotates the objects in the previous location(glTranslate) position. You create a object in the x=0. So you translate ur current x position to x=1. the glRotate will spin the object, that x=0, around x=1. Make Sense?

"There are people who live in the reality. We recreate it!"
"There are people who live in the reality. We recreate it!"
lobravo just wanted to say I love your sig! :D

Love means nothing to a tennis player

My nothing-to-write-home-about OpenGL webpage. (please pardon the popups!)

what I mean is, I made a cube (a group of triangles) and I can use glTranslate to move it around my world, and use GlRotate() to spin it around. the origin, which means the point at which the cube spins around, is in the center (dead center) of the cube. I want to be able to move the origin so that I can make it spin around a given origin. that is as best as I can explin it...

[edited by - labrat404 on August 28, 2003 12:10:00 AM]
0x52 0x65 0x61 0x6C 0x69 0x74 0x79 0x43 0x72 0x61 0x73 0x68

This topic is closed to new replies.

Advertisement