Rotating a triangle in SDL

Started by
28 comments, last by sdlprorammer 19 years, 10 months ago
I want to write a single program on rotating a triangle. The trinagle will also be filled with a color, or with many colors. How do i go about it? Am i going to keep drawing the triangle pixel by pixel? And the movement is also hard.. PLEASE help
Advertisement
Why not use OpenGL?

SDL has support for OpenGL integration, so this would be a breeze. There''s little sense in reinventing the wheel, unless this is for the sake of learning how 3D works.
Yeah it sounds as if you try to learn SDL by reading tutorials about opengl or directx.
SDL is meant for sprites. For example: why would you want to rotate triangles in a 2d tile based game?

You can rotate sdl surfaces using an additional library though.
http://www.ferzkopp.net/~aschiffler/Software/SDL_gfx-2.0/

But if I were you I''d approach learning differently.
You can''t start a new thread for each function of SDL here ...
Writing errors since 10/25/2003 2:25:56 AM
It's not 3D. It's only 2D. I want to rotate from the center ( only a point ).I know how to move a sprite in the screen, but rotating the triangle is a little harder.. So?

P.S RuneLancer could you show me some functions.. ( without pure SDL, with OpenGL too - just too have a look at them )?

>You can't start a new thread for each function of SDL here ...
I am sorry but i am a beginner in graphics, and, i know.... every beginning is hard so bear with me...

[edited by - sdlprorammer on May 27, 2004 9:38:17 AM]
Perhaps it would be wise to have a look at the SDL documentation that came with it? I learned everything I know about SDL from them, really; it's not too hard.

As for OpenGL functions, there's hardly any point in showing you example functions if they're taken out of context: it's a little hard to understand what the use of toying with the projection matrix is without explaining what the projection matrix is and what it's for, and how it affects an OpenGL scene as a whole. What you're looking for is a tutorial, pretty much. May I suggest having a look at NeHe? They have pretty good stuff to get you started.

On the subject of you asking so many questions about SDL, have you tried experimenting with these functions? A first-hand look at what happens when you use something can often be very insightful and could solve a lot of the questions you have. You can't expect to have the answer to everything spoon-fed to you when it comes to programming. And it'll make Clueless a happy man.

[edited by - RuneLancer on May 27, 2004 10:03:33 AM]

RuneLancer, if you read my posts, you''ll see that i do read the docs, and that i do expirement.

Anyway, on the topic, why would i go on OpenGL when what i want is 2D? Please let''s leave OpenGL alone right now. Can anybody please give me some notes on how to implement what i need?
I didn't write it because it is annoying.
With so many questions about specific functions ...
I think it is a better understanding of the big picture that would really help.
Read in the gamedev articles.
Look at SDL example programs.
Look at OpenGl example programs.
Read threads about 2d and 3d programming.

Looking at the SDL documentation alone does not make sense at that stage IMO.

Why would anybody want to rotate a triangle (why triangle???) in SDL?

[edited by - Clueless on May 27, 2004 10:23:44 AM]
Writing errors since 10/25/2003 2:25:56 AM
Rotation of graphics is getting beyond the basic 2D idea. When you want to start doing arbitrary rotations and scalings then you really need to look into 3D if you want speed. The SDL_gfx library may help you though.

[ MSVC Fixes | STL Docs | SDL | Game AI | Sockets | C++ Faq Lite | Boost
Asking Questions | Organising code files | My stuff | Tiny XML | STLPort]
ah.... Well if i am going to download a library for that stuff ( which as i understand shouldn''t be done with SDL ), and one just for writting text in the screen, then why don''t i just drop SDL and start OpenGL, witch with i can do everything SDL supports?
Why do you seem to think SDL and OpenGL are competing libraries. They are not. It''s like saying should I drop bananas in favour of a spoon.
You can quite happily use both together, one, or something different entirely to accomplish similar goals.

This topic is closed to new replies.

Advertisement