Jump to content

  • Log In with Google      Sign In   
  • Create Account

VitaliBR

Member Since 22 Apr 2010
Offline Last Active Aug 24 2012 08:48 PM

Topics I've Started

Picking

21 August 2012 - 04:34 AM

Do you recommend I use this method?
http://content.gpwiki.org/index.php/OpenGL:Tutorials:Picking

I'm asking this, because I used it in my project and I have a problem.


My cube in the scene has ID 1:
Posted Image

The red square on top of the cube was made by me in photoshop. It is to show the area where I click and returns the selected cube.
That is, the edges of the cube is shown by the function list_hits not selected anything, but I clicked on the edge of the cube!

Moving from Direct3D to OpenGL

16 August 2012 - 08:33 AM

Hi! :)

I'm learning OpenGL, (always programmed to direct3d).
I chose the Direct3D rendering options this way:

_d3d = Direct3DCreate9(D3D_SDK_VERSION);
bool p_bMultiSample = true;
bool p_bSuperSample = true;
bool bHW = true;
D3DDEVTYPE eType = bHW ? D3DDEVTYPE_HAL : D3DDEVTYPE_REF;
// get the current display mode
D3DDISPLAYMODE sMode;
_d3d->GetAdapterDisplayMode(0,&sMode);
    D3DPRESENT_PARAMETERS d3dpp;
RECT rect;
GetClientRect( hwnd , &rect );
    ZeroMemory(&d3dpp, sizeof(d3dpp));
    d3dpp.Windowed = !fullscreen;
    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
    d3dpp.hDeviceWindow = hwnd;
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
    d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
    d3dpp.BackBufferWidth = rect.right - rect.left; //screenWidth;
    d3dpp.BackBufferHeight = rect.bottom - rect.top; //screenHeight;
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.BackBufferCount = 1;
// check whether we can use a D32 depth buffer format
if ( SUCCEEDED ( _d3d->CheckDepthStencilMatch(0,eType,
  D3DFMT_X8R8G8B8,D3DFMT_X8R8G8B8,D3DFMT_D32)))
{
  d3dpp.AutoDepthStencilFormat = D3DFMT_D32;
}
else
{
  d3dpp.AutoDepthStencilFormat = D3DFMT_D24X8;
}
// find the highest multisample type available on this device
D3DMULTISAMPLE_TYPE sMS = D3DMULTISAMPLE_2_SAMPLES;
D3DMULTISAMPLE_TYPE sMSOut = D3DMULTISAMPLE_NONE;
DWORD dwQuality = 0;
if (p_bMultiSample)
{
  while ((D3DMULTISAMPLE_TYPE)(D3DMULTISAMPLE_16_SAMPLES + 1)  !=
   (sMS = (D3DMULTISAMPLE_TYPE)(sMS + 1)))
  {
   if(SUCCEEDED( _d3d->CheckDeviceMultiSampleType(0,eType,
    sMode.Format,TRUE,sMS,&dwQuality)))
   {
    sMSOut = sMS;
   }
  }
  if (0 != dwQuality)dwQuality -= 1;

  d3dpp.MultiSampleQuality = dwQuality;
  d3dpp.MultiSampleType = sMSOut;
}
// preget the device capabilities. If the hardware vertex shader is too old, we prefer software vertex processing
D3DCAPS9 g_sCaps;
_d3d->GetDeviceCaps( 0, eType, &g_sCaps);
DWORD creationFlags = D3DCREATE_MULTITHREADED;
if( g_sCaps.VertexShaderVersion >= D3DVS_VERSION( 2, 0))
  creationFlags |= D3DCREATE_HARDWARE_VERTEXPROCESSING;
else
  creationFlags |= D3DCREATE_SOFTWARE_VERTEXPROCESSING;
////////////////////////////////////////////////////////////////////////////////////
    // create a device class using this information and the info from the d3dpp stuct
////////////////////////////////////////////////////////////////////////////////
    _d3d->CreateDevice(D3DADAPTER_DEFAULT,
					  eType,
					  hwnd,
					  creationFlags,
					  &d3dpp,
					  &_d3ddev);

In OpenGL I only got this far:
#ifndef GL_MULTISAMPLE
#define GL_MULTISAMPLE  0x809D
#endif

// Initialize OpenGL
void VS_Core::initGL()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glClearColor (backR,backG,backB, 0.0);
    glEnable(GL_CULL_FACE);
    glEnable(GL_MULTISAMPLE);
    //QMessageBox::about( this, tr("OpenGL Version"), tr((char*)glGetString(GL_VERSION)));
    qDebug((char*)glGetString(GL_VERSION));
    qDebug((char*)glGetString(GL_RENDERER));
    /*
	    GLint bufs;
	    GLint samples;
	    glGetIntegerv(GL_SAMPLE_BUFFERS, &bufs);
	    glGetIntegerv(GL_SAMPLES, &samples);
	    qDebug("Have %d buffers and %d samples", bufs, samples);
    */
    glEnable(GL_DEPTH_TEST);
    glShadeModel(GL_SMOOTH);
    glEnable(GL_COLOR_MATERIAL);
    glDisable(GL_CULL_FACE);
    glEnable(GL_TEXTURE_2D);
}

Game Editor

14 August 2012 - 10:16 AM

I wonder how Unity works in relation to select the "Sphere" and hit her in the scene and create a sphere, where it adds this "class" sphere to a list of objects in the scene? (I believe that the sphere inherits from a class "Object" for example)
and another question is, how the "play" it? after I add a floor and a sphere in the scene, I would like to give to build a play or he manages the game itself and not the "scene editable" which is seen in the Engine Editor.

Do not know if I was very clear, I wrapped myself up to try to mount the doubt

Sorry my poor English :(

GUI with OpenGL/Qt

09 August 2012 - 01:47 PM

Hi,

I'm a programmer and I want DirectX start a simple OpenGL and Qt (for control and window creation and its easy portability) :)

I wonder how he could make a GUI system like this video (combobox, checklist, checkbox, textbox, etc ...)


I used once to CEGUI, but I thought the look of it very ugly and very laborious to implement the project, wanted something simple, clean and beautiful as the video above

I came to develop 2D using OpenGL and SDL, and the options screen gave me a lot of work and many hours, I would use something ready to help me save time:


Thanks :)

Multiples Point Light

08 August 2012 - 09:18 PM

Hi!

I anticipate that I already have trouble with shaders :(

I would create several "point light" using HLSL, where I can create a PointLight in a class.For exemple:
PointLight* light1;
PointLight* light3;
PointLight* light2;
//....

light1 = new PointLight();
light2 = new PointLight();
light3 = new PointLight();
//....

I found this demo, but the 8 lights are created within the. Fx, how do I create a light class in the code?

http://www.dhpoware.com/demos/d3d9MultiplePointLights.html


Thanks :)

PARTNERS