Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

Krum110487

Member Since 22 Sep 2010
Offline Last Active Aug 19 2012 04:21 PM
-----

Topics I've Started

Ortho Near/Far not working as I expected

17 August 2012 - 04:26 PM

ok I am having an issue where I have a plane which I am spinning in 3d space, and it is getting cut off then the edge is to far away, or past the near.

so I figured I would set the near and far to really high numbers to see if that would fix it, but it doesn't seem to matter, does ortho not cover this?

GL.Ortho(0, screen_width, screen_height, 0, -10000, 10000);
GL.Viewport(0, 0, screen_width, screen_height);

then the render code is this:
GL.MatrixMode(MatrixMode.Projection);
GL.LoadIdentity();


//GL.Scale(.5,.5,.5);
GL.Rotate(video_rotation_x % 360, 0, 1, 0);
GL.Rotate(video_rotation_y % 360, 1, 0, 0);
GL.Rotate(video_rotation_z % 360, 0, 0, 1);

GL.Begin(BeginMode.Quads);
GL.TexCoord2(0, 0);
GL.Vertex2(x, y);
GL.TexCoord2(1, 0);
GL.Vertex2(x + (float)video_width, y);
GL.TexCoord2(1, 1);
GL.Vertex2(x + (float)video_width, y + (float)video_height);
GL.TexCoord2(0, 1);
GL.Vertex2(x, y + (float)video_height);
GL.End();

I assumed that the -10000 would be more than enough for the near, but the corners at certain angles is cut off (looks flat) and I am just curious as to why, the video is not wider than 800 and it is at 0, so the max it could be is -800 right? maybe a bit further, but shouldn't come near -10,000, but no matter what value I use, it doesn't seem to make a difference.

also if I scale it to .5, .5, .5 it isn't clipped at all, so I am not sure how to fix it.

what am I missing?

Rotate flat surface in 3D space

14 August 2012 - 10:02 AM

Ok, I am new to OpenGL and I am having a bit of trouble:

currently I am rotating a texture by using glRotate on the vertex's

GL.Rotate(45, 1.0, 0.0, 0.0);
GL.Begin(BeginMode.Polygon);
GL.TexCoord2(0, 0);
GL.Vertex2(ULx, ULy);
GL.TexCoord2(1, 0);
GL.Vertex2(URx, URy);
GL.TexCoord2(1, 1);
GL.Vertex2(BRx, BRy);
GL.TexCoord2(0, 1);
GL.Vertex2(BLx, BLy);
GL.End();

This works fine, but since it is just a 2d matrix operation all of the rotations are pretty much squashing the texture (it doesn't look like the far side is far away), in the example, I would expect the top to have a smaller width than the bottom width, because it is visible but further away.

this isn't the case, and I understand why (I've taken Linear Algebra :-P)

I am looking to create a 3D FLAT object, would it be a cube where one side is 0 width?
and I want to rotate it in 3D space where the perspective is correct.

I don't really know how to accomplish this yet, most of the code I find makes 3D cubes (although I am having trouble placing my texture on it).

Any help is appreciated.

thanks.

C# Rendering Video from external thread using LibVlc

13 August 2012 - 12:43 AM

Ok, I am new to openGL.

I am having a hard time figuring out what the best method is for rendering a video in 3D space.

I am using C# as my development because I only really want to focus on Windows for now and it is great for quick prototyping...anyway.

I am using OpenTK which is essentially the same as openGL (if you didn't already know), so information on either would be great.

I am using VLC so any file type can be supported.


Currently I have this code:
[source lang="csharp"]IMediaPlayerFactory factory = new MediaPlayerFactory();IVideoPlayer player = player = factory.CreatePlayer<IVideoPlayer>();IMedia media = factory.CreateMedia<IMedia>(@"C:\test.flv");IMemoryRenderer memRender = player.CustomRenderer;memRender.SetCallback(delegate(Bitmap frame){ //This is my callback, so every frame for VLC code call this. //This code should lock and update the texture (unsure if it is needed to lock)});memRender.SetFormat(new BitmapFormat(300, 300, ChromaType.RV24));player.Open(media);player.Play();[/source]

would it be better to render in the Callback?
or during the render loop?

I have tried everything and searched the net for ideas to get the bitmap from the video to the texture, but I haven't been successful, I know the bitmap is correct, because I wrote code to output it, so it is rendering, I just can't get OpenTK to generate the texure and load it onto the screen.

I want the focus to be on speed.

any help is appreciated, thanks!

PARTNERS