any real point to vertex(vertices)

Started by
12 comments, last by Rydis 20 years, 8 months ago
is there really any point do make a matrix that draws polygons with your hand made vertices when you have bitmaps to do all the graphics for you. im reading this book and they gone on and on about vertices and showing some really stupid examples i dont get and just leaving you with matrixes of about 50 diff numberes that when renderd dont show anything...really whats the point of em.
Advertisement
I''m going to assume you''re trying to learn 2D graphics, and you''re reading a book that teaches DirectX 8.0.

DirectX 8.0 is much different in the way you have probably programmed before. You want the simplicity of blitting to the screen. This isn''t the case in DX 8.0, DirectDraw was discontinued, so you have to use Direct3D for graphics. In DX 8.0, you have to draw polygons in 3D space, which are made of verticies. Then you can put your bitmaps on the polygons. Matricies are there to move objects around, but that''s such a poor explaination of their full capabilities, so I''ll just let someone else explain them.
---Will DDR for food.
Ya its Programming RPGs with DirectX 8 and on chapter that explains vertiexes and stuff and i just cant figure it all out.
Heh, you''re reading the same book as I am. I suggest printing out the source code from the CD. Preferably the Draw3D demo in chapter 6.
Look through the source code as you read through the book to follow along and understand what he is talking about more clearly. The more you interact with code, the more you''ll understand. Check the SDK Documentation too if you don''t completely understand what a function does.
Also, there are some things in the source code that are not mentioned in the book, and it could screw you over big time. One thing the author forgot to mention was to set the render state to D3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE) right after you create your vertex buffer. I was confused for days when it wouldn''t draw anything.

Other than that, just remember that all your drawing is in 3D space. Verticies are the corners to the polygons, and you need to use them to define a polygon. It''s a little harder than working in 2D space.
---Will DDR for food.
If you want to do 2D without messing with vertices, use ID3DXSprite. You simply load a texture and call the Draw method of the interface. and voila!
y know what functions do ;P mind you. just i dont get vertex stuff all together really...cant figure out how to combine them at certain points in a space..i got the code and just played around mesing with the vertex in the sVertex matrix object he created and i couldn''t get anything to be drawn besides what he already had.
quote:Original post by FlamePixel
If you want to do 2D without messing with vertices, use ID3DXSprite. You simply load a texture and call the Draw method of the interface. and voila!


No No No NOOOOO Not ID3DXSprite!!!

.lick
ddin''t feel like creating a new topic can anyone tell me why this comes up all black

