Advertisement Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

151 Neutral

About Red_falcon

  • Rank
  1. Hey, thanks for your answer, i will reflect on this later this day, cause other work wits for me. But it seems very helpful. I will use such graph for different things, but since i'm OpenGL programmmer, it will be used to generate GLSL shader. Cause i couldn't find free editor which will give me all options i want and especially not for GLSL 1.40/1.50. My nodes are only container for pins. Each output pin will hold the value (int, float, matrix, color) it should give to input pins they are connected. Evaluation of the container/pin that changed shouldn't be big hassle cause of the separation, in my opinion. I hope this idea is not too dumb. Greetings
  2. Hi this should give you the right way althouth its XNA, but it helped me back when i did one in OpenGL Game State Management in XNA Greetings
  3. Hello, for a couple of years i had the intention to write own node-based interface like Node Editor in Blender, Hypershade in Maya or MapZone. Now i finally got some spare time for it so the plan is to write in C# and visualize in WPF. But my first problem is, i cannot get my had wrapped around the data structures. I'm not that bad at programming, but this thing gives me headaches. I wrote a little test application to connect nodes between their pins and to check for data type of the connection. But it feels not really right. Base class Node for nodes and base class Pin for pins, also a Connection class exists. It looks all very simple, but if i look at other source code of similiar programs i have no idead why they look so complex and what my mistake is. Should it be done like an interface pattern? I would appreciate some suggestions or links how it's done.
  4. Red_falcon

    [C#] MouseMove makes rendering choppy

    Yeah, that was my thought the whole time, but how was it done in MDX? Tom Miller's loop is widely used so i guess it's the "best" in this case. I could take c++/clr and mix it with native code, like i did with another project, but i am trying to get a managed solution, beside of PeekMessage, which is native.
  5. Red_falcon

    [C#] MouseMove makes rendering choppy

    Since no one replied i tried a couple of solutions and hope the problem is gone. Now i use timer class from and the movement does not get choppy when i move the mouse. I'm still irritated why it was so with Stopwatch.
  6. Hi, i wrote a little app to test a couple of things under OpenGL with C#. The main loop is one that Tom Miller suggested. But my problem is event handling of .Net, if i move the mouse the movement of the dot becomes choppy, if i let the mouse go it becomes normal again. I would like to disable the mouse event processing by the form and do the poll myself. Has someone suggestions on how i could accomplish it? Program.cs using System; using System.Diagnostics; using System.Runtime.InteropServices; using System.Threading; using System.Windows.Forms; namespace GLLayers { internal class NativeMethods { [StructLayout(LayoutKind.Sequential)] public struct Message { public IntPtr hWnd; public IntPtr msg; public IntPtr wParam; public IntPtr lParam; public uint time; public System.Drawing.Point p; } [System.Security.SuppressUnmanagedCodeSecurity] [DllImport("User32.dll", CharSet = CharSet.Auto)] //import the User32.dll to get the PeekMessage method public static extern bool PeekMessage(out Message msg, IntPtr hWnd, uint messageFilterMin, uint messageFilterMax, uint flags); public NativeMethods() { } } /*static*/ class Program { public static float fps; private static Stopwatch stopwatch; /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { stopwatch = new Stopwatch(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Idle += new EventHandler(Application_Idle); Application.Run(new RenderWindow()); } static void Application_Idle(object sender, EventArgs e) { while (AppStillIdle) { // Render a frame during idle time (no messages are waiting) stopwatch.Start(); RenderWindow.DrawGLScene(); //stopwatch.Stop(); fps = (float)stopwatch.Elapsed.TotalSeconds; RenderWindow.i += 2.0f * fps; stopwatch.Reset(); Thread.Sleep(0); } } private static bool AppStillIdle { get { NativeMethods.Message msg; return !NativeMethods.PeekMessage(out msg, IntPtr.Zero, 0, 0, 0); } } } } RenderWindow.cs using System; using System.Runtime.InteropServices; using System.Windows.Forms; using Tao.OpenGl; using Tao.Platform.Windows; namespace GLLayers { class RenderWindow : Form { private static IntPtr hDC; // Private GDI Device Context private static IntPtr hRC; // Permanent Rendering Context int pixelFormat; public bool created; public static float i; static float x; public RenderWindow() { this.CreateParams.ClassStyle = this.CreateParams.ClassStyle | // Redraw On Size, And Own DC For Window. User.CS_HREDRAW | User.CS_VREDRAW | User.CS_OWNDC; this.SetStyle(ControlStyles.AllPaintingInWmPaint, true); // No Need To Erase Form Background this.SetStyle(ControlStyles.DoubleBuffer, true); // Buffer Control this.SetStyle(ControlStyles.Opaque, true); // No Need To Draw Form Background this.SetStyle(ControlStyles.ResizeRedraw, true); // Redraw On Resize this.SetStyle(ControlStyles.UserPaint, true); // We'll Handle Painting Ourselves i = 0.0f; x = 0.0f; this.FormClosing += new FormClosingEventHandler(win_FormClosing); this.Resize += new EventHandler(win_Resize); Gdi.DEVMODE dmScreenSettings = new Gdi.DEVMODE(); // Device Mode // Size Of The Devmode Structure dmScreenSettings.dmSize = (short)Marshal.SizeOf(dmScreenSettings); dmScreenSettings.dmPelsWidth = 320; // Selected Screen Width dmScreenSettings.dmPelsHeight = 240; // Selected Screen Height dmScreenSettings.dmBitsPerPel = 32; // Selected Bits Per Pixel dmScreenSettings.dmFields = Gdi.DM_BITSPERPEL | Gdi.DM_PELSWIDTH | Gdi.DM_PELSHEIGHT; // Try To Set Selected Mode And Get Results. NOTE: CDS_FULLSCREEN Gets Rid Of Start Bar. User.ChangeDisplaySettings(ref dmScreenSettings, User.CDS_FULLSCREEN); Gdi.PIXELFORMATDESCRIPTOR pfd = new Gdi.PIXELFORMATDESCRIPTOR(); // pfd Tells Windows How We Want Things To Be pfd.nSize = (short)Marshal.SizeOf(pfd); // Size Of This Pixel Format Descriptor pfd.nVersion = 1; // Version Number pfd.dwFlags = Gdi.PFD_DRAW_TO_WINDOW | // Format Must Support Window Gdi.PFD_SUPPORT_OPENGL | // Format Must Support OpenGL Gdi.PFD_DOUBLEBUFFER; // Format Must Support Double Buffering pfd.iPixelType = (byte)Gdi.PFD_TYPE_RGBA; // Request An RGBA Format pfd.cColorBits = (byte)32; // Select Our Color Depth pfd.cRedBits = 0; // Color Bits Ignored pfd.cRedShift = 0; pfd.cGreenBits = 0; pfd.cGreenShift = 0; pfd.cBlueBits = 0; pfd.cBlueShift = 0; pfd.cAlphaBits = 0; // No Alpha Buffer pfd.cAlphaShift = 0; // Shift Bit Ignored pfd.cAccumBits = 0; // No Accumulation Buffer pfd.cAccumRedBits = 0; // Accumulation Bits Ignored pfd.cAccumGreenBits = 0; pfd.cAccumBlueBits = 0; pfd.cAccumAlphaBits = 0; pfd.cDepthBits = 16; // 16Bit Z-Buffer (Depth Buffer) pfd.cStencilBits = 0; // No Stencil Buffer pfd.cAuxBuffers = 0; // No Auxiliary Buffer pfd.iLayerType = (byte)Gdi.PFD_MAIN_PLANE; // Main Drawing Layer pfd.bReserved = 0; // Reserved pfd.dwLayerMask = 0; // Layer Masks Ignored pfd.dwVisibleMask = 0; pfd.dwDamageMask = 0; hDC = User.GetDC(this.Handle); // Attempt To Get A Device Context pixelFormat = Gdi.ChoosePixelFormat(hDC, ref pfd); // Attempt To Find An Appropriate Pixel Format Gdi.SetPixelFormat(hDC, pixelFormat, ref pfd); hRC = Wgl.wglCreateContext(hDC); // Attempt To Get The Rendering Context Wgl.wglMakeCurrent(hDC, hRC); ReSizeGLScene(this.ClientRectangle.Width, this.ClientRectangle.Height); Gl.glShadeModel(Gl.GL_SMOOTH); // Enable Smooth Shading Gl.glClearColor(0.05f, 0.38f, 0.64f, 0.0f); Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); Gl.glClearDepth(1); // Depth Buffer Setup Gl.glEnable(Gl.GL_DEPTH_TEST); // Enables Depth Testing Gl.glDepthFunc(Gl.GL_LEQUAL); // The Type Of Depth Testing To Do Gl.glHint(Gl.GL_PERSPECTIVE_CORRECTION_HINT, Gl.GL_NICEST); // Really Nice Perspective Calculations this.StartPosition = FormStartPosition.Manual; this.Location = new System.Drawing.Point(0, 0); this.WindowState = FormWindowState.Maximized; this.FormBorderStyle = FormBorderStyle.None; this.TopMost = true; this.Focus(); //win.Show(); created = true; } void win_Resize(object sender, EventArgs e) { ReSizeGLScene(this.ClientRectangle.Width, this.ClientRectangle.Height); } public static bool DrawGLScene() { Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer Gl.glLoadIdentity(); // Reset The Current Modelview Matrix Gl.glTranslatef(0.0f, 0.0f, -5.0f); Gl.glBegin(Gl.GL_POINTS); Gl.glVertex2f(x, (float)Math.Sin(i)); Gl.glEnd(); Gdi.SwapBuffers(hDC); return true; } private static void ReSizeGLScene(int width, int height) { if (height == 0) { // Prevent A Divide By Zero... height = 1; // By Making Height Equal To One } Gl.glViewport(0, 0, width, height); // Reset The Current Viewport Gl.glMatrixMode(Gl.GL_PROJECTION); // Select The Projection Matrix Gl.glLoadIdentity(); // Reset The Projection Matrix Glu.gluPerspective(45, width / (double)height, 0.1, 100); // Calculate The Aspect Ratio Of The Window Gl.glMatrixMode(Gl.GL_MODELVIEW); // Select The Modelview Matrix Gl.glLoadIdentity(); // Reset The Modelview Matrix } void win_FormClosing(object sender, FormClosingEventArgs e) { created = false; } ~RenderWindow() { } } } Edit: I changed the line RenderWindow.i += 2.0f * fps; to RenderWindow.i += 0.05f; and it seem to work without problems, but i need frame independent movement. [Edited by - Red_falcon on July 17, 2009 4:12:13 AM]
  7. Hi guys, I need a couple of suggestions to start off the ground with DAGs. Language: C++ .NET/C# I want to make a software which allows to build graphs like the texture tool MapZone, but for DSP in this case. I want to connect a couple of filters together and process input from line-in. It's only for teaching myself new tricks and for fun. The 1. problem: How to create nodes with variable inputs/outputs. Should i create for every node/filter type a class with fixed in/outs or is there ab better way? The 2. problem: How to draw it? I thought of user control which is a canvas. It gets a list of nodes, draws them and also the arrows. Thanks in advance Andi
  8. Red_falcon

    Multi format movie playing

    Thats my original function: void CreateEmptyTexture(unsigned int id, int bpp, int width, int height) { glEnable(GL_TEXTURE_RECTANGLE_ARB); glBindTexture(GL_TEXTURE_RECTANGLE_ARB,id); glTexParameteri(GL_TEXTURE_RECTANGLE_ARB,GL_TEXTURE_MAG_FILTER,GL_NEAREST); glTexParameteri(GL_TEXTURE_RECTANGLE_ARB,GL_TEXTURE_MIN_FILTER,GL_NEAREST); //glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); //glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); //gluBuild2DMipmaps(GL_TEXTURE_2D, bpp, h, v, f, GL_UNSIGNED_BYTE, texdata); glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB/*bpp*/, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL); glBindTexture(GL_TEXTURE_RECTANGLE_ARB,NULL); glDisable(GL_TEXTURE_RECTANGLE_ARB); }
  9. Red_falcon

    Multi format movie playing

    There is one little error in your code. GL_TEXTURE_2D should be GL_TEXTURE_RECTANGLE_ARB(I hope i remember the sentence right). EDIT: I suggest to take GLEW or GLEE for extensions, it takes a lot of work off you.
  10. Red_falcon

    Multi format movie playing

    Hi. Sorry had not much time cause i'm working on a project at the moment(the code i posted is from it :)). I use ARB_TEXTURE_RECTANGLE extension to display videos. The size of the videos is 1280x720, converted form MPEG-2 Transport Stream to Quicktime format.
  11. Red_falcon

    Multi format movie playing

    No need to compile yourself, I had enough pain trying it, and failing of course;) here you get ready compiled dll's and libs: and they have a forum for ffmpeg.
  12. Red_falcon

    Multi format movie playing

    I have never used any wrappers, only native OpenGL and a couple of supporting libs. But if you want it to be portable then you can try SDL or something equal. I can't speak for Linux, cause i never tried to program for it.
  13. Red_falcon

    Multi format movie playing

    Actually not, FFMPEG supports enough other formats :) That's why i use it for Quicktime, cause i dislike, that official QT SDK lacks of OpenGL support under Windows.
  14. Red_falcon

    Multi format movie playing

    Here is a part of my code, you must modify and clean it up to run, but it works. Caution its for OpenGL, but DirectX should be no problem. if(av_open_input_file(&pFormatCtx, filename.c_str(), NULL, 0, NULL)!=0) { MessageBox(NULL,"av_open error","Error",MB_OK); // Couldn't open file PostQuitMessage(0); return 0; } if(av_find_stream_info(pFormatCtx)<0) { MessageBox(NULL,"No streams","Error",MB_OK); PostQuitMessage(0); return 0; } unsigned int i; videoStream = -1; for(i=0; i<pFormatCtx->nb_streams; i++) { if(pFormatCtx->streams->codec->codec_type==CODEC_TYPE_VIDEO) { videoStream=i; break; } if(videoStream==-1) { MessageBox(NULL,"No video streams","Error",MB_OK); PostQuitMessage(0); return 0; } } pCodecCtx=pFormatCtx->streams[videoStream]->codec; AVCodec *pCodec; pCodec=avcodec_find_decoder(pCodecCtx->codec_id); if(pCodec==NULL) { MessageBox(NULL,"No codec availaible","Error",MB_OK); PostQuitMessage(0); return 0; } if(avcodec_open(pCodecCtx, pCodec)<0) { MessageBox(NULL,"Codec could not be opened","Error",MB_OK); PostQuitMessage(0); return 0; } pFrameRGB=avcodec_alloc_frame(); pFrame=avcodec_alloc_frame(); numBytes=avpicture_get_size(PIX_FMT_RGB24, pCodecCtx->width,pCodecCtx->height); buffer=new uint8_t[numBytes]; avpicture_fill((AVPicture *)pFrameRGB, buffer, PIX_FMT_RGB24, pCodecCtx->width, pCodecCtx->height); pSWSCtx = sws_getContext(pCodecCtx->width, pCodecCtx->height, pCodecCtx->pix_fmt, pCodecCtx->width, pCodecCtx->height, PIX_FMT_RGB24, SWS_FAST_BILINEAR, NULL, NULL, NULL); And here how to copy it ot the texture: if(av_read_frame(pFormatCtx, &packet)>=0) { if(packet.stream_index==videoStream) { avcodec_decode_video(pCodecCtx, pFrame, &frameFinished,, packet.size); if(frameFinished) { //sws_scale((AVPicture *)pFrameRGB, PIX_FMT_RGB24, (AVPicture*)pFrame, pCodecCtx->pix_fmt, pCodecCtx->width, pCodecCtx->height); sws_scale(pSWSCtx, pFrame->data, pFrame->linesize, 0, pCodecCtx->height, pFrameRGB->data, pFrameRGB->linesize); } } } else curr_frame = 0; av_free_packet(&packet); I hope it helps a bit. If you have questions, ask. EDIT: Oops, forgot to post the texture update function, sorry. glTexSubImage2D(GL_TEXTURE_RECTANGLE_ARB,0,0,0,vid->GetWidth(),vid->GetHeight(),GL_RGB,GL_UNSIGNED_BYTE,(char*)pFrameRGB->data[0]);
  15. Red_falcon

    PhysX and DirectX

    I had the same problem as you. I needed some info on DX an PhysX, cause the docs in the SDK are most for OGL. I found this example and used also the docs of PhysX. Now PhysX works well with DX in my app.
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!