• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0

A small Problem with SharpDX

4 posts in this topic



I do not know if this is the right forum, but I am looking for help with SharpDX 2.6. I have very simple

algorithm to create and draw a triangle. unfortunately, I see nothing.

Can anyone help ?


Source is here:






Share this post

Link to post
Share on other sites

Why are you using a DirectX binding for C# under C++? Because of the SharpDX Toolkit?


Share this post

Link to post
Share on other sites

Wou, mabybe I found a solution: ( SharpDX, SlimDX, ManagedDX ) with C++/CLI


#pragma once
namespace CLRW58 {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::Threading; 
using namespace Microsoft::DirectX; 
using namespace Microsoft::DirectX::Direct3D;
#define RGB(r,g,b) (((r)<<16) | ((g)<<8) | (b))
 //using namespace Microsoft::Xna::Framework;
//using namespace Microsoft::Xna::Framework::Content; 
//using namespace Microsoft::Xna::Framework::Graphics;   
/// <summary>
/// Summary for Form1
///          resources associated with this form.
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
Microsoft::DirectX::Direct3D::Device^ _dev; 
Microsoft::DirectX::Direct3D::IndexBuffer^ ib; 
  Microsoft::DirectX::Direct3D::VertexBuffer^ _vb;
Microsoft::DirectX::Direct3D::Font^ font;
Microsoft::DirectX::Direct3D::PresentParameters^ _presentParams = gcnew Microsoft::DirectX::Direct3D::PresentParameters();
_presentParams->Windowed = true;
_presentParams->SwapEffect = Microsoft::DirectX::Direct3D::SwapEffect::Discard;
_presentParams->EnableAutoDepthStencil = false;
_presentParams->BackBufferCount = 1;
_presentParams->BackBufferWidth = this->panel1->Width;
_presentParams->BackBufferHeight = this->panel1->Height;
array<Microsoft::DirectX::Direct3D::PresentParameters^,1>^ _pp = gcnew array<Microsoft::DirectX::Direct3D::PresentParameters^>(1);
_pp[0] = _presentParams;
/* _pp[0]->Windowed = true;
_pp[0]->SwapEffect = Microsoft::DirectX::Direct3D::SwapEffect::Discard;
_pp[0]->EnableAutoDepthStencil = false;
_pp[0]->BackBufferCount = 1;
_pp[0]->BackBufferWidth = this->panel1->Width;
_pp[0]->BackBufferHeight = this->panel1->Height; */
_dev = 
gcnew Microsoft::DirectX::Direct3D::Device( 0, 
Control::FromHandle( this->panel1->Handle ),
                                                _presentParams );
_dev->SetRenderState( Microsoft::DirectX::Direct3D::RenderStates::Lighting, false );
    _vb = 
gcnew VertexBuffer( CustomVertex::PositionColored::typeid,//; //PositionColored::typeid,
    Pool::Managed );
array<CustomVertex::PositionColored>^ v =
 gcnew array<CustomVertex::PositionColored>(8);
  for ( int n = 0; n < 8; n++ ) {
    v[n].Position = Vector3( (float)(n&4), (float)(n&2), (float)(n&1));
v[n].Color = RGB(0xff*((n>>2)&1), 0xff*((n>>1)&1), 0xff*(n&1)); // #define RGB(r,g,b) (((r)<<16) | ((g)<<8) | (b))
GraphicsStream^ gs = _vb->Lock(0, 0, (LockFlags)0);
  ib = gcnew IndexBuffer(Int16::typeid, 36, _dev, (Usage)0, Pool::Managed);
  array<Int16>^ data = {
    0,4,2,6,2,4, // yz:
    7,5,3,1,3,5, // yz:
    0,2,1,3,1,2, // xy:
    7,6,5,4,5,6, // xy:
    0,1,4,5,4,1, // zx:
    7,3,6,2,6,3, // zx:
  ib->SetData(data, 0, (LockFlags)0);
FontDescription fd;
  fd.Height = 20;
  fd.FaceName = "Arial";
font = gcnew Direct3D::Font(_dev, fd);
   Int32 counter = 0;
while ( this->IsDisposed == false ) {
    _dev->Transform->World = Matrix::RotationY( Environment::TickCount / 3000.0f) *
                            Matrix::RotationX( Environment::TickCount / 4000.0f);
_dev->RenderState->CullMode = Cull::Clockwise; // None;
     _dev->Transform->View = Matrix::LookAtLH( Vector3(8.0f, 8.0f, 8.0f),
                                              Vector3(0.0f, 0.0f, 0.0f),
                                              Vector3(0.0f, 1.0f, 0.0f));
     _dev->Transform->Projection = Matrix::PerspectiveFovLH((float)Math::PI / 4,
                                  (float)ClientSize.Width / ClientSize.Height, 3.0f, 15.0f);
     _dev->RenderState->Lighting = false;
 _dev->Clear( ClearFlags::Target, System::Drawing::Color::Red, 1.0f, 0 );
      _dev->SetStreamSource(0, _vb, 0);
   _dev->Indices = ib;
_dev->VertexFormat = CustomVertex::PositionColored::Format;
_dev->DrawIndexedPrimitives(PrimitiveType::TriangleList, 0, 0, 8, 0, 12);
font->DrawText( nullptr, "HELLO  " + counter.ToString(), 20, 20, Color::White);
//Microsoft::DirectX::Direct3D::Surface^ _surface = gcnew Microsoft::DirectX::Direct3D::Surface( _dev,BITMAP, pool ); 
//Microsoft::DirectX::Direct3D::Surface::^ _backbuffer = _dev->GetBackBuffer( 0, 0, Microsoft::DirectX::Direct3D::BackBufferType::Mono ); 
    // acquire access to the back buffer
    Surface^ backbuffer;
backbuffer = _dev->GetBackBuffer( 0, 0, Microsoft::DirectX::Direct3D::BackBufferType::Mono );
System::Drawing::Graphics^ graphics;
graphics = backbuffer->GetGraphics();
    // draw a rectangle using GDI+
    graphics->DrawRectangle(Pens::Beige, 10, 20, 50, 60);
      // release
   catch (DeviceLostException^) 
      Int32 hResult = 0;
     if (!_dev->CheckCooperativeLevel(hResult)) {
       switch (hResult) {
         case ResultCode::DeviceLost:
         case ResultCode::DeviceNotReset:
          _dev->Reset( _presentParams );
       }// switch
}// if
   }// try catch 
//TODO: Add the constructor code here
/// <summary>
/// Clean up any resources being used.
/// </summary>
if (components)
delete components;
private: System::Windows::Forms::Panel^  panel1;
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
this->panel1 = (gcnew System::Windows::Forms::Panel());
// panel1
this->panel1->Location = System::Drawing::Point(0, 0);
this->panel1->Name = L"panel1";
this->panel1->Size = System::Drawing::Size(456, 396);
this->panel1->TabIndex = 0;
// Form1
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(478, 396);
this->Name = L"Form1";
this->Text = L"Form1";
#pragma endregion

Share this post

Link to post
Share on other sites

Of course several DLL need to be added







from Win XP, so called managed DirectX


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
Followers 0