#include <windows.h>									#include <stdio.h>#include <d3d8.h>	#include <d3dx8.h>										//Globalchar *g_WindowClass = "Game";char *g_WindowName = "Game";HWND g_hWnd;//graphic-based globelsIDirect3D8 *g_d3d; //globel for device checking and settingIDirect3DDevice8 *g_d3dd; //device for the vertex drawing//vertex matrixstruct sVertex{	int PosX, PosY, PosZ, RHW; //x, y, z cordinates	D3DCOLOR Diffuse; //diffuse color of pixel	float TextureU, TextureV; //texture mappin cordinates};//FVF Format#define VertexFVF (D3DFVF_XYZRHW | D3DFVF_DIFFUSE)// Vertex bufferIDirect3DVertexBuffer8 *g_d3dvb;// TextureIDirect3DTexture8 *g_d3dt;//Main PrototypesHWND CreateNewWindow(HINSTANCE, char *, char *, int, int);bool RegisterWindow(HINSTANCE, char *);bool UnRegisterWindow(HINSTANCE, char *);bool Init();bool PreFrame();bool PerFrame();bool PostFrame();int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance,                    PSTR szCmdLine, int iCmdShow)			{    MSG msg;		//Regeister New Window	RegisterWindow(hInst, g_WindowClass);	CreateNewWindow(hInst, g_WindowClass, g_WindowName, 800, 600);	if(Init() == false)		MessageBox(g_hWnd, "test", "test", MB_OK);	if(PerFrame() == false)		MessageBox(g_hWnd, "test", "test", MB_OK);	while(msg.message != WM_QUIT)	if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))	    {															TranslateMessage (&msg);						DispatchMessage (&msg);					}		UnRegisterWindow(hInst, g_WindowClass);	return msg.wParam;					 }LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam){    switch (iMsg)							    {	case WM_DESTROY:		PostQuitMessage(0);						break;										}														return DefWindowProc (hwnd, iMsg, wParam, lParam);}//Create a New WidnowHWND CreateNewWindow(HINSTANCE hInst,char *WindowClass, char *WindowClassName, int WindowWidth, int WindowHeight){	HWND hWnd;	 hWnd = CreateWindow (WindowClass, WindowClassName, WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,							 CW_USEDEFAULT, WindowWidth, WindowHeight, NULL, NULL, hInst, NULL);	 	ShowWindow(hWnd, SW_NORMAL);					    UpdateWindow(hWnd);		g_hWnd = hWnd;	return hWnd;}//Register New Windowbool RegisterWindow(HINSTANCE hInst, char *WindowClass){	WNDCLASSEX  wndclass;    wndclass.cbSize        = sizeof (wndclass);	    wndclass.style         = CS_HREDRAW | CS_VREDRAW;	    wndclass.lpfnWndProc   = WndProc;	    wndclass.cbClsExtra    = 0;						    wndclass.cbWndExtra    = 0;					    wndclass.hInstance     = hInst;			    wndclass.hIcon         = LoadIcon (NULL, IDI_WINLOGO);    wndclass.hCursor       = LoadCursor (NULL, IDC_ARROW);										    wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);    wndclass.lpszMenuName  = NULL;					    wndclass.lpszClassName = WindowClass;				    wndclass.hIconSm       = LoadIcon (NULL, IDI_WINLOGO);		RegisterClassEx (&wndclass);			return true;}//UnRegesterWindowbool UnRegisterWindow(HINSTANCE hInst, char *WindowClass){	UnregisterClass(WindowClass,hInst);	return true;}bool Init(){  D3DPRESENT_PARAMETERS d3dpp; //display parameters  D3DDISPLAYMODE        d3ddm; //display mode  byte *VertexPtr; //vertex pointer  sVertex Verts[4] =   {	  {10, 10, 1, 1, D3DCOLOR_RGBA(15, 0, 210, 255) },	  {20, 10, 1, 1, D3DCOLOR_RGBA(15, 0, 210, 255)},	  {10, 20, 1, 1, D3DCOLOR_RGBA(15, 0, 210, 255)},	  {20, 20, 1, 1, D3DCOLOR_RGBA(15, 0, 210, 255)}  };  //window intinalization  //creates a object taht allows creation of other objects  if((g_d3d = Direct3DCreate8(D3D_SDK_VERSION)) == NULL)    return false;  //gets Display Mode  if(FAILED(g_d3d->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm)))    return false;  //clears the present parameters  ZeroMemory(&d3dpp, sizeof(d3dpp));  //set the present parameters  d3dpp.Windowed = true; //tellss compiler its windowed  d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; //what do so with enpty buffer  d3dpp.BackBufferFormat = d3ddm.Format; //format of backbuffer  d3dpp.EnableAutoDepthStencil = false;  //create display Device  if(FAILED(g_d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, g_hWnd,                                  D3DCREATE_SOFTWARE_VERTEXPROCESSING,                                  &d3dpp, &g_d3dd)))	return false;  // Create the vertex buffer and set data  g_d3dd->CreateVertexBuffer(sizeof(sVertex)*4, 0,                          VertexFVF, D3DPOOL_DEFAULT, &g_d3dvb);  g_d3dvb->Lock(0,0, (BYTE**)&VertexPtr, 0); //locks vertex ptr  memcpy(VertexPtr, Verts, sizeof(Verts)); //copys it  g_d3dvb->Unlock(); //then releases  // Load the texture map  D3DXCreateTextureFromFile(g_d3dd, "Texture.bmp", &g_d3dt);  return true;}bool PerFrame(){	// Clear device backbuffer  g_d3dd->Clear(0, NULL, D3DCLEAR_TARGET,                                       D3DCOLOR_RGBA(255,255,150,255), 1.0f, 0);  // Begin scene  if(SUCCEEDED(g_d3dd->BeginScene()))   {    // Set the vertex stream, shader, and texture    g_d3dd->SetStreamSource(0, g_d3dvb, sizeof(sVertex));    g_d3dd->SetVertexShader(VertexFVF);    g_d3dd->SetTexture(0, g_d3dt);    // Draw the vertex buffer    g_d3dd->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);    // Release texture    g_d3dd->SetTexture(0, NULL);    // End the scene    g_d3dd->EndScene();  }  // Display the scene  g_d3dd->Present(NULL, NULL, NULL, NULL);  return true;}


yes the texture name is right if anyone tries to ask
You''re not describing the vertices correctly:

#define Vertex_FVF (D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1)
nothing changes it still dont display it...it dont even display the square i drew at all

This topic is closed to new replies.

Advertisement