krywen

Members
  • Content count

    3
  • Joined

  • Last visited

Community Reputation

117 Neutral

About krywen

  • Rank
    Newbie
  1. Let's have a look at D3D11, HW supported formats for depth stencil are DXGI_FORMAT_D32_FLOAT_S8X24_UINT DXGI_FORMAT_D32_FLOAT DXGI_FORMAT_D24_UNORM_S8_UINT DXGI_FORMAT_D16_UNORM - From my undesrtanding these are the only format allowed for resources to be selected in a depth-stencil view, NOT the format allowed in the depth-stencil view, those are listed here https://msdn.microsoft.com/en-us/library/windows/desktop/ff476112%28v=vs.85%29.aspx. Is this correct?   - Still I can't find is it is legal to use in the view a format with different size from the selected resource. E.g. is it legal to use DXGI_FORMAT_D16_UNORM as a format in a D3D11_DEPTH_STENCIL_VIEW_DESC structure when the selected subresource has format DXGI_FORMAT_D32_FLOAT_S8X24_UINT? I only suppose is not legal but cannot find a proper specification for this.   [Edit - Clarification]
  2. When creating a DepthStencilView I'm able to pass a D3D11_DEPTH_STENCIL_VIEW_DESC as an argument, specifying a format from a list. I'd like to know which format are allowed, respect to the Resouce format. I.e. Can I use a DXGI_FORMAT which is smaller then the selected resource format? Can I create a DEPTH_STENCIL_VIEW with format DXGI_FORMAT_D16_UNORM is the selected resource format is DXGI_FORMAT_R32? Does it have other limitations, like a Depth stencil view cannot be created when the subresource has a some DXGI formats?   I am not albe to find a specification for this. Moreover the same question apply when creating a RenderTargetView.   Thanks in advance
  3. Here is an example program of cylindrical texture mapping. I was unable to find it on the web, so I've made my one. OpenGL does not generate cylindrical mapping automatically; you can create spherical mapping with [source lang="cpp"] glTexGend(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); [/source] but not cylindrical, so we must do it by hand, coupling each vertex with corrisponding texture coordinate, using [source lang="cpp"]glTexCoord2d(s, t); glVertex3d( x, y, z );[/source] First think about parametrical rappresentation of a cylinder: cylinder(u, v): x = r * cos(u * 2*pi) y = r * sin(u * 2*pi) z = v in our case u and v are the texture coordinates u=s v=t so the idea is to iterate on texture coordinates, and generating corresponding vertices. Suppose we want the cylinder to have 360 side faces; then we select 360 point in the texture (u coordinate) and calculate corresponding (x,y,z) vertex coordinate. Coordinate v will be only 0.0 or 1.0; In our reference system, Y is the height, so we modify formulas: cylinder(u, v): x = r * cos(u * 2*pi) z = r * sin(u * 2*pi) y = v We use a GL_QUAD_STRIP fot the cylinder side. Here we generate a cylinder with the height parallel at Y axis. [CODE] /* radius */ double r=5.0; double height=4.0; /* number of side faces */ int faces=360; /* Choose neutral color (white)*/ glColor3d(1,1,1); /* Enable 2D Texture*/ glEnable(GL_TEXTURE_2D); /* set current working texture */ glBindTexture(GL_TEXTURE_2D, texture[0]); /* Disabling these is not necessary in this example, * BUT if you have previously enabled GL_TEXTURE_GEN_ * for other textures,then you need these lines */ glDisable(GL_TEXTURE_GEN_S); glDisable(GL_TEXTURE_GEN_T); glBegin(GL_QUAD_STRIP); double x, y, z; y=height; for (int i =0; i <= faces; i++) { double u = i/ (double) faces; x = r*cos(2*M_PI*u); z = r*sin(2*M_PI*u); /* Bottom vertex*/ glTexCoord2d(u, 1.0); glVertex3d( x, 0, z ); /* Top vertex*/ glTexCoord2d(u, 0.0); glVertex3d( x, y, z ); } glEnd(); [/CODE] [unverified] Issue: I have loaded images with SDL, but if you loaded the image with OpenGL probably you will have to modify code in this way: [CODE] glTexCoord2d(u, 0.0); glVertex3d( x, 0, z ); /* Top vertex*/ glTexCoord2d(u, 1.0); glVertex3d( x, y, z ); } glEnd(); [/CODE] Attachment is a working code using OpenGL, glut, and SDL. The attached code alse let you rotate the view with mouse to verify the result. I really hope my hours spent to create this example will be usefull to someone. --- [b]Update 21 August 2012[/b] [b]- Face Orientation[/b] The code above will create cylinder with faces where the front is toward the center of cylinder (this because the OpenGL default is glFrontFace(CCW)= faces have front orientation where its vertex are declared in counterclockwise order ). Keep an eye on this especially if you are using back face culling [CODE]glEnable(GL_CULL_FACE); glCullFace(GL_BACK);[/CODE] If you want your cylinder to have front face towards the extern, just reorder the vertexes declaration in this way: [CODE]glBegin(GL_QUAD_STRIP); double x, y, z; y=height; for (int i =0; i <= faces; i++) { double u = i/ (double) faces; x = r*cos(2*M_PI*u); z = r*sin(2*M_PI*u); /* Top vertex*/ glTexCoord2d(u, 0.0); glVertex3d( x, y, z ); /* Bottom vertex*/ glTexCoord2d(u, 1.0); glVertex3d( x, 0, z ); }[/CODE] or, instead of doing thath, you can put glFrontFace(GL_CW); before glBegin [CODE] glFrontFace(GL_CW); glBegin(GL_QUAD_STRIP); double x, y, z; y=height; for (int i =0; i <= faces; i++) { double u = i/ (double) faces; x = r*cos(2*M_PI*u); z = r*sin(2*M_PI*u); /* Bottom vertex*/ glTexCoord2d(u, 1.0); glVertex3d( x, 0, z ); /* Top vertex*/ glTexCoord2d(u, 0.0); glVertex3d( x, y, z ); }[/CODE] this second method have an issue: from now every polygon you will draw will have front face if vertex are declared CounterClockWise, which is not OpenGL default.