Jump to content
  • Advertisement

fear4ever

Member
  • Content Count

    31
  • Joined

  • Last visited

Community Reputation

135 Neutral

About fear4ever

  • Rank
    Member
  1. fear4ever

    My first C++ game

    I think you should start with c# or java and use the built in graphics API as they are pretty straight forward and require little effort to learn. You'll use eclipse/visual studio to write the code and intellisense will remember function names for you so you wont have to bother with 1- Graphics APIs/Frameworks 2- Function details/graphics pipelines 3- Windowing/keyboard-mouse input routines. You can easily focus on actual game development/algorithms/geometry calculations. By the time you create a game like snake that actually works you'll have learned a great deal about essentials of game programming. Then you can move to more professional stuff like OpenGL/DirectX
  2. Hello, As far as I can see glPolygonStipple isnt applied when glDrawPixels is called. Is there a way to make this work?
  3. Quote:Original post by fear4ever That overlay can be drawn by the c# application itself or maybe by some other dll. It doesn't really matter whether it gdi+ or anything else that does the drawing. What i am trying to find is the method of double buffered drawing onto a c# form (flicker free). As i understand OpenGL and gdi+ use different buffers for drawing so something like is not possible? in each timer tick clear_area() oglDLL.draw() //dont swap buffers yet some_other_dll.draw() //dont swap buffers yet gdi+.draw() //dont swap buffers yet swap_buffers() Any explanation or pointers to that kind of drawing tecnique would be appriciated.
  4. Hi I am trying to create a c++ dll which draws some stuff to a c# form (hWd passed as a parameter to the dll). It works fine up to that point. I put a timer to the c# application and it calls the dll's draw method on each tick. What I am trying to add now is an overlay on top of what is drawn by the c++ part. That overlay can be drawn by the c# application itself or maybe by some other dll. Is that possible? And if so how do i go about it? Something like void tick() { openGL_Part.draw(); draw_Some_Stuff_On_Top_Of_That(); }
  5. fear4ever

    c++ bitmap to bmp

    I have played a bit around with the code. First off the HBITMAP i created was not getting the info from CBitmap bmp; so i decided to get pixel directly from it. and changed 24 color depth to 32 which is my desktop resolution. At last i got some output but half the picture is still in black. What could be the reason? // CDenemeView drawing void CDenemeView::OnDraw(CDC* pDC) { CDenemeDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // TODO: add draw code for native data here // bitmap dimensions RECT windowRect; GetWindowRect(&windowRect); int bitmap_dx = windowRect.right - windowRect.left; int bitmap_dy = windowRect.bottom - windowRect.top; CPaintDC odc(this); CBitmap bmp; CDC dc; dc.CreateCompatibleDC(&odc); bmp.CreateCompatibleBitmap( &odc, bitmap_dx, bitmap_dy ); dc.SelectObject(&bmp); //fill the area for ( int x = 0; x < bitmap_dy; x ++ ) { for ( int y = 0; y < bitmap_dx; y ++ ) { dc.SetPixel(x,y, RGB(x%256,y%256,(x+y)%256)); } } // create file ofstream file("example.bmp", ios::binary); if(!file) return; // save bitmap file headers BITMAPFILEHEADER fileHeader; BITMAPINFOHEADER infoHeader; fileHeader.bfType = 0x4d42; fileHeader.bfSize = 0; fileHeader.bfReserved1 = 0; fileHeader.bfReserved2 = 0; fileHeader.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER); infoHeader.biSize = sizeof(infoHeader); infoHeader.biWidth = bitmap_dx; infoHeader.biHeight = bitmap_dy; infoHeader.biPlanes = 1; infoHeader.biBitCount = 32; infoHeader.biCompression = BI_RGB; infoHeader.biSizeImage = 0; infoHeader.biXPelsPerMeter = 0; infoHeader.biYPelsPerMeter = 0; infoHeader.biClrUsed = 0; infoHeader.biClrImportant = 0; file.write((char*)&fileHeader, sizeof(fileHeader)); file.write((char*)&infoHeader, sizeof(infoHeader)); // save dibsection data int bytes = (((32*bitmap_dx + 31) & (~31))/8)*bitmap_dy; char *memory2= (char*)malloc(sizeof(char)*bytes); bmp.GetBitmapBits(bytes,memory2); file.write((char*)memory2, bytes); DeleteObject(bmp); DeleteDC(dc); DeleteDC(odc); file.close(); }
  6. fear4ever

    c++ bitmap to bmp

    Hello. I am having a problem creating and saving an image as bmp in a MFC application. Project is created by VS6 from mfc appication wizard(exe) with standard options. This is the source of the onDraw method. This creates a bitmap and draws to screen. Also creates a bmp file of application size but its just black. What am i doing wrong? // CDenemeView drawing void CDenemeView::OnDraw(CDC* pDC) { CDenemeDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // TODO: add draw code for native data here // bitmap dimensions RECT windowRect; GetWindowRect(&windowRect); int bitmap_dx = windowRect.right - windowRect.left; int bitmap_dy = windowRect.bottom - windowRect.top; CPaintDC odc(this); CBitmap bmp; CDC dc; dc.CreateCompatibleDC(&odc); bmp.CreateCompatibleBitmap( &odc, bitmap_dx, bitmap_dy ); dc.SelectObject(&bmp); //fill the area for ( int x = 0; x < bitmap_dy; x ++ ) { for ( int y = 0; y < bitmap_dx; y ++ ) { dc.SetPixel(x,y, RGB(x%256,y%256,(x*y)%256)); } } // create file ofstream file("example.bmp", ios::binary); if(!file) return; // save bitmap file headers BITMAPFILEHEADER fileHeader; BITMAPINFOHEADER infoHeader; fileHeader.bfType = 0x4d42; fileHeader.bfSize = 0; fileHeader.bfReserved1 = 0; fileHeader.bfReserved2 = 0; fileHeader.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER); infoHeader.biSize = sizeof(infoHeader); infoHeader.biWidth = bitmap_dx; infoHeader.biHeight = bitmap_dy; infoHeader.biPlanes = 1; infoHeader.biBitCount = 24; infoHeader.biCompression = BI_RGB; infoHeader.biSizeImage = 0; infoHeader.biXPelsPerMeter = 0; infoHeader.biYPelsPerMeter = 0; infoHeader.biClrUsed = 0; infoHeader.biClrImportant = 0; file.write((char*)&fileHeader, sizeof(fileHeader)); file.write((char*)&infoHeader, sizeof(infoHeader)); // dibsection information BITMAPINFO info; info.bmiHeader = infoHeader; //for checking if dc has correct drawing pDC->BitBlt( 0,0,bitmap_dx, bitmap_dy, &dc,0,0,SRCCOPY); BYTE *memory; SelectObject(dc, bmp); HBITMAP bitmap = CreateDIBSection(dc, &info, DIB_RGB_COLORS, (void**)&memory, 0, 0); // save dibsection data int bytes = (((24*bitmap_dx + 31) & (~31))/8)*bitmap_dy; file.write((char*)memory, bytes); DeleteObject(bmp); DeleteDC(dc); DeleteDC(odc); file.close(); }
  7. fear4ever

    Visual Basic And OpenGL

    Yes you are right. Basically i wanted to develop a GUI based opengl application. Nehe's window system works just fine but controlling everything with keyboard is not possible when you want to create an actual application. SDL is not any different as far as i can see. Anyway i did manage to integrate opengl/vb/c++. After a bit of a work i'll hopefully have a simple framework where vb controls user input and c++ handles application logic and opengl. Thanks for the replies.
  8. fear4ever

    Visual Basic And OpenGL

    Thanks edgar. I did manage to make it work by creating a simple atl com object and linking to vb. This brings some problems with it of course i.e i have to prevent vb from drawing over opengl stuff by running it in a closed loop. Still it works and will save me some time while designing a GUI. Hopefully i'll have a generic framework for future use. I also looked into SDL a bit. It seems quite nice but is there a form editor type tool for creating GUI's based on it?
  9. Hi, I am trying to create a simple windows opengl application. For GUI i decided to use visual basic. I know people can code opengl in vb using a tlb file which i cannot remember the exact name for but that's not i am after. I am looking for a way to implement only GUI in VB and all application code in visual c++. That means i'll have a dll that initiliazes opengl using the window handle of vb, vb will pass GUI events to that/or another dll responsible for application impelemtatioin. Is that possible? I tried to create a simple win32 dll with VS/c++ and reference it in a VB app but that doesnt seem to work. Do i have to create an mfc activeX control instead of a regular dll? (That i tried and managed to link the ocx file to vb but is creating a control best way to do this?) I am also open for suggestions about the platform to implement the GUI (MFC is a bit too complicated and glut/glui do not have a good application feel). Thanks in advance.
  10. fear4ever

    Vector rotation

    This is not a homework. I am trying to build a pipe around a curve, the normals at curve points need to match so i can create circles around it and connect them with triangle strips. BeanDog, your methods seems like it will work. I am not very good with linear algebra, so i'll try to implement this and let you know. Thanks for replies
  11. fear4ever

    Vector rotation

    Hi, I have 2 vectors. a=[x1,y1,y1] b=[x2,y2,z2] Now somehow the vector a is rotated to a'=[x1',y1',z1'] a' is given without the rotation matrix that produced it. What i need is to rotate the vector b the same way vector a has been rotated to obtain b'=[x2',y2',z2']. Any (if possible easy) way to do this? Thanks
  12. fear4ever

    3D Pipe

    Thanks a lot. I just cannot see such typos especially it is me who made them :( This works fine now.
  13. fear4ever

    Spotlight not working

    This page shows how to set up lights. Specifiying spotlight properties. Hope it helps
  14. fear4ever

    3D Pipe

    I have written a simple program to implement this. Here is a link to MSVS 6 workspace (10kb) Source I am using a bezier curve. You can play with resetControl() function to specify diffrent control points and get diffrent curves. The pipe is generated with some weird looking parts especially at curving regions. I could not figure out if this is due to the 3D structure of it or not. (I think something is definetely wrong though). If you have time to download and have a look at it please check the "circlesFromCurve" function and let me know if there is any problem there. For those who dont have time to download the source, this is the function. double PI = acos(-1); const float DEG2RAD=PI/180; typedef struct { double x; double y; double z; }Point3D; typedef struct { Point3D* points; int n; }Circle; /*This func generates a circle for each point on curve *cn is numner of curve points that i will generate circles for *res is resolution of circles(number of points per circle) */ Circle* circlesFromCurve(Point3D* curvePoints,int cn, int res, double radius) { Circle* circles=(Circle*)malloc(sizeof(Circle)*cn); Point3D pRandom; pRandom.x=1; pRandom.y=1; pRandom.z=1; for(int i=0;i<cn-1;i++) { Point3D pDirection; Point3D axis1,axis2; pDirection.x=curvePoints[i+1].x-curvePoints.x; pDirection.y=curvePoints[i+1].y-curvePoints.y; pDirection.z=curvePoints[i+1].z-curvePoints.z; axis1.x=pDirection.y*pRandom.z - pDirection.z*pRandom.y; axis1.y=pDirection.z*pRandom.x - pDirection.x*pRandom.z; axis1.z=pDirection.x-pRandom.y - pDirection.y*pRandom.x; axis2.x=axis1.y*pDirection.z - axis1.z*pDirection.y; axis2.y=axis1.z*pDirection.x - axis1.x*pDirection.z; axis2.z=axis1.x-pDirection.y - axis1.y*pDirection.x; double l=axis1.x*axis1.x+axis1.y*axis1.y+axis1.z*axis1.z; axis1.x=axis1.x/sqrt(l); axis1.y=axis1.y/sqrt(l); axis1.z=axis1.z/sqrt(l); l=axis2.x*axis1.x+axis2.y*axis2.y+axis2.z*axis2.z; axis2.x=axis2.x/sqrt(l); axis2.y=axis2.y/sqrt(l); axis2.z=axis2.z/sqrt(l); circles.n=res; circles.points=(Point3D*)malloc(sizeof(Point3D)*res); double step=360/res; for(int j=0;j<res;j++) { double degree=j*step*DEG2RAD; double vcos=sin(degree)*radius; double vsin=cos(degree)*radius; circles.points[j].x=curvePoints.x+axis1.x*vcos+axis2.x*vsin; circles.points[j].y=curvePoints.y+axis1.y*vcos+axis2.y*vsin; circles.points[j].z=curvePoints.z+axis1.z*vcos+axis2.z*vsin; } pRandom.x=pDirection.x; pRandom.y=pDirection.y; pRandom.z=pDirection.z; } return circles; }
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!