Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
M

Member 3375334

@Member 3375334
About
Posts
20
Topics
12
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • inverse mapping
    M Member 3375334

    Hello, i managed to rotate a rectangle 45 degrees. Now i have an picture that i need to map to this reversed rectangle. I heard there is an inverse mapping way. Something about u and v. I am not familiar with it. Can someone tell me how to use this? thanks

    C / C++ / MFC

  • glDrawPixels help
    M Member 3375334

    hello, i am using it because i was told to use it. I can't use OpenGL for rotation so somehow i need to apply the pixels from glDrawPixels to the rotation matrix... please don't tell me not to use glDrawPixels and use something else because i am just following the assignment. I must use it. So i am curious having that.. how can go around and trying to rotate those pixels with rotation matrix. NOT OPNEGL... I know it's not the best way to do it but this is what i am asked to do. thanks

    C / C++ / MFC

  • glDrawPixels help
    M Member 3375334

    Hello, i am creating a rectangle using glDrawPixels by specifying it's height and width. I need to rotate this rectangle somehow 45 degrees. What should i do in order to rotate this rectangle. by using glRasterPos i am positioning that rect somewhere on the screen. How would i keep it rotating? thanks:confused:

    C / C++ / MFC

  • rectangle rotation
    M Member 3375334

    umm what i have in my code is something like: px = (rectwidth/2); py = (rectheight/2); so i assume that they represent my center through which i want to rotate my rectangle (px, py) however, i am not sure how to represent all of the point of the rect to be Xi Yi considering that my rectangle representaion is as mentioned in the previous post with co-ordinates of (250, 100) is rectangle[0] (550, 100) is rectangle[1] (550, 300) is rectangle[2] (250, 300) is rectangle[3] i am new to C++ so i am having trouble seeing how your equasion can be programmed. i do understand the equasions u've provided though. Please any suggestions on the programming? like:

    void rotate (float angle)
    {
    ? = (? - px)cos(angle) - (? - py)sin(angle);
    ? = (? - px)sin(angle) + (? - py)cos(angle);
    }

    not sure what should be in there.

    C / C++ / MFC

  • rectangle rotation
    M Member 3375334

    Hello, please help me to write a function rotate that will rotate the rectangle 45 degrees each time button is pressed let say that rectangle values are as follows rectangle[0].x=250.0; rectangle[0].y=100.0; rectangle[1].x=550.0; rectangle[1].y=100.0; rectangle[2].x=550.0; rectangle[2].y=300.0; rectangle[3].x=250.0; rectangle[3].y=300.0; i know that it should be something like H2 = H·cosθ + W·sinθ W2 = H·sinθ + W·cosθ where H2 is the height of the rotated rectangles and W2 is the width. i need an assistance in writing this function.. please help

    C / C++ / MFC

  • fill in the polygon
    M Member 3375334

    hello everyone i really need your help here.... i have implemented a program that is clipping the polygon against a square.. what i need to do now is to use the vertices that got created after clipping to fill in the polygon

    void OnFillPolygon()
    {
    // TODO: Add your command handler code here
    wglMakeCurrent(m_hDC,m_hRC);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    ::SwapBuffers(m_hDC);
    glPushMatrix();
    glColor3f( 1.0, 0.0, 0.0 ); //red
    glPolygonMode( GL_FRONT, GL_FILL );
    glBegin( GL_POLYGON ); //draw solid polygon
    glVertex2i( 10, 10 );
    glVertex2i( 100, 10 );
    glVertex2i( 150, 50 );
    glVertex2i( 100, 100 );
    glVertex2i( 50, 80 );
    glVertex2i( 10, 10 );*/
    glEnd();
    glPopMatrix();
    wglMakeCurrent(m_hDC,NULL);
    wglMakeCurrent(m_hDC,m_hRC);
    glFlush();
    ::SwapBuffers(m_hDC);
    }

    this is just specifying exact vertex values...
    what should i do so that those were the vertices after clipping.....?

    Graphics architecture help question

  • Boundary Fill function assistance needed [modified]
    M Member 3375334

    when i tried running it ... it did crash i know there is a way to fill in the polygon using something like poligonmode... but i am not sure how to use that correctly.. what i am doing is using GL_LINES to draw a polygon and then need to fill it in. how can i do that if not based on that function or what changes should i make to the function itself.

    Graphics help question

  • Boundary Fill function assistance needed [modified]
    M Member 3375334

    Hello, i am trying to implement boudary function but i am trying to run it .. it just crashes on me with no reason...what am i doing wrong? i think there is a problem with getPixel part... please help

    void CtestopenglView::setPixel(GLint x, GLint y)
    {
    glBegin(GL_POINTS);
    glVertex2d(x, y);
    glEnd();
    }

    void CtestopenglView::getPixel(GLint x ,GLint y, GLint &color)
    {
    glReadPixels(x, y, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, &color);
    }

    void CtestopenglView::boundFill(int x, int y, int fillColor, int borderColor)
    {
    int interiorColor;
    getPixel (x, y, interiorColor);
    if ((interiorColor != borderColor) && (interiorColor!= fillColor))
    {
    setPixel(x,y);
    boundFill(x + 1, y, fillColor, borderColor);
    boundFill(x - 1, y, fillColor, borderColor);
    boundFill(x, y + 1, fillColor, borderColor);
    boundFill(x, y - 1, fillColor, borderColor);
    }
    glFlush();
    }

    thank you

    modified on Thursday, March 5, 2009 11:41 PM

    Graphics help question

  • draw polygon using only two vertices
    M Member 3375334

    HEllo everyone, i am new to OpenGL and trying to figure out how to draw a rectangle using only 2 vertices. what i need to do is on button click select 2 opposite vertices like (0,0) and (10,10) let say. After i click 10,10 a rectangle should be drawn and it has to be not a solid line but dashed. please tell me what to do and what to write where. I tried googling didn't find anything regarding this. thanks FYI: i am going to be using this rectangle for clipping polygons.

    Graphics graphics game-dev architecture tutorial

  • rectangle drawing using OpenGL [modified]
    M Member 3375334

    Hello, i am totally new to OpenGL or windows programming in general. can someone please provide me with some code or tell me how to draw a rectangular clipping window on mouse move with only 2 vertices. So if i click somewehre in upper part of the window and then lower i should get a rectangle which is NOT filled and has dashed lines. i am going to use this rectangle for clipping. thanks

    modified on Friday, February 27, 2009 12:23 AM

    C / C++ / MFC graphics game-dev tutorial lounge

  • OnMouseMove swap and clear problem
    M Member 3375334

    hey, if i take out the first swap only i do get one line on the screen ... however it does not stay on the screen when i try to draw another... it dissapears... i need to keep on drawing the lines and keep on the screen...so that i could write something like WE right now after taking that swap out and trying to draw second line of the W first line is no longer on the screen... what should i do

    C / C++ / MFC graphics help game-dev tutorial

  • OnMouseMove swap and clear problem
    M Member 3375334

    Hello, i need help with this onMouseMove function... what i am doing here is drawing a line on the left and right side. On the left it;s all OpenGL AVI on the right i am calling my own function to draw the same lines as i move a mouse... however my problem is with MakeCurrent and clear screen here... because when i draw a line and rotate it ... there are bunch of lines all around. I don't know what i am doing wrong and where i need this swap buffer.... can someone please tell me how to get rid of those multiple lines when i move my mouse:

    void CtestopenglView::OnMouseMove(UINT nFlags, CPoint point)
    {
    // TODO: Add your message handler code here and/or call default
    wglMakeCurrent(m_hDC,m_hRC);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glClear(GL_COLOR_BUFFER_BIT);
    ::SwapBuffers(m_hDC);
    if(m_drawenabled)
    {
    m_start = point;
    glPushMatrix();
    glColor3f(0.0,0.0,0.0);
    DrawLine(m_start.x+300, m_start.y, m_end.x+300, m_end.y);

    	glBegin(GL\_LINES);
    	glVertex3d(m\_start.x, m\_start.y,0);
    	glVertex3d(m\_end.x, m\_end.y,0);
    	glEnd();
    	glPopMatrix();
    
    	m\_start = point;
    	glPushMatrix();
    	glColor3f(1.0,1.0,1.0);
    	DrawLine(m\_start.x+300, m\_start.y, m\_end.x+300, m\_end.y);
    	
    	glBegin(GL\_LINES);
    	glVertex3d(m\_start.x, m\_start.y,0);
    	glVertex3d(m\_end.x, m\_end.y,0);
    	glEnd();
    	glPopMatrix();
    }
    CView::OnMouseMove(nFlags, point);
    wglMakeCurrent(m\_hDC,NULL);
    wglMakeCurrent(m\_hDC,m\_hRC);
    glFlush();
    ::SwapBuffers(m\_hDC);
    

    }

    thanks

    C / C++ / MFC graphics help game-dev tutorial

  • reverse lines in OpenGl
    M Member 3375334

    Ok the fact that my code is so ugly is because i am brand new to all this so please don't be judgmental :) the reason why i am doing it in mousemove..is because that's what i need to do.. i need to draw on mouse move not paint. when i move my mouse i should be drawing lines. So that's right. The reason why i need to see MFC is because that's what i need to do based on the requirements. where should i do clear?

    C / C++ / MFC graphics help c++ game-dev tutorial

  • reverse lines in OpenGl
    M Member 3375334

    [Message Deleted]

    C / C++ / MFC graphics help c++ game-dev tutorial

  • reverse lines in OpenGl
    M Member 3375334

    the reason why i am using SetPixel is because i need to draw line in MFC and at the same time make it draw in OpenGL... i am sorry i didn't mention that earlier. that 10 was a mistake i meant for it to be 0 yes. another question i wanted to ask actually was that when i add OpenGL to MFC and roll my mouse over the screen i get entirely black screen and do not see on the left side my MFC line anymore. So what i am trying to do is to draw MFC line on the left and project that line the same exact way on the right. what am i doing wrong for that? because if i am trying to change a window color wihich by default is black to white my window flickers. when i close the window i see briefly my MFC line....but it's like behind the OpenGL layer... what's wrong?

    C / C++ / MFC graphics help c++ game-dev tutorial

  • reverse lines in OpenGl
    M Member 3375334

    [Message Deleted]

    C / C++ / MFC graphics help c++ game-dev tutorial

  • reverse lines in OpenGl
    M Member 3375334

    Hi, i am new to OpenGL and therefore need your help. When i draw a simple line using MFC it works fine... my pixels are ret correctly.. when i am trying to redraw that automatically using OpenGL they are being drawn in reverse...so instead of let say up to bottom... it is drawing it bottom to top. please let me know what changes need to be done withing Vertex...i tried it all.. i don't see how to fix this. int dx = (x2 - x1); int dy = (y2 - y1); int temp; float k; glBegin(GL_LINES); // Set start pixel ::SetPixel(m_hDC, x1, y1, color); glVertex2f(x1,y1); // X-dominant line if (abs(dx) > abs(dy)) { // Ex-change line end points if (dx < 0) { temp = x1; x1 = x2; x2 = temp; temp = y1; y1 = y2; y2 = temp; } k = (float)dy / (float)dx; // Set middle pixels int xs; float yt = (float)y1 + k; float distance; for (xs=x1+1; xs<x2; xs++) { distance = (float)(yt - (int)(yt)); ::SetPixel(m_hDC, xs, (int)yt, color); glVertex2f(xs,(int)yt); ::SetPixel(m_hDC, xs, (int)yt+1, color); glVertex2f(xs,(int)yt+1); yt += k; } } // Y-dominant line else { // Ex-change line end points if (dy < 0) { temp = x1; x1 = x2; x2 = temp; temp = y1; y1 = y2; y2 = temp; } k = (float)dx / (float)dy; // Set middle pixels int ys; float xt = (float)x1 + k; float distance; for (ys=y1+1; ys<y2; ys++) { distance = (float)(xt - (int)(xt)); ::SetPixel(m_hDC, (int)xt, ys, color); glVertex2f((int)xt,ys); ::SetPixel(m_hDC, (int)xt+1, ys, color); glVertex2f((int)xt+1,ys); xt += k; } } // Set end pixel ::SetPixel(m_hDC, x2, y2, color); glVertex2f(x2,y2); glEnd();

    C / C++ / MFC graphics help c++ game-dev tutorial

  • sqrt() pow() fabs() do not work
    M Member 3375334

    Hello everyone, i am trying to compile my program where i am using the functions like sqrt pow and fabs. I do have math.h included but for some reason i get errors like: error C2668: 'fabs' : ambiguous call to overloaded function same for the rest of the functions i have this included: #include "stdafx.h" #include "math.h" i tried including but still same errors. Does anyone know why they are not being recognized? my file is .cpp not .c but it is an MFC project. thanks

    C / C++ / MFC c++ json help question

  • selecting control points with OnLButtonDown
    M Member 3375334

    Hello, I am new to MFC so i have a question on how properly select a control point. When i click on the screen with my left mouse i want to select that point for my line drawing. So when i click on that spot ones and then by just moving a mouse without holding on the button i could draw a line and with right mouse click end this control point. Does anyone know of a good source to do this? Or how to tell the program that i want to select that point... thanks

    C / C++ / MFC question c++ graphics tutorial

  • Anti-aliased lines based on Gupta-Sproull algorithm
    M Member 3375334

    Hello everyone, i am new to MFC and VC++ programming in general. What i am trying to do right now is write a program that will allow me to draw lines based on a Gupta-Sproull midpoint algorithm. There is Bresenham algorithm but it's different. I believe it does not use distance. So the idea is if i'll left click on a mouse i select a control point on the screen and then can drag anywhere to draw a line. If i right button click then i end control point selection. By using this method i am trying to write something like WAKE which consists of bunch of lines. My problem is to get started. When i created a project in Visual studio it gives me loads of files for modification. Where should i start and does anyone have a sample code of that algorithm or how and where to use LButtonClick and RButtonClick... Any help will be appreaciated. The fact that i am new to this sample codes are the best. thanks

    C / C++ / MFC c++ help csharp visual-studio algorithms
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups