Page 2 of 3 FirstFirst 123 LastLast
Results 41 to 80 of 83

Thread: [VB6] Direct3D9.

  1. #41
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,195

    Re: [VB6] Direct3D9.

    Quote Originally Posted by xman2000 View Post
    Hi, TheTrick

    is awesome this 3D9 libary, you like make this entire in VB6 ? why?
    Hi xman2000,

    I've got no idea what motivates The Trick, as I've got little idea what motivates myself. However, I'm sure glad that The Trick was willing to share this work. I've used it in several of my own VB6 projects. Here's a C3D mocap reader I've posted on the CodeBank that uses it. I've also used it in several other contexts.

    Take Care,
    Elroy
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  2. #42
    Lively Member
    Join Date
    Jun 2016
    Posts
    106

    Re: [VB6] Direct3D9.

    Quote Originally Posted by Elroy View Post
    Hi xman2000,

    I've got no idea what motivates The Trick, as I've got little idea what motivates myself. However, I'm sure glad that The Trick was willing to share this work. I've used it in several of my own VB6 projects. Here's a C3D mocap reader I've posted on the CodeBank that uses it. I've also used it in several other contexts.

    Take Care,
    Elroy
    Hi Elroy,
    this 3D9 libray is a greate work, greate project, and not problem if closed source-code, only i need some time use pure vb6 and i like to find in the web a pure vb6 library like this 3D9.

    My intention not is find the library only by algorithms but to pradronize the code, and se Library is big i use like external compiled file, but if the codes i need is small i use only few codes of library to my project, or rebuild the library into small libraries but with same pradronized code, to avoid bugs, to make more easy understand.

    only is a question to know the plans of the autor and possible difficulties to implement this idea.


    cheers.
    Last edited by xman2000; Dec 23rd, 2018 at 10:41 AM.

  3. #43
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,195

    Re: [VB6] Direct3D9.

    Quote Originally Posted by xman2000 View Post
    this 3D9 libray is a greate work, greate project, and not problem if closed source-code, only i need some time use pure vb6 and i like to find in the web a pure vb6 library like this 3D9.
    Hi Xman,

    Everything about The Trick's work is open-source. I'm not sure what you mean by closed-source?!

    He provided many linear algebra procedures (in VB6 open-source source-code). But the main thing he provides is the DX9VB.tlb TypeLib, which allows VB6 to interface with the DirectX3D library built into Windows. And this DX9VB.tlb is easily open-source as well. Here, I've attached the IDL file for your perusal (see attached ZIP).

    Now, you say "pure VB6". This is about as pure VB6 as it gets. Do you want to do all the DirectX3D graphics functions in VB6 code? If so, that's sort of insane because the DirectX technology interfaces directly with the GPU (graphics processing unit) of your hardware to do its work. Sure, you could write your own procedures with the graphics statements of a PictureBox (or a Form), but they'd be MUCH slower than anything using DirectX. Without DirectX (or some other similar technology, such as the stuff that uses OpenGL), you're not interfacing directly with the GPU. That's the whole reason for DirectX.

    Now, if you want the TypeLib out of the picture (and there's really no reason for that), you could drop back to DirectX8, which is directly COM compatible. Also DirectX8 uses StdCall, which allows for API declarations directly in the VB6 source code, and no need for a TypeLib. But again, what's wrong with a TypeLib?

    The DirectX9 just comes with all recent versions of Windows, which is very convenient. However, to use DirectX8, you'll have to find a copy of the dx8vb.dll, and distribute it with your application.

    Good Luck,
    Elroy
    Attached Files Attached Files
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  4. #44
    Lively Member
    Join Date
    Jun 2016
    Posts
    106

    Re: [VB6] Direct3D9.

    Hi, Elroy,

    yes, i like "Do you want to do all the DirectX3D graphics functions in VB6 code? If so, that's sort of insane"

    not problem if is more slow, only if works very well.

    "Now, if you want the TypeLib out of the picture"
    i not understand "out of the picture" but i like the TypeLib in pure vb6 inside the project like a module .bas, or class or .frm but i need not use files.

    in some times i use external files, .dll, .ocx, but other times i like use only vb6 code and others with apis.

    i understand you speak this Libarry is to DirectX interaction, i I had imagined that something like this already existed, and that this library was a little (little and simple) substitute for Directx and people can add more features.

    "you're not interfacing directly with the GPU"
    yes, we can make a 3D Library replacement of Directx more simple with not GPU and other version of the 3D library with GPU.

    What would we need to do to create a GPU version?
    there would be a need to create compatibility for the drivers of each VGA GPU device of each company?
    eu can stop this subject not to flood this thread.

    not problem if is more slow, only if works very well and not uses external files or external ressources, the most compatible and universal is better for some uses.

    like this idea: have a 3D libray in pure VB6 i can put all code inside the vb project an re-use all functions and rebuild the big library into small libraries to especific purposes and can padronize the codes i use in image processing, and can add more features, more algorithms like scientific and image vision, medical, etc.

    edit:it is not always necessary that the performance be very fast as for games at 60fps, it can be slow if it is only to visualize an object or a scenario observing the details, but perhaps to edit objects and see the changes in a reasonable speed a non- GPU library I do not know if it will.


    edit2: but if we can but use the GPU but with everything written in VB6 with total replacement of Directx or OpenGL would be very good, even if it is a little slower than them.

    This 3D9 library by TheTrick is greate and is specific to DirectX, greate!
    I was not sure if it was this or a replacement. Now i know.
    Last edited by xman2000; Dec 23rd, 2018 at 12:29 PM.

  5. #45
    New Member
    Join Date
    Mar 2019
    Posts
    2

    Re: [VB6] Direct3D9.

    How about this? im using this source code but I cant load pictures from memory. Thanks.

  6. #46

  7. #47
    New Member
    Join Date
    Mar 2019
    Posts
    2

    Re: [VB6] Direct3D9.

    Hi The trick! Thanks for replying.

    Im trying to load a PNG file in memory directly into DX9, I used the D3Dx.CreateTextureFromFileInMemoryEx but I cannot find it in your typelib. Thanks.

  8. #48

  9. #49
    New Member
    Join Date
    Oct 2019
    Posts
    3

    Re: [VB6] Direct3D9.

    Hi all,

    I need your help

    My problem: two textures; one for background (image from hd), the other one with a lot of text (with vertex), black background, and text color random.

    I need to make transparent only the black background, not alpha the text (must be completly opaque)Name:  Schermata del 2019-10-17 10-25-13.jpg
Views: 1025
Size:  33.9 KB

    This is my code:

    ' // Apply texture Background
    d3dev.SetTexture 0, texture
    d3dev.DrawPrimitive D3DPT_TRIANGLELIST, 0, 2

    ' // Remove texture
    d3dev.SetTexture 0, Nothing
    d3dev.SetTexture 0, textureText

    d3dev.SetRenderState D3DRS_ALPHABLENDENABLE, 1
    d3dev.SetRenderState D3DRS_SRCBLEND, D3DBLEND_SRCCOLOR
    d3dev.SetRenderState D3DRS_DESTBLEND, D3DBLEND_DESTCOLOR
    d3dev.SetRenderState D3DRS_BLENDOP, D3DBLENDOP_ADD
    d3dev.SetRenderState D3DRS_BLENDOP, D3DBLENDOP_ADD


    ' // Draw background
    d3dev.DrawPrimitive D3DPT_TRIANGLELIST, 6, 2
    d3dev.SetTexture 0, Nothing
    d3dev.EndScene

    d3dev.Present ByVal 0, ByVal 0, 0, ByVal 0


    Thanx in advance.

    Ciao.
    L.

  10. #50
    New Member
    Join Date
    Oct 2019
    Posts
    3

    Re: [VB6] Direct3D9.

    Hi all,

    I need your help

    My problem: two textures; one for background (image from hd), the other one with a lot of text (with vertex), black background, and text color random.

    I need to make transparent only the black background, not alpha the text (must be completly opaque)Name:  Schermata del 2019-10-17 10-25-13.jpg
Views: 1025
Size:  33.9 KB

    This is my code:

    ' // Apply texture Background
    d3dev.SetTexture 0, texture
    d3dev.DrawPrimitive D3DPT_TRIANGLELIST, 0, 2

    ' // Remove texture
    d3dev.SetTexture 0, Nothing
    d3dev.SetTexture 0, textureText

    d3dev.SetRenderState D3DRS_ALPHABLENDENABLE, 1
    d3dev.SetRenderState D3DRS_SRCBLEND, D3DBLEND_SRCCOLOR
    d3dev.SetRenderState D3DRS_DESTBLEND, D3DBLEND_DESTCOLOR
    d3dev.SetRenderState D3DRS_BLENDOP, D3DBLENDOP_ADD
    d3dev.SetRenderState D3DRS_BLENDOP, D3DBLENDOP_ADD


    ' // Draw background
    d3dev.DrawPrimitive D3DPT_TRIANGLELIST, 6, 2
    d3dev.SetTexture 0, Nothing
    d3dev.EndScene

    d3dev.Present ByVal 0, ByVal 0, 0, ByVal 0


    Thanx in advance.

    Ciao.
    L.

  11. #51

  12. #52
    New Member
    Join Date
    Oct 2019
    Posts
    3

    Re: [VB6] Direct3D9.

    Quote Originally Posted by The trick View Post
    Use additive blending (see Fire example demo).
    Hi Trick, first of all thank you (sorry for delay).

    I saw the fire example, but maybe isn't what i'm looking for. My problem is that the second texture (the one with the text only) must be opaque (with black background completly transparent):

    - texture 0: a random image from file
    - texture 1: opaque text (background is black)

    Is possibile?

    PS: As you can see, I'm not an expert of DirectX

    Thank you again.

    Ciao.
    L.

  13. #53

  14. #54
    Fanatic Member
    Join Date
    Sep 2010
    Location
    Italy
    Posts
    682

    Re: [VB6] Direct3D9.

    hello this seems to me the best starting point to create a 3d graphic engine for "games".
    What I noticed in the examples is that necessary code in my opinion is a little too low level.
    I'd like to have higher-level classes / functions such as in TrueVision3D.
    Do you think it would be a good idea to build these higher level classes? (in a sense simplified and more intuitive to use)
    anyone interested?
    These classes could be for example:
    • SCENE
    • CAMERA
    • MATERIAL
    • OBJECT
    • MESH
    • TEXTURE
    • LIGHT
    • GROUND
    • SKY
    • HELPER-Math such as VECTOR MATRIX QUATERNION
    • TEXT, "SPRITES", 2D shapes, .... MORE


    What do you think? Is it an absurd idea?
    What difficulties would be encountered?
    What would be the pros and cons?

  15. #55
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,195

    Re: [VB6] Direct3D9.

    Hi Reexre,

    In the project on which I'm currently working, I've got clsDxScene, clsDxMesh, & clsDxCamera. I haven't messed with texturing, and I typically just deal with lighting and ground in the clsDxScene class. I also haven't done anything with the 2D stuff ... well, it's been a while, and it was back when I was still using DX8.

    I'm not sure I'd know the difference between Mesh and Object, nor the difference between Texture and Material.

    Also, The Trick's work was/is always my starting place with DX9, but I've reworked all his math procedures into functions. They're just more intuitive to me that way, so I'm not starting from exactly the same place as everyone else.

    But, I certainly think it's a good idea, possibly a VB6 DLL with its own set of classes and calls.

    Take Care,
    Elroy
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  16. #56
    Fanatic Member
    Join Date
    Sep 2010
    Location
    Italy
    Posts
    682

    Re: [VB6] Direct3D9.

    Quote Originally Posted by Elroy View Post
    In the project on which I'm currently working, I've got clsDxScene, clsDxMesh, & clsDxCamera. I haven't messed with texturing, and I typically just deal with lighting and ground in the clsDxScene class. I also haven't done anything with the 2D stuff ... well, it's been a while, and it was back when I was still using DX8.
    Wow very interesting! Do you plan on sharing this code at some point?

    I'm not sure I'd know the difference between Mesh and Object, nor the difference between Texture and Material.
    About Object I think I was wrong... Yes it should be the same.
    About Textutre and Material I would differentiate them like this:
    Material is what concerns color and the relationship with light such as reflection etc.
    Texture is a kind of image applied to a surface.
    but, yes in fact they can also be considered as a single aspect. (of a surface / mesh)

    Also, The Trick's work was/is always my starting place with DX9, but I've reworked all his math procedures into functions. They're just more intuitive to me that way, so I'm not starting from exactly the same place as everyone else.
    Agree and understand

    But, I certainly think it's a good idea, possibly a VB6 DLL with its own set of classes and calls.
    Yes, I too had thought of a DLL.

    Well, then if you want to share the code it would be fantastic, and maybe somehow me and others could contribute to it.

    EDIT:
    Here's what I thought about OBJECT.
    By OBJECT I meant a hierarchical set of meshes. (Parent / child)
    Which could have characteristics related to the other such as pivot point and rotation.

  17. #57
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,195

    Re: [VB6] Direct3D9.

    Quote Originally Posted by reexre View Post
    Here's what I thought about OBJECT.
    By OBJECT I meant a hierarchical set of meshes. (Parent / child)
    Which could have characteristics related to the other such as pivot point and rotation.
    Yeah, after I posted, I had a similar though. An "Object" might be a way to group individual mesh pieces. And then, they could possibly be moved and rotated as a unit.

    And yeah, I see the distinction between Texture and Material.

    I'm still deciding about when/whether I'm going to share the code to this latest project. However, here is another project that has pretty much all of the same features.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  18. #58
    Fanatic Member
    Join Date
    Sep 2010
    Location
    Italy
    Posts
    682

    Re: [VB6] Direct3D9.

    Quote Originally Posted by Elroy View Post
    ..... However, here is another project that has pretty much all of the same features.
    Wow huge work!
    So I begin creating the engine using it.
    I opened a new thread about this

  19. #59

  20. #60
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,747

    Re: [VB6] Direct3D9.

    I tried CornerPin.
    if I start the project in IDE, I see the picture, but when I click on any of the "dots" the picture disappears.
    when I compile it and run the EXE, it works.

    Im now in windows 10. maybe thats the reason?

  21. #61

  22. #62
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,747

    Re: [VB6] Direct3D9.

    yeah, the points works, I can move them around. but the picture itself is not shown at all.
    only at start I see picture, once I start moving the dots, the picture disappears and never returns.
    but, if I compile and run .exe it works.

  23. #63
    Hyperactive Member gaouser's Avatar
    Join Date
    Mar 2022
    Location
    Near the User32.dll
    Posts
    390

    Re: [VB6] Direct3D9.

    @the trick can you add a import .obj or .x demo

  24. #64
    Hyperactive Member gaouser's Avatar
    Join Date
    Mar 2022
    Location
    Near the User32.dll
    Posts
    390

    Re: [VB6] Direct3D9.

    hi the trick can you add a example fot loading,resizing,moving,rotating .x or .obj in dx9vb

  25. #65
    Hyperactive Member gaouser's Avatar
    Join Date
    Mar 2022
    Location
    Near the User32.dll
    Posts
    390

    Re: [VB6] Direct3D9.

    how to load obj with it

  26. #66

  27. #67
    Hyperactive Member
    Join Date
    Jul 2017
    Posts
    372

    Re: [VB6] Direct3D9.

    I would like to capture a small region of 40 x 80 pixels of my screen as bmp at 60 fps.

    I want to record a certain checkbox slider animation.
    Why bmp? I need to be able to perfectly compare the frames to see changes from 1 frame to another to see if anything happened, as I want to discard frames where nothing happened.
    I tried that to do that with a screen recorder, but the one which could record at 60 fps would not record in a losless format, so I always got compressed frames which never looked perfectly the same althought (judging with a human eye) nothing happened. This showed me that I really need to use bmp.

    Can I do that using your DirectX library in VB6?
    Thank you!

  28. #68
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,988

    Re: [VB6] Direct3D9.

    Search for a lossless screen recorder, like https://www.wisdom-soft.com/products...enrecorder.htm
    And the free CamStudio also support LossLess encoding
    ..
    And if all that wasn't enough, CamStudio also comes with its own Lossless Codec that produces crystal clear results with a much smaller filesize compared with other more popular codecs, like Microsoft Video 1.
    ..

  29. #69
    Hyperactive Member
    Join Date
    Jul 2017
    Posts
    372

    Re: [VB6] Direct3D9.

    Yes, I found out how to do it with litecam and a losless codec, however I don't want to rely on closed source apps anymore, that was also a reason why I asked here.

  30. #70
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,988

    Re: [VB6] Direct3D9.

    But you are using Windows and VB6?

  31. #71
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,908

    Re: [VB6] Direct3D9.

    https://stackoverflow.com/questions/...-using-directx

    The example there uses Direct3D 9; I didn't check if The trick's lib has everything needed. Note there's a comment there about partial screen captures with a dead link; here's the archive of it if you need it.

    As that thread notes, there's better options if you don't need to support Windows 7. There's a VB6 implementation of Desktop Duplication.

  32. #72
    Frenzied Member VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    1,539

    Talking Re: [VB6] Direct3D9.

    Quote Originally Posted by tmighty2 View Post
    I would like to capture a small region of 40 x 80 pixels of my screen as bmp at 60 fps.
    You could try my VB6 Capture any Window with WinRT / Windows.Graphics.Capture project for that. You can set it to capture any region from a window or from the entire monitor.

    It does capture all frames as bitmaps as you wanted but the frame rate is way higher than 60 fps so you'd have to employ a timer if you want less frames. Also you'd need to save the frames yourself (with SavePicture or some such) as at the moment they are only displayed in a PictureBox and not encoded in a stream in any way.

  33. #73
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,230

    Re: [VB6] Direct3D9.

    @VanGoghGaming: Btw, you could use the class to implement a full-blown screen to GIF/MP4 app by shelling ffmpeg (or not) so that the sample project is full (includes capture frame-rate) and feature-rich (allow captions, mouse movements, etc.)

  34. #74
    Frenzied Member VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    1,539

    Lightbulb Re: [VB6] Direct3D9.

    I don't know anything about ffmpeg but shelling out external applications to do the job for you doesn't sound like a proper thing to do. The project can already capture mouse movements, the property is just set to False by default. The next step in development would indeed be making a video file from the captured frames.

    WinRT does seem to have the right tools for the job as explained in this article: Screen capture to video but translating C# into VB6 when all you can rely on is "DispCallFunc" is an extremely tedious process to say the least.

    I've spent days on end on this screen capture project which at first was just capturing frames synchronously in a loop and then spent even more days implementing surrogate events to make it asynchronous and get rid of the loop but now the novelty has pretty much worn off. Anyone who wants to take it further is welcome to though.

  35. #75
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,908

    Re: [VB6] Direct3D9.

    I've been looking at some possible alternatives tB might be able to do with WinRT... if Python can make use of it through CppWinRT then why not tB?

    Because manually translating it into regular COM interfaces... it would be easier to use but holy hell would it take me forever. Looking at all the ones in that screengrab project it'd take weeks of devoting all my free time to it, and that's *counting* all the DirectX/DXGI/WIC stuff I've already got 100% covered.

  36. #76
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,230

    Re: [VB6] Direct3D9.

    Quote Originally Posted by VanGoghGaming View Post
    I don't know anything about ffmpeg but shelling out external applications to do the job for you doesn't sound like a proper thing to do.
    Trust me, it is the proper thing to do in this case. Everybody uses ffmpeg to produce/transcode video, it's like the gold standard, even youtube is using it.

    ScreenToGif has it's own proprietary animated GIF encoder but allows ffmpeg for video *and* animated GIFs -- the difference in output is huge (the difference on GIFs).

    cheers,
    </wqw>

  37. #77
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,195

    Re: [VB6] Direct3D9.

    Quote Originally Posted by gaouser View Post
    hi the trick can you add a example fot loading,resizing,moving,rotating .x or .obj in dx9vb
    By "obj", I assume you mean a Wavefront type file, and not a compiler intermediate file. As such, you're really talking about a piece of 3D mesh.

    Now, my understanding of Direct3D (whatever version), is, what we're getting is a GPU interface that allows loading 3D mesh into the GPU memory, texturing it, building a back-buffer-frame, and then displaying the whole-frame (with no build-flicker). Beyond that, we've got to do all other manipulations (rotation, translation, scaling) ourselves and then re-load them into the back-buffer to build another frame.

    So, to ask how to rotate, translate, & scale in DirectX is not a good question. You should just ask how to rotate, translate, & scale a piece of mesh in memory (regardless of the GPU approach).

    Now this requires a good working knowledge of 3D linear algebra (primarily, an understanding of what mesh is, and how to use 3D transformation matrices).

    Without getting into texturing, mesh is nothing but a set of 3D vertices with another set of pairs of pointers telling us how those 3D vertices are connected. But, for purposes of transformation (rotate, scale, translate), we can ignore the set of pairs of pointers, as they won't change. We just need to know how to transform each of the vertices in the mesh definition. Translation (moving) is easy. Just add (or subtract) the translation amount from each vertex. Scaling and rotation are a bit more complex, in that we must know the centroid around which to rotate and/or scale. We might just transform from <0,0,0> or we might calculated a vertex average around which to rotate. These are decisions that must be made, but we must have a centroid to scale or rotate.

    Once we've got our centroid, we must build a transformation matrix (which can include any/all of scale, rotate, translate), and these transformation matrices are applied in that order (scale first, rotate next, and finally translation). So, to do it in a different order, you must build separate transformation matrices, and do it in steps. Once our transformation matrix is built, we simply subtract the centroid, multiply it (via linear algebra) to each of our mesh vertices, re-add the centroid, and voila. Shove the results back into your Direct3D buffer and build a new frame with it. (And just as a further FYI, we must do this for each mesh-piece in our frame.)

    I'm not sure if that helps or not, but it's the answer. The trick does supply a wonderful VB6 library of 3D linear algebra procedures, but you've still got to know 3D linear algebra to know how to use them.
    Last edited by Elroy; Feb 8th, 2024 at 12:44 PM.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  38. #78
    Frenzied Member VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    1,539

    Talking Re: [VB6] Direct3D9.

    Quote Originally Posted by wqweto View Post
    @VanGoghGaming: Btw, you could use the class to implement a full-blown screen to GIF/MP4 app
    I thought I would give it a try to port that Screen Capture to Video C# project into VB6 but the attempt was rather short lived! I got stumped near the beginning on these 3 lines of C# code from the article:

    Code:
        var videoProperties = VideoEncodingProperties.CreateUncompressed(MediaEncodingSubtypes.Bgra8, width, height);
        _videoDescriptor = new VideoStreamDescriptor(videoProperties);
    
        // Create our MediaStreamSource
        _mediaStreamSource = new MediaStreamSource(_videoDescriptor);
    The VB6 equivalent (quite a handful compared to the 3 lines above) looks like this but it blows up on the red line below (which is the equivalent of "new MediaStreamSource(_videoDescriptor)"):

    Code:
    Private Sub SetupVideoStreamDescriptor()
    Dim lpIVideoEncodingPropertiesStatics As Long, lpIVideoEncodingProperties As Long, lpIVideoStreamDescriptorFactory As Long, lpIMediaEncodingSubtypesStatics As Long, hString As Long
        If GetActivationFactory(WindowsMediaMediaPropertiesVideoEncodingProperties, pIID(eIVideoEncodingPropertiesStatics), lpIVideoEncodingPropertiesStatics) Then
            If GetActivationFactory(WindowsMediaMediaPropertiesMediaEncodingSubtypes, pIID(eIMediaEncodingSubtypesStatics), lpIMediaEncodingSubtypesStatics) Then
                If InvokePtr(lpIMediaEncodingSubtypesStatics, IMediaEncodingSubtypesStatics_GetBgra8, VarPtr(hString)) = S_OK Then
                    If InvokePtr(lpIVideoEncodingPropertiesStatics, IVideoEncodingPropertiesStatics_CreateUncompressed, hString, m_lWidth, m_lHeight, VarPtr(lpIVideoEncodingProperties)) = S_OK Then
                        hString = WindowsDeleteString(hString)
                        If GetActivationFactory(WindowsMediaCoreVideoStreamDescriptor, pIID(eIVideoStreamDescriptorFactory), lpIVideoStreamDescriptorFactory) Then
                            InvokePtr lpIVideoStreamDescriptorFactory, IVideoStreamDescriptorFactory_Create, lpIVideoEncodingProperties, VarPtr(m_lpIVideoStreamDescriptor)
                        End If
                        ReleasePtr lpIVideoStreamDescriptorFactory
                    End If
                    ReleasePtr lpIVideoEncodingProperties
                End If
                ReleasePtr lpIMediaEncodingSubtypesStatics
            End If
            ReleasePtr lpIVideoEncodingPropertiesStatics
        End If
    End Sub
    
    Private Sub SetupMediaStreamSource()
    Dim lpIMediaStreamSourceFactory As Long
        If GetActivationFactory(WindowsMediaCoreMediaStreamSource, pIID(eIMediaStreamSourceFactory), lpIMediaStreamSourceFactory) Then
            If InvokePtr(lpIMediaStreamSourceFactory, IMediaStreamSourceFactory_CreateFromDescriptor, m_lpIVideoStreamDescriptor, VarPtr(m_lpIMediaStreamSource)) = S_OK Then
    
            End If
            ReleasePtr lpIMediaStreamSourceFactory
        End If
    End Sub
    I don't have a C# compiler to test if their example crashes in the same way but I really can't figure out what might be the problem. I doubled checked all the IIDs both from the SDK and the MagnumDB website, everything checks out...

    Here's a very small working project outlining the snippet above: MediaStreamSource.zip, if anyone would take a look I would appreciate it very much!

  39. #79

    Thread Starter
    PowerPoster
    Join Date
    Feb 2015
    Posts
    2,728

    Re: [VB6] Direct3D9.

    Quote Originally Posted by VanGoghGaming View Post
    Here's a very small working project outlining the snippet above: MediaStreamSource.zip, if anyone would take a look I would appreciate it very much!
    You have type error. If you see MediaStreamSource constructor it accepts IMediaStreamDescriptor whereas you pass IVideoStreamDescriptor. You should do something like this:

    Code:
    Private Sub SetupMediaStreamSource()
    Dim lpIMediaStreamSourceFactory As Long
    Dim lpIMediaStreamDescriptor As Long
    
        If InvokePtr(m_lpIVideoStreamDescriptor, IUnknown_QueryInterface, pIID(eIMediaStreamDescriptor), VarPtr(lpIMediaStreamDescriptor)) >= S_OK Then
            If GetActivationFactory(WindowsMediaCoreMediaStreamSource, pIID(eIMediaStreamSourceFactory), lpIMediaStreamSourceFactory) Then
                If InvokePtr(lpIMediaStreamSourceFactory, IMediaStreamSourceFactory_CreateFromDescriptor, lpIMediaStreamDescriptor, VarPtr(m_lpIMediaStreamSource)) = S_OK Then
        
                End If
                ReleasePtr lpIMediaStreamSourceFactory
            End If
            ReleasePtr lpIMediaStreamDescriptor
        End If
        
    End Sub

  40. #80
    Frenzied Member VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    1,539

    Thumbs up Re: [VB6] Direct3D9.

    Quote Originally Posted by The trick View Post
    You have type error. If you see MediaStreamSource constructor it accepts IMediaStreamDescriptor
    You know, that was literally the second thing I've tried and querying "IVideoStreamDescriptor" for "IMediaStreamDescriptor" always returned "80004002, No such interface supported"...

    Now that you've mentioned it, I've double checked everything again and it seems I was missing the curly braces around the declaration of the "IMediaStreamDescriptor" IID:

    Code:
    Private Const IID_IMediaStreamDescriptor As String = "80F16E6E-92F7-451E-97D2-AFD80742DA70"
    
    Private Const IID_IMediaStreamDescriptor As String = "{80F16E6E-92F7-451E-97D2-AFD80742DA70}"
    A lot of silly mistakes like this can happen when copy-pasting stuff in a hurry and a fresh pair of eyes can help more than you know. Thanks a lot for your help TheTrick, you rock!

    * Note to self: "IIDFromString" has a return value, USE IT!

    Code:
        lRet = IIDFromString(...)
        Debug.Assert lRet = S_OK

Page 2 of 3 FirstFirst 123 LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width