test opengl lesson 5 --- c program by LCCWin32 compiler

------------ down load file ----------------

1130820642_lcc prg lesson5.zip

lcc prg lesson5.zip

--------------------------------------------

LCCWin32 compiler

lcc compile
C:\lcc\bin\lcc.exe
$(FileName)
$(FileDir)

lcc link
C:\lcc\bin\lcclnk.exe
-O $(FileNameNoExt).exe -subsystem windows -s $(FileNameNoExt).obj opengl32.lib glu32.lib glaux.lib
$(FileDir)

glut link
C:\lcc\bin\lcclnk.exe
-O $(FileNameNoExt).exe -subsystem windows -s $(FileNameNoExt).obj opengl32.lib glu32.lib glaux.lib glut32.lib

----- mouse button1 --- and drag -----------

movement viewport ---------

----- mouse button3 --- and drag -----------

rotateviewport ---------




/*
*
*program by :choi myung hoan ------ blog.paran.com/choi7mh
*
referennce this ---------------------------

* 책 api 정복 -- 김상형 --
* *lesson xx ------- nehe.gamedev.net
*-----------------------------------------------

LCCWin32 compiler

lcc compile
C:\lcc\bin\lcc.exe
$(FileName)
$(FileDir)

lcc link
C:\lcc\bin\lcclnk.exe
-O $(FileNameNoExt).exe -subsystem windows -s $(FileNameNoExt).obj opengl32.lib glu32.lib glaux.lib
$(FileDir)

glut link
C:\lcc\bin\lcclnk.exe
-O $(FileNameNoExt).exe -subsystem windows -s $(FileNameNoExt).obj opengl32.lib glu32.lib glaux.lib glut32.lib

*/

#include <windows.h>// Header File For Windows
#include <math.h>// Header File For Math Library Routines
#include <stdio.h>// Header File For Standard I/O Routines
#include <stdlib.h>// Header File For Standard Library

//#include <containers.h>
//#include <str.h>
//#include <complex.h>


#include <gl\gl.h>// Header File For The OpenGL32 Library
#include <gl\glu.h>// Header File For The GLu32 Library
#include <gl\glaux.h>// Header File For The Glaux Library


//using std::min;
//using std::max;


LRESULT CALLBACK ChildLeftProc(HWND,UINT,WPARAM,LPARAM);

//HDChDC=NULL;// Private GDI Device Context
//HGLRChRC=NULL;// Permanent Rendering Context
//HWNDhWnd=NULL;// Holds Our Window Handle
//HINSTANCEhInstance;// Holds The Instance Of The Application
//-------------- global --------- var. ------- begin ---------------------------

HDCglobal_hDC=NULL;// Private GDI Device Context
HGLRCglobal_hglrc=NULL;// Permanent Rendering Context
HWNDglobal_hWnd=NULL;// Holds Our Window Handle
HINSTANCEglobal_hInstance;// Holds The Instance Of The Application

UINTglobal_uMsg ;
WPARAM global_wParam ;
LPARAMglobal_lParam ;

PAINTSTRUCT global_ps;
charglobal_str1[300];


//-------------- window1 --------- var. ------- begin ---------------------------

HDCwindow1_hDC=NULL;// Private GDI Device Context
HGLRCwindow1_hglrc=NULL;// Permanent Rendering Context
HWNDwindow1_hWnd=NULL;// Holds Our Window Handle
HINSTANCEwindow1_hInstance;// Holds The Instance Of The Application

//-------------- window2 --------- var. ------- begin ---------------------------
HDCwindow2_hDC=NULL;// Private GDI Device Context
HGLRCwindow2_hglrc=NULL;// Permanent Rendering Context
HWNDwindow2_hWnd=NULL;// Holds Our Window Handle
HINSTANCEwindow2_hInstance;// Holds The Instance Of The Application
//-------------- window2 --------- var. ------- end -----------------------------


//-------------- control window --------- var. ------- begin ------------------------

//HWND hWndMain, hC1, hC2, hC3;
HINSTANCE g_hInst;
//LRESULT CALLBACK ChildLeftProc(HWND hWnd,UINT iMessage,WPARAM wParam,LPARAM lParam);
LRESULT CALLBACK control_WndProc(HWND,UINT,WPARAM,LPARAM);
CALLBACK int control_window(HINSTANCE ,HINSTANCE ,LPSTR ,int );
LPSTR lpszClass_ctr="Opengl :by choi myung hoan ";

//-------------- control window --------- var. ------- end --------------------------

//-------------- control window2 --------- var. ------- begin ------------------------

//HINSTANCE g_hInst2;
LRESULT CALLBACK control_WndProc2(HWND,UINT,WPARAM,LPARAM);
CALLBACK int control_window2(HINSTANCE ,HINSTANCE ,LPSTR ,int );
LPSTR lpszClass_ctr2="Opengl control box:by choi myung hoan ";

char controle_now_str[90];int controle_now=1 ;
int hide_triangle=0 ;

//-------------- control window --------- var. ------- end --------------------------

BOOLkeys[256];// Array Used For The Keyboard Routine
BOOLactive=TRUE;// Window Active Flag Set To TRUE By Default
BOOLfullscreen=FALSE;// Fullscreen Flag Set To Fullscreen Mode By Default
BOOLdone=TRUE; ;//FALSE;// BOOL Variable To Exit Loop


floatrtri;// Angle For The Triangle ( NEW )
GLfloatrquad;// Angle For The Quad ( NEW )
GLfloatangle_line_xyz=0.0f;
float ms_move_to_gl_move_ratio= 1.0f/50.0f ;// 마우스의 델타를 gl 델타로 변환하는 상수값

LRESULTCALLBACK Window1_WndProc(HWND, UINT, WPARAM, LPARAM);// Declaration For Window1_WndProc
LRESULTCALLBACK Window2_WndProc(HWND, UINT, WPARAM, LPARAM);// Declaration For Window1_WndProc


CALLBACK int winow_mouse_move_dragg_set(void) ;//---
//LRESULT CALLBACK int winow_mouse_move_dragg_set(void) ; //multiple use of '_stdcall' 에러발생

CALLBACK int set_new_camera_poition( GLsizei x,GLsizei y ) ;//-----
CALLBACK int button_down_first_point_set(void); //-----


//- 주의 == 아래의 함수를 호출했는데도 에러메시지를 잡지못해 엄청 헤멨다
//----- move_camera_up_down_and_camera_direction_centered_rotate;//-----
//---- 아래와같이 정확히 기입할것 위경우는 콤파일 에러메시도 없고 실행도 안되서 버그 잡기가 무철 어려웠다 ---
//---- move_camera_up_down_and_camera_direction_centered_rotate();

/*
//=============== rot_xyz_and_translate_xyz_and_go_now ===== var.===== begin =====================

float len_of_3d_xyz_rot = 20.0f ;//----
float point_of_3d_xyz_rot[] = { 0.0f, 0.0f, -20.0f , //x,y,z //----
-5.0f, -1.0f, -5.0f , //rotate value x,y,z
2.0f, 5.0f,20.0f } ;//translate value x,y,z

float point_of_3d_xyz_rot_old[] = { 0.0f, 0.0f, -20.0f , //x,y,z //----
45.0f, -1.0f, -5.0f , //rotate value x,y,z
2.0f, 5.0f,20.0f } ;//translate value x,y,z

float new_point_of_xyz_rotated[] = { 0.0f, 0.0f, 0.0f, //rotated point x,y,x ---
0.0f, 0.0f, 0.0f } ;//translated point x,y,z

//=============== rot_xyz_and_translate_xyz_and_go_now ===== var.===== end =======================
*/


//=============== rot_xyz_and_translate_xyz_and_go_now ===== var.===== begin =====================

float len_of_3d_xyz_rot = 20.0f ;//----
float point_of_3d_xyz_rot[] = {
0.0f, 0.0f, 0.0f, //locate point x,y,x --- +-- 변수초기화로 아래의 카메라와 비슷한 역활을함 -----
0.0f, 0.0f, 0.0f, //rotate value x,y,z +-- gluPerspective , glViewport , frustum
0.0f, 0.0f, 0.0f, //translated point x,y,z
0.0f, 0.0f, 0.0f , //삼차변환 변수 y rot = +10 --- 카메라의 방향의 포인트를 중심으로 회전 ---
0.0f, 0.0f, 0.0f , //사차변환 변수 y rot = +13 --- 관찰자의 위치를 중심으로 회전 = 카메라의 위치의 포인트를 중심으로 회전 ---
0.0f, 0.0f, 0.0f } ; //buff

float point_of_3d_xyz_rot_old[] = {
0.0f, 0.0f,-20.0f , //locate point x,y,x +-- 변수초기화로 아래의 카메라와 비슷한 역활을함 -----
5.0f,-1.0f,-5.0f , //rotate value x,y,z +-- gluPerspective , glViewport , frustum
2.0f, 5.0f,20.0f , //translated point x,y,z
0.0f, 0.0f, 0.0f , //삼차변환 변수 y rot = +10 --- 카메라의 방향의 포인트를 중심으로 회전 ---
0.0f, 0.0f, 0.0f , //사차변환 변수 y rot = +13 --- 관찰자의 위치를 중심으로 회전 = 카메라의 위치의 포인트를 중심으로 회전 ---
0.0f, 0.0f, 0.0f } ; //buff

//----- transform_upgrade3 에서 이용하는 변수 ------
float new_point_of_xyz_rotated[] = {
0.0f, 0.0f, 0.0f, //locate point x,y,x ---
0.0f, 0.0f, 0.0f, //rotate value x,y,z
0.0f, 0.0f, 0.0f, //translated point x,y,z
0.0f, 0.0f, 0.0f , //삼차변환 변수 y rot = +10 --- 카메라의 방향의 포인트를 중심으로 회전 ---
0.0f, 0.0f, 0.0f , //사차변환 변수 y rot = +13 --- 관찰자의 위치를 중심으로 회전 = 카메라의 위치의 포인트를 중심으로 회전 ---
0.0f, 0.0f, 0.0f } ; //buff

float point_of_3d_xyz_rot_stage3[] = {
0.0f, 0.0f, 0.0f, //---- 삼차까지 변환한 값의 카메라의 위치값
0.0f, 0.0f, 0.0f } ;//---- 삼차까지 변환한 값의 카메라의 방향값

//=============== rot_xyz_and_translate_xyz_and_go_now ===== var.===== end =======================

//---------- mouse var. --- begin -------------

//char *str7 = "uuu" ;

static char *ms_btn_status ="uuuuuuuuuuuuuuuuu";
int ms_first_x=0;
int ms_first_y=0;
int ms_window_no=0;
int ms_now_x=0;
int ms_now_y=0;

int ms_btn_dn_xy[]={0,0,0,// x,y,window nu.
0,0,// +3 now ms x,y
0,0,// +5 delta x,y
0,0,0,0} ;

float ms_btn_dn_float_delta_xy[] = { 0.0,0.0,0.0,0.0 } ;

float LookAt_position_now[] = //<---- _old[] + _delta[]
{ 2.0f, 5.0f, 20.0f,// 카메라위치
0.0f, 0.0f, 0.0f,// 카메라방향 ,
0.0f, 1.0f, 0.0f };// 카메라 up방향

float LookAt_position_old[] =
{ 2.0f, 5.0f, 20.0f,// 카메라위치
0.0f, 0.0f, 0.0f,// 카메라방향 ,
0.0f, 1.0f, 0.0f };// 카메라 up방향

float LookAt_position_delta[] =
{ 0.0f, 0.0f, 0.0f,// 카메라위치
0.0f, 0.0f, 0.0f,// 카메라방향 ,
0.0f, 0.0f, 0.0f };// 카메라 up방향

typedef struct list_1 {
DWORD first_x;
DWORD first_y;
DWORD window_no;
DWORD now_x;
DWORD now_y;
} ;


//---------- mouse var. --- begin -------------


//IDirect3DViewport::DeleteLight ;

void ReSizeGLScene(GLsizei width, GLsizei height)// Resize And Initialize The GL Window
//GLvoid ReSizeGLScene( width, height)// Resize And Initialize The GL Window
{
if (height==0)// Prevent A Divide By Zero By
{
height=1;// Making Height Equal One
}

glViewport(0,0,width,height);// Reset The Current Viewport

glMatrixMode(GL_PROJECTION);// Select The Projection Matrix
glLoadIdentity();// Reset The Projection Matrix

// Calculate The Aspect Ratio Of The Window
gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f);

//gluLookAt ( 2.0f, 5.0f, 20.0f, 0.0f, 0.0f, 0.0f,// 카메라위치 , 카메라방향 ,
//0.0f, 1.0f, 0.0f );// 카메라 up방향

gluLookAt ( LookAt_position_now[0],LookAt_position_now[1],LookAt_position_now[2],
LookAt_position_now[3],LookAt_position_now[4],LookAt_position_now[5],
LookAt_position_now[6],LookAt_position_now[7],LookAt_position_now[8] ) ;

glMatrixMode(GL_MODELVIEW);// Select The Modelview Matrix
glLoadIdentity();// Reset The Modelview Matrix

//SwapBuffers(window1_hDC);// Swap Buffers (Double Buffering)

}

int InitGL(void)// All Setup For OpenGL Goes Here
{
glShadeModel(GL_SMOOTH);// Enable Smooth Shading
glClearColor(0.0f, 0.0f, 0.0f, 0.5f);// Black Background
glClearDepth(1.0f);// Depth Buffer Setup
glEnable(GL_DEPTH_TEST);// Enables Depth Testing
glDepthFunc(GL_LEQUAL);// The Type Of Depth Testing To Do
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);// Really Nice Perspective Calculations
return TRUE;// Initialization Went OK
}

int DrawGLScene(void)// Here's Where We Do All The Drawing
{//-----
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);// Clear Screen And Depth Buffer
glLoadIdentity();// Reset The Current Modelview Matrix
glTranslatef(-1.5f,0.0f,-6.0f);// Move Left 1.5 Units And Into The Screen 6.0
glRotatef(rtri,0.0f,1.0f,0.0f);// Rotate The Triangle On The Y axis ( NEW )
glBegin(GL_TRIANGLES);// Start Drawing A Triangle
glColor3f(1.0f,0.0f,0.0f);// Red
glVertex3f( 0.0f, 1.0f, 0.0f);// Top Of Triangle (Front)
glColor3f(0.0f,1.0f,0.0f);// Green
glVertex3f(-1.0f,-1.0f, 1.0f);// Left Of Triangle (Front)
glColor3f(0.0f,0.0f,1.0f);// Blue
glVertex3f( 1.0f,-1.0f, 1.0f);// Right Of Triangle (Front)
glColor3f(1.0f,0.0f,0.0f);// Red
glVertex3f( 0.0f, 1.0f, 0.0f);// Top Of Triangle (Right)
glColor3f(0.0f,0.0f,1.0f);// Blue
glVertex3f( 1.0f,-1.0f, 1.0f);// Left Of Triangle (Right)
glColor3f(0.0f,1.0f,0.0f);// Green
glVertex3f( 1.0f,-1.0f, -1.0f);// Right Of Triangle (Right)
glColor3f(1.0f,0.0f,0.0f);// Red
glVertex3f( 0.0f, 1.0f, 0.0f);// Top Of Triangle (Back)
glColor3f(0.0f,1.0f,0.0f);// Green
glVertex3f( 1.0f,-1.0f, -1.0f);// Left Of Triangle (Back)
glColor3f(0.0f,0.0f,1.0f);// Blue
glVertex3f(-1.0f,-1.0f, -1.0f);// Right Of Triangle (Back)
glColor3f(1.0f,0.0f,0.0f);// Red
glVertex3f( 0.0f, 1.0f, 0.0f);// Top Of Triangle (Left)
glColor3f(0.0f,0.0f,1.0f);// Blue
glVertex3f(-1.0f,-1.0f,-1.0f);// Left Of Triangle (Left)
glColor3f(0.0f,1.0f,0.0f);// Green
glVertex3f(-1.0f,-1.0f, 1.0f);// Right Of Triangle (Left)
glEnd();// Done Drawing The Pyramid

glLoadIdentity();// Reset The Current Modelview Matrix
glTranslatef(1.5f,0.0f,-7.0f);// Move Right 1.5 Units And Into The Screen 7.0
glRotatef(rquad,1.0f,1.0f,1.0f);// Rotate The Quad On The X axis ( NEW )
glBegin(GL_QUADS);// Draw A Quad
glColor3f(0.0f,1.0f,0.0f);// Set The Color To Blue
glVertex3f( 1.0f, 1.0f,-1.0f);// Top Right Of The Quad (Top)
glVertex3f(-1.0f, 1.0f,-1.0f);// Top Left Of The Quad (Top)
glVertex3f(-1.0f, 1.0f, 1.0f);// Bottom Left Of The Quad (Top)
glVertex3f( 1.0f, 1.0f, 1.0f);// Bottom Right Of The Quad (Top)
glColor3f(1.0f,0.5f,0.0f);// Set The Color To Orange
glVertex3f( 1.0f,-1.0f, 1.0f);// Top Right Of The Quad (Bottom)
glVertex3f(-1.0f,-1.0f, 1.0f);// Top Left Of The Quad (Bottom)
glVertex3f(-1.0f,-1.0f,-1.0f);// Bottom Left Of The Quad (Bottom)
glVertex3f( 1.0f,-1.0f,-1.0f);// Bottom Right Of The Quad (Bottom)
glColor3f(1.0f,0.0f,0.0f);// Set The Color To Red
glVertex3f( 1.0f, 1.0f, 1.0f);// Top Right Of The Quad (Front)
glVertex3f(-1.0f, 1.0f, 1.0f);// Top Left Of The Quad (Front)
glVertex3f(-1.0f,-1.0f, 1.0f);// Bottom Left Of The Quad (Front)
glVertex3f( 1.0f,-1.0f, 1.0f);// Bottom Right Of The Quad (Front)
glColor3f(1.0f,1.0f,0.0f);// Set The Color To Yellow
glVertex3f( 1.0f,-1.0f,-1.0f);// Top Right Of The Quad (Back)
glVertex3f(-1.0f,-1.0f,-1.0f);// Top Left Of The Quad (Back)
glVertex3f(-1.0f, 1.0f,-1.0f);// Bottom Left Of The Quad (Back)
glVertex3f( 1.0f, 1.0f,-1.0f);// Bottom Right Of The Quad (Back)
glColor3f(0.0f,0.0f,1.0f);// Set The Color To Blue
glVertex3f(-1.0f, 1.0f, 1.0f);// Top Right Of The Quad (Left)
glVertex3f(-1.0f, 1.0f,-1.0f);// Top Left Of The Quad (Left)
glVertex3f(-1.0f,-1.0f,-1.0f);// Bottom Left Of The Quad (Left)
glVertex3f(-1.0f,-1.0f, 1.0f);// Bottom Right Of The Quad (Left)
glColor3f(1.0f,0.0f,1.0f);// Set The Color To Violet
glVertex3f( 1.0f, 1.0f,-1.0f);// Top Right Of The Quad (Right)
glVertex3f( 1.0f, 1.0f, 1.0f);// Top Left Of The Quad (Right)
glVertex3f( 1.0f,-1.0f, 1.0f);// Bottom Left Of The Quad (Right)
glVertex3f( 1.0f,-1.0f,-1.0f);// Bottom Right Of The Quad (Right)
glEnd();// Done Drawing The Quad

rtri+=0.2f;// Increase The Rotation Variable For The Triangle ( NEW )
rquad-=0.15f;// Decrease The Rotation Variable For The Quad ( NEW )

// ---- 이루틴은 앞쪽에 있기때문에 에러발생 Missing prototype for 'DrawGLScene_b_line_xyz'
//DrawGLScene_b_line_xyz() ;

return TRUE;// Keep Going
}//---------------- end int DrawGLScene(void)-----------------


int DrawGLScene_b_line_xyz(void){ // drawing
//;clear screen and depth buffer
//; invoke glClear, GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT
glLoadIdentity(); //invoke glLoadIdentity ;reset modelview matrix
//; _glTranslatef -1.5f, 0.0f, -6.0f
//glTranslatef(-1.5f,0.0f,-6.0f);;// _glTranslatef 0.0f, 0.0f, 0.0f
glTranslatef( 0.0f,0.0f, 0.0f);;// _glTranslatef 0.0f, 0.0f, 0.0f
//; invoke glRotatef , rtri, rtri+4, rtri+8 , rtri+12
glRotatef( angle_line_xyz,0.0f,1.0f,0.0f);
// invoke glRotatef , rot_line_xyz_x, rot_line_xyz_x+4, rot_line_xyz_x+8 , rot_line_xyz_x+12 ;rtri
glBegin(GL_LINES);//invoke glBegin, GL_LINES

glColor3f (1.0f, 1.0f, 1.0f) ;
glVertex3f (-100.0f,0.0f ,0.0f) ;//x
glVertex3f (+100.0f,0.0f ,0.0f);

glColor3f (1.0f, 0.0f, 0.0f) ;
glVertex3f ( 0.0f ,-10.0f,0.0f) ;//y
glVertex3f (0.0f ,10.0f ,0.0f);

glColor3f (0.0f, 1.0f, 0.0f) ;
glVertex3f (0.0f ,0.0f ,-100.0f);//z
glVertex3f (0.0f ,0.0f ,+100.0f);


glEnd();//invoke glEnd

glLoadIdentity(); //invoke glLoadIdentity ;reset modelview matrix

float c_len = 1.1f;
glBegin(GL_LINES);//invoke glBegin, GL_LINES

glColor3f (1.0f, 1.0f, 1.0f) ;
glVertex3f (LookAt_position_now[3] , LookAt_position_now[4] ,LookAt_position_now[5] ) ;//x
glVertex3f (LookAt_position_now[3]+c_len, LookAt_position_now[4] ,LookAt_position_now[5] );

glColor3f (1.0f , 0.0f , 0.0f) ;
glVertex3f (LookAt_position_now[3] ,LookAt_position_now[4]-c_len ,LookAt_position_now[5]) ;//y
glVertex3f (LookAt_position_now[3] ,LookAt_position_now[4]+c_len ,LookAt_position_now[5]);

glColor3f (0.0f, 1.0f, 0.0f) ;
glVertex3f (LookAt_position_now[3] ,LookAt_position_now[4] , LookAt_position_now[5] );//z
glVertex3f (LookAt_position_now[3] ,LookAt_position_now[4] ,LookAt_position_now[5]+c_len );

if ( hide_triangle==0 ){//-----


glColor3f (1.0f, 1.0f, 1.0f) ;//---- 빗변 ----
glVertex3f ( 0.0f , 0.0f , 0.0f ) ;//x
glVertex3f (point_of_3d_xyz_rot_stage3[3] , point_of_3d_xyz_rot_stage3[4] ,point_of_3d_xyz_rot_stage3[5] );
glColor3f (1.0f, 1.0f, 1.0f) ;//---- 수직 ----
glVertex3f (point_of_3d_xyz_rot_stage3[3] , 0.0f ,point_of_3d_xyz_rot_stage3[5] );
glVertex3f (point_of_3d_xyz_rot_stage3[3] , point_of_3d_xyz_rot_stage3[4] ,point_of_3d_xyz_rot_stage3[5] );
glColor3f (1.0f, 1.0f, 1.0f) ;//---- 밑둥 ----
glVertex3f ( 0.0f , 0.0f , 0.0f ) ;//x
glVertex3f (point_of_3d_xyz_rot_stage3[3] , 0.0f ,point_of_3d_xyz_rot_stage3[5] );


glColor3f (1.0f, 0.0f, 0.0f) ;//---- 빗변 ----
glVertex3f ( 0.0f , 0.0f , 0.0f ) ;//x
glVertex3f (LookAt_position_now[3] , LookAt_position_now[4] ,LookAt_position_now[5] );
glColor3f (1.0f, 0.0f, 0.0f) ;//---- 수직 ----
glVertex3f (LookAt_position_now[3] , 0.0f ,LookAt_position_now[5] );
glVertex3f (LookAt_position_now[3] , LookAt_position_now[4] ,LookAt_position_now[5] );
glColor3f (1.0f, 0.0f, 0.0f) ;//---- 밑둥 ----
glVertex3f ( 0.0f , 0.0f , 0.0f ) ;//x
glVertex3f (LookAt_position_now[3] , 0.0f ,LookAt_position_now[5] );


/*
glColor3f (1.0f, 1.0f, 1.0f) ;//---- 빗변 ----
glVertex3f (point_of_3d_xyz_rot_stage3[0] ,point_of_3d_xyz_rot_stage3[1] ,point_of_3d_xyz_rot_stage3[2] );
glVertex3f (point_of_3d_xyz_rot_stage3[3] ,point_of_3d_xyz_rot_stage3[4] ,point_of_3d_xyz_rot_stage3[5] );
glColor3f (1.0f, 1.0f, 1.0f) ;//---- 수직 ----
glVertex3f (point_of_3d_xyz_rot_stage3[0] , 0.0f ,point_of_3d_xyz_rot_stage3[2] );
glVertex3f (point_of_3d_xyz_rot_stage3[3] ,point_of_3d_xyz_rot_stage3[4] ,point_of_3d_xyz_rot_stage3[5] );
glColor3f (1.0f, 1.0f, 1.0f) ;//---- 밑둥 ----
glVertex3f (point_of_3d_xyz_rot_stage3[0] ,point_of_3d_xyz_rot_stage3[1] ,point_of_3d_xyz_rot_stage3[2] );
glVertex3f (point_of_3d_xyz_rot_stage3[3] , 0.0f ,point_of_3d_xyz_rot_stage3[5] );
*/


}//-------- end if ( hide_triangle==0 ) ----------

glEnd();//invoke glEnd

return TRUE;// Keep Going

}//-------------


void KillGLWindow1(void)// Properly Kill The Window
{//----
if (fullscreen)// Are We In Fullscreen Mode?
{
ChangeDisplaySettings(NULL,0);// If So Switch Back To The Desktop
ShowCursor(TRUE);// Show Mouse Pointer
}

if (window1_hglrc)// Do We Have A Rendering Context?
{
if (!wglMakeCurrent(NULL,NULL))// Are We Able To Release The DC And RC Contexts?
{
MessageBox(NULL,"Release Of DC And RC Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
}

if (!wglDeleteContext(window1_hglrc))// Are We Able To Delete The RC?
{
MessageBox(NULL,"Release Rendering Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
}
window1_hglrc=NULL;// Set RC To NULL
}

if (window1_hDC && !ReleaseDC(window1_hWnd,window1_hDC))// Are We Able To Release The DC
{
MessageBox(NULL,"Release Device Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
window1_hDC=NULL;// Set DC To NULL
}

if (window1_hWnd && !DestroyWindow(window1_hWnd))// Are We Able To Destroy The Window?
{
MessageBox(NULL,"Could Not Release window1_hWnd.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
window1_hWnd=NULL;// Set window1_hWnd To NULL
}

if (!UnregisterClass("OpenGL_1",window1_hInstance))// Are We Able To Unregister Class
{
MessageBox(NULL,"Could Not Unregister Class.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
window1_hInstance=NULL;// Set window1_hInstance To NULL
}
}//--------- end --- KillGLWindow1 ---------------------


/*This Code Creates Our OpenGL Window. Parameters Are:*
*title- Title To Appear At The Top Of The Window*
*width- Width Of The GL Window Or Fullscreen Mode*
*height- Height Of The GL Window Or Fullscreen Mode*
*bits- Number Of Bits To Use For Color (8/16/24/32)*
*fullscreenflag- Use Fullscreen Mode (TRUE) Or Windowed Mode (FALSE)*/

BOOL CreateGLWindow1 //----------------- (window 1) ------- creating -------------
//BOOL CreateGLWindow1
(char* title, int width, int height, int bits, BOOL fullscreenflag)
{
GLuintPixelFormat;// Holds The Results After Searching For A Match
WNDCLASSwc;// Windows Class Structure
DWORDdwExStyle;// Window Extended Style
DWORDdwStyle;// Window Style
RECTWindowRect;// Grabs Rectangle Upper Left / Lower Right Values
WindowRect.left=(long)0;// Set Left Value To 0
WindowRect.right=(long)width;// Set Right Value To Requested Width
WindowRect.top=(long)0;// Set Top Value To 0
WindowRect.bottom=(long)height;// Set Bottom Value To Requested Height

fullscreen=fullscreenflag;// Set The Global Fullscreen Flag

window1_hInstance= GetModuleHandle(NULL);// Grab An Instance For Our Window

// mov wc.style, CS_HREDRAW or CS_VREDRAW or CS_OWNDC
//WS_OVERLAPPEDWINDOW or WS_CLIPSIBLINGS or WS_CLIPCHILDREN,
wc.style= CS_HREDRAW | CS_VREDRAW | CS_OWNDC;// Redraw On Size, And Own DC For Window.
//wc.style= 0; //

wc.lpfnWndProc= (WNDPROC) Window1_WndProc;// Window1_WndProc Handles Messages
wc.cbClsExtra= 0;// No Extra Window Data
wc.cbWndExtra= 0;// No Extra Window Data
//wc.this_hinstance= window1_hInstance;// error this ---
wc.hInstance= window1_hInstance;// Set The Instance
wc.hIcon= LoadIcon(NULL, IDI_WINLOGO);// Load The Default Icon
wc.hCursor= LoadCursor(NULL, IDC_ARROW);// Load The Arrow Pointer
wc.hbrBackground= NULL;// No Background Required For GL
wc.lpszMenuName= NULL;// We Don't Want A Menu
wc.lpszClassName= "OpenGL_1";// Set The Class Name

if (!RegisterClass(&wc))// Attempt To Register The Window Class
{
MessageBox(NULL,"Failed To Register The Window Class.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE;// Return FALSE
}

if (fullscreen)// Attempt Fullscreen Mode?
{
DEVMODE dmScreenSettings;// Device Mode
memset(&dmScreenSettings,0,sizeof(dmScreenSettings));// Makes Sure Memory's Cleared
dmScreenSettings.dmSize=sizeof(dmScreenSettings);// Size Of The Devmode Structure
dmScreenSettings.dmPelsWidth= width;// Selected Screen Width
dmScreenSettings.dmPelsHeight= height;// Selected Screen Height
dmScreenSettings.dmBitsPerPel= bits;// Selected Bits Per Pixel
dmScreenSettings.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;

// Try To Set Selected Mode And Get Results. NOTE: CDS_FULLSCREEN Gets Rid Of Start Bar.
if (ChangeDisplaySettings(&dmScreenSettings,CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL)
{
// If The Mode Fails, Offer Two Options. Quit Or Use Windowed Mode.
if (MessageBox(NULL,"The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?","NeHe GL",MB_YESNO|MB_ICONEXCLAMATION)==IDYES)
{
fullscreen=FALSE;// Windowed Mode Selected. Fullscreen = FALSE
}
else
{
// Pop Up A Message Box Letting User Know The Program Is Closing.
MessageBox(NULL,"Program Will Now Close.","ERROR",MB_OK|MB_ICONSTOP);
return FALSE;// Return FALSE
}
}
}

if (fullscreen)// Are We Still In Fullscreen Mode?
{
dwExStyle=WS_EX_APPWINDOW;// Window Extended Style
dwStyle=WS_POPUP;// Windows Style
ShowCursor(FALSE);// Hide Mouse Pointer
}
else
{
dwExStyle=WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;// Window Extended Style
dwStyle=WS_OVERLAPPEDWINDOW;// Windows Style
}

AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle);// Adjust Window To True Requested Size

// Create The Window
window1_hWnd=CreateWindowEx(dwExStyle,// Extended Style For The Window
"OpenGL_1",// Class Name
title,// Window Title
dwStyle |// Defined Window Style
WS_CLIPSIBLINGS |// Required Window Style
WS_CLIPCHILDREN,// Required Window Style
10, 70,// Window Position
WindowRect.right-WindowRect.left,// Calculate Window Width
WindowRect.bottom-WindowRect.top,// Calculate Window Height
NULL,// No Parent Window
NULL,// No Menu
window1_hInstance,// Instance
NULL);// Dont Pass Anything To WM_CREATE
//invokeCreateWindowEx,0,ADDR szClassName,
//movwindow1_hWnd,eax

//window1_hWnd= hWnd;

if (!window1_hWnd)
{
KillGLWindow1();// Reset The Display
MessageBox(NULL,"Window Creation Error.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE;// Return FALSE
}

staticPIXELFORMATDESCRIPTOR pfd=// pfd Tells Windows How We Want Things To Be
{
sizeof(PIXELFORMATDESCRIPTOR),// Size Of This Pixel Format Descriptor
1,// Version Number
PFD_DRAW_TO_WINDOW |// Format Must Support Window
PFD_SUPPORT_OPENGL |// Format Must Support OpenGL
PFD_DOUBLEBUFFER,// Must Support Double Buffering
PFD_TYPE_RGBA,// Request An RGBA Format
0, // Select Our Color Depth
0, 0, 0, 0, 0, 0,// Color Bits Ignored
0,// No Alpha Buffer
0,// Shift Bit Ignored
0,// No Accumulation Buffer
0, 0, 0, 0,// Accumulation Bits Ignored
16,// 16Bit Z-Buffer (Depth Buffer)
0,// No Stencil Buffer
0,// No Auxiliary Buffer
PFD_MAIN_PLANE,// Main Drawing Layer
0,// Reserved
0, 0, 0// Layer Masks Ignored
};
pfd.cColorBits = bits;

if (!(window1_hDC=GetDC(window1_hWnd)))// Did We Get A Device Context?
{
KillGLWindow1();// Reset The Display
MessageBox(NULL,"Can't Create A GL Device Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE;// Return FALSE
}

if (!(PixelFormat=ChoosePixelFormat(window1_hDC,&pfd)))// Did Windows Find A Matching Pixel Format?
{
KillGLWindow1();// Reset The Display
MessageBox(NULL,"Can't Find A Suitable PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE;// Return FALSE
}

if(!SetPixelFormat(window1_hDC,PixelFormat,&pfd))// Are We Able To Set The Pixel Format?
{
KillGLWindow1();// Reset The Display
MessageBox(NULL,"Can't Set The PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE;// Return FALSE
}

if (!(window1_hglrc=wglCreateContext(window1_hDC)))// Are We Able To Get A Rendering Context?
{
KillGLWindow1();// Reset The Display
MessageBox(NULL,"Can't Create A GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE;// Return FALSE
}

if(!wglMakeCurrent(window1_hDC,window1_hglrc))// Try To Activate The Rendering Context
{
KillGLWindow1();// Reset The Display
MessageBox(NULL,"Can't Activate The GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE;// Return FALSE
}

ShowWindow(window1_hWnd,SW_SHOW);// Show The Window
SetForegroundWindow(window1_hWnd);// Slightly Higher Priority
SetFocus(window1_hWnd);// Sets Keyboard Focus To The Window
ReSizeGLScene(width, height);// Set Up Our Perspective GL Screen

if (!InitGL())// Initialize Our Newly Created GL Window
{
KillGLWindow1();// Reset The Display
MessageBox(NULL,"Initialization Failed.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE;// Return FALSE
}

return TRUE;// Success
}//------ end CreateGLWindow1 ---------------------------------------------


//================= Window1_WndProc ============= begin ===========================

LRESULT CALLBACK Window1_WndProc( //--------------- Window1_WndProc ------ creating ------
HWNDthis_hWnd,// Handle For This Window
UINTuMsg,// Message For This Window
WPARAMwParam,// Additional Message Information
LPARAMlParam)// Additional Message Information
{
MSGmsg;
PAINTSTRUCTps;//LOCAL ps:PAINTSTRUCT
//LPPAINTSTRUCT lpps ;
HDCthis_hdc;//LOCAL hdc:HDC
RECTWINRect;

global_hWnd= this_hWnd ;
global_uMsg= uMsg ;
global_wParam= wParam ;
global_lParam= lParam ;


switch (uMsg)// Check For Windows Messages
{
case WM_ACTIVATE:// Watch For Window Activate Message
{
if (!HIWORD(wParam))// Check Minimization State
{
active=TRUE;// Program Is Active
}
else
{
active=FALSE;// Program Is No Longer Active
}

return 0;// Return To The Message Loop
}

case WM_SYSCOMMAND:// Intercept System Commands
{
switch (wParam)// Check System Calls
{
case SC_SCREENSAVE:// Screensaver Trying To Start?
case SC_MONITORPOWER:// Monitor Trying To Enter Powersave?
return 0;// Prevent From Happening
}
break;// Exit
}

case WM_CLOSE:// Did We Receive A Close Message?
{//--------------
//invoke MessageBox,hWin,ADDR TheText,ADDR szDisplayName ,MB_YESNO+MB_ICONQUESTION
// int eax =MessageBox(0,"Exit this program...","msx box",MB_YESNO+MB_ICONQUESTION);
//printf (" close the window\n " );
//done=TRUE;
//wglMakeCurrent(window1_hDC,NULL);
//wglDeleteContext(window1_hglrc);
//ReleaseDC(this_hWnd,window1_hDC);
//if (eax == IDYES){PostQuitMessage(0);}
PostQuitMessage(0);

//KillGLWindow1();// Kill The Window
//return 0;// Jump Back
//return (msg.wParam); //wParam// Exit The Program
// printf("Count, Capacity \n" );
//PostQuitMessage(0);// Send A Quit Message
return 0;// Jump Back
}

case WM_KEYDOWN:// Is A Key Being Held Down?
{
keys[wParam] = TRUE;// If So, Mark It As TRUE
return 0;// Jump Back
}

case WM_KEYUP:// Has A Key Been Released?
{
keys[wParam] = FALSE;// If So, Mark It As FALSE
return 0;// Jump Back
}

case WM_SIZE:// Resize The OpenGL Window
{


GetClientRect( this_hWnd,&WINRect ) ;// invokeGetClientRect,hWin,ADDR WINRect

wglMakeCurrent ( window1_hDC,window1_hglrc );

int t7_wd= LOWORD(lParam) , t7_ht= HIWORD(lParam) ;
GLsizei width = t7_wd , height = t7_ht ;
ReSizeGLScene( width , height ); // LoWord=Width, HiWord=Height
//ReSizeGLScene( t7_wd , t7_ht ); // LoWord=Width, HiWord=Height
//ReSizeGLScene(LOWORD(lParam),HIWORD(lParam)); // LoWord=Width, HiWord=Height
ReSizeGLScene( WINRect.right,WINRect.bottom ); // LoWord=Width, HiWord=Height

DrawGLScene();
DrawGLScene_b_line_xyz() ;// ----
SwapBuffers(window1_hDC);// Swap Buffers (Double Buffering)
return 0;// Jump Back
}

//--------------- WM_PAINT------------ begin --------------------------

case WM_PAINT:{//.ELSEIF uMsg==WM_PAINT
// --- 프로그램상에서 의도적으로 그림을 그리기 위해서 이루틴을 강제적으로 콜하게 만들면
//---- WM_SIZE lParam 에서와같이 화면의 정보를 얻을수 없으므로 GetClientRect
//---- 로 화면의 크기를 구한다음 화면 크기를 조정할것
//---- DrawGLScene(); SwapBuffers( 만으로는 그림이 안그려진다
//---- 그외의 경우는 DrawGLScene(); SwapBuffers( 만으로도 그려진다
//--- 화면의 겹쳐지는 부분만 갱신하므로 회전,이동...등의 변화를 중지한다 ------
this_hdc =BeginPaint(window1_hWnd,&ps); //invoke BeginPaint,hWin, ADDR ps
//this_hdc =BeginPaint(this_hWnd,&ps); //invoke BeginPaint,hWin, ADDR ps
// mov hdc,eax <-- HDC STDCALL BeginPaint( HWND,LPPAINTSTRUCT);windows.h>WIN.H

wglMakeCurrent ( window1_hDC,window1_hglrc );
//ReSizeGLScene(LOWORD(lParam),HIWORD(lParam)); // LoWord=Width, HiWord=Height
//set_new_camera_poition() ;//-----

//---------- 이루틴을 안더하면 화면이 안보였다. 아마도 갱신을 못하기때문 ---
//GetClientRect( this_hWnd,&WINRect ) ;// invokeGetClientRect,hWin,ADDR WINRect
GetClientRect( window1_hWnd,&WINRect ) ;// invokeGetClientRect,hWin,ADDR WINRect
//---------- 이것 때문에 엄청나게 지저분해졌다 . 무지하게 많이 뜯어고쳤다 ---

//ReSizeGLScene( WINRect.right,WINRect.bottom ); // LoWord=Width, HiWord=Height
set_new_camera_poition( WINRect.right,WINRect.bottom );//-----

DrawGLScene();
DrawGLScene_b_line_xyz() ;// ----
SwapBuffers(window1_hDC);// Swap Buffers (Double Buffering)
SwapBuffers(this_hdc);// Swap Buffers (Double Buffering)

//BOOL STDCALL EndPaint(HWND,CONST PAINTSTRUCT *);windows.h>WIN.H
//EndPaint(this_hWnd,&ps);//invoke EndPaint,hWin, ADDR ps
EndPaint(window1_hWnd,&ps);//invoke EndPaint,hWin, ADDR ps

return 0;// Jump Back
}//----------- end case WM_PAINT:{ ------------


/*

case WM_PAINT:{//.ELSEIF uMsg==WM_PAINT
//--- 화면의 겹쳐지는 부분만 갱신하므로 회전,이동...등의 변화를 중지한다 ------
//this_hdc =BeginPaint(window1_hWnd,&ps); //invoke BeginPaint,hWin, ADDR ps
this_hdc =BeginPaint(this_hWnd,&ps); //invoke BeginPaint,hWin, ADDR ps
// mov hdc,eax <-- HDC STDCALL BeginPaint( HWND,LPPAINTSTRUCT);windows.h>WIN.H

DrawGLScene();
DrawGLScene_b_line_xyz() ;// ----
//SwapBuffers(window1_hDC);// Swap Buffers (Double Buffering)
SwapBuffers(this_hdc);// Swap Buffers (Double Buffering)

//BOOL STDCALL EndPaint(HWND,CONST PAINTSTRUCT *);windows.h>WIN.H
EndPaint(this_hWnd,&ps);//invoke EndPaint,hWin, ADDR ps
//EndPaint(window1_hWnd,&ps);//invoke EndPaint,hWin, ADDR ps

return 0;// Jump Back
}//----------- end case WM_PAINT:{ ------------

*/

//--------------- WM_PAINT------------ end ----------------------------


//break;// Exit


}//------- end switch (uMsg) ---------------


winow_mouse_move_dragg_set();//------- button ---
printf( "ms_btn_status= %s ",ms_btn_status ); //---
printf(" ms_btn_dn_xy= %d,%d,%d,%d,%d ,%d,%d,%d,%d fdelta= %f,%f \n ",
ms_btn_dn_xy[0],ms_btn_dn_xy[1],ms_btn_dn_xy[2],
ms_btn_dn_xy[3],ms_btn_dn_xy[4],
ms_btn_dn_xy[5],ms_btn_dn_xy[6],ms_btn_dn_xy[7],ms_btn_dn_xy[7],
ms_btn_dn_float_delta_xy[0],ms_btn_dn_float_delta_xy[1]
);


/*
if ( global_uMsg ==WM_MOUSEMOVE ){//----

if ( (ms_btn_status[6] == 'd') || (ms_btn_status[7] == 'd') || (ms_btn_status[8] == 'd') ){//--
printf( " @@@ 500 run test \n" ) ;
//InvalidateRect( this_hWnd,NULL,TRUE ) ;// 이루틴은 윈도의 페인트를 콜하게 한다
}//--- end if ---

}//----- end if -------
*/


//InvalidateRect( this_hWnd,NULL,TRUE ) ;// 이루틴은 윈도의 페인트를 콜하게 한다

// Pass All Unhandled Messages To DefWindowProc
//return DefWindowProc(window1_hWnd,uMsg,wParam,lParam);
return DefWindowProc(this_hWnd,uMsg,wParam,lParam);

}//--------- end LRESULT CALLBACK Window1_WndProc(HWNDwindow1_hWnd,-------------

//================= Window1_WndProc ============= end ===========================


//================= CreateGLWindow2 ============= begin =========================


void KillGLWindow2(void)// Properly Kill The Window
{//----
if (fullscreen)// Are We In Fullscreen Mode?
{
ChangeDisplaySettings(NULL,0);// If So Switch Back To The Desktop
ShowCursor(TRUE);// Show Mouse Pointer
}

if (window2_hglrc)// Do We Have A Rendering Context?
{
if (!wglMakeCurrent(NULL,NULL))// Are We Able To Release The DC And RC Contexts?
{
MessageBox(NULL,"Release Of DC And RC Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
}

if (!wglDeleteContext(window2_hglrc))// Are We Able To Delete The RC?
{
MessageBox(NULL,"Release Rendering Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
}
window2_hglrc=NULL;// Set RC To NULL
}

if (window2_hDC && !ReleaseDC(window2_hWnd,window2_hDC))// Are We Able To Release The DC
{
MessageBox(NULL,"Release Device Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
window2_hDC=NULL;// Set DC To NULL
}

if (window2_hWnd && !DestroyWindow(window2_hWnd))// Are We Able To Destroy The Window?
{
MessageBox(NULL,"Could Not Release window2_hWnd.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
window2_hWnd=NULL;// Set window2_hWnd To NULL
}

if (!UnregisterClass("OpenGL_2",window2_hInstance))// Are We Able To Unregister Class
{
MessageBox(NULL,"Could Not Unregister Class.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
window2_hInstance=NULL;// Set window2_hInstance To NULL
}
}//--------- end --- KillGLWindow2 ---------------------


BOOL CreateGLWindow2 //----------------- (window 2) ------- creating -------------
(char* title, int width, int height, int bits, BOOL fullscreenflag)
{
//----------- new inserted by add childs ------- begin -------------
static HBRUSH hRedBrush, hBlueBrush, hGreenBrush;

hRedBrush=CreateSolidBrush(RGB(255,0,0));
hBlueBrush=CreateSolidBrush(RGB(0,255,0));
hGreenBrush=CreateSolidBrush(RGB(0,0,255));

//----------- new inserted by add childs ------- end ---------------




GLuintPixelFormat;// Holds The Results After Searching For A Match
WNDCLASSwc;// Windows Class Structure
DWORDdwExStyle;// Window Extended Style
DWORDdwStyle;// Window Style
RECTWindowRect;// Grabs Rectangle Upper Left / Lower Right Values
WindowRect.left=(long)0;// Set Left Value To 0
WindowRect.right=(long)width;// Set Right Value To Requested Width
WindowRect.top=(long)0;// Set Top Value To 0
WindowRect.bottom=(long)height;// Set Bottom Value To Requested Height

fullscreen=fullscreenflag;// Set The Global Fullscreen Flag

window2_hInstance= GetModuleHandle(NULL);// Grab An Instance For Our Window

// mov wc.style, CS_HREDRAW or CS_VREDRAW or CS_OWNDC
//WS_OVERLAPPEDWINDOW or WS_CLIPSIBLINGS or WS_CLIPCHILDREN,
wc.style= CS_HREDRAW | CS_VREDRAW | CS_OWNDC;// Redraw On Size, And Own DC For Window.
//wc.style= 0; //

wc.lpfnWndProc= (WNDPROC) Window2_WndProc;// Window2_WndProc Handles Messages
wc.cbClsExtra= 0;// No Extra Window Data
wc.cbWndExtra= 0;// No Extra Window Data
//wc.this_hinstance= window2_hInstance;// error this ---
wc.hInstance= window2_hInstance;// Set The Instance
wc.hIcon= LoadIcon(NULL, IDI_WINLOGO);// Load The Default Icon
wc.hCursor= LoadCursor(NULL, IDC_ARROW);// Load The Arrow Pointer
wc.hbrBackground= NULL;// No Background Required For GL
wc.lpszMenuName= NULL;// We Don't Want A Menu
wc.lpszClassName= "OpenGL_2";// Set The Class Name

if (!RegisterClass(&wc))// Attempt To Register The Window Class
{MessageBox(NULL,"Failed To Register The Window Class.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE;}//----

/*
// 왼쪽 차일드 클래스
wc.hbrBackground=hRedBrush;
wc.lpfnWndProc=(WNDPROC)ChildLeftProc;
wc.lpszClassName="ChildLeft";
RegisterClass(&wc);
*/


if (fullscreen)// Attempt Fullscreen Mode?
{
DEVMODE dmScreenSettings;// Device Mode
memset(&dmScreenSettings,0,sizeof(dmScreenSettings));// Makes Sure Memory's Cleared
dmScreenSettings.dmSize=sizeof(dmScreenSettings);// Size Of The Devmode Structure
dmScreenSettings.dmPelsWidth= width;// Selected Screen Width
dmScreenSettings.dmPelsHeight= height;// Selected Screen Height
dmScreenSettings.dmBitsPerPel= bits;// Selected Bits Per Pixel
dmScreenSettings.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;

// Try To Set Selected Mode And Get Results. NOTE: CDS_FULLSCREEN Gets Rid Of Start Bar.
if (ChangeDisplaySettings(&dmScreenSettings,CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL)
{
// If The Mode Fails, Offer Two Options. Quit Or Use Windowed Mode.
if (MessageBox(NULL,"The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?","NeHe GL",MB_YESNO|MB_ICONEXCLAMATION)==IDYES)
{
fullscreen=FALSE;// Windowed Mode Selected. Fullscreen = FALSE
}
else
{
// Pop Up A Message Box Letting User Know The Program Is Closing.
MessageBox(NULL,"Program Will Now Close.","ERROR",MB_OK|MB_ICONSTOP);
return FALSE;// Return FALSE
}
}
}

if (fullscreen)// Are We Still In Fullscreen Mode?
{
dwExStyle=WS_EX_APPWINDOW;// Window Extended Style
dwStyle=WS_POPUP;// Windows Style
ShowCursor(FALSE);// Hide Mouse Pointer
}
else
{
dwExStyle=WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;// Window Extended Style
dwStyle=WS_OVERLAPPEDWINDOW;// Windows Style
}

AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle);// Adjust Window To True Requested Size

// Create The Window
window2_hWnd=CreateWindowEx(dwExStyle,// Extended Style For The Window
"OpenGL_2",// Class Name
title,// Window Title
dwStyle |// Defined Window Style
WS_CLIPSIBLINGS |// Required Window Style
WS_CLIPCHILDREN,// Required Window Style
300, 90,// Window Position
WindowRect.right-WindowRect.left,// Calculate Window Width
WindowRect.bottom-WindowRect.top,// Calculate Window Height
NULL,// No Parent Window
NULL,// No Menu
window2_hInstance,// Instance
NULL);// Dont Pass Anything To WM_CREATE
//invokeCreateWindowEx,0,ADDR szClassName,
//movwindow2_hWnd,eax

//window2_hWnd= hWnd;

if (!window2_hWnd)
{
KillGLWindow2();// Reset The Display
MessageBox(NULL,"Window Creation Error.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE;// Return FALSE
}

staticPIXELFORMATDESCRIPTOR pfd=// pfd Tells Windows How We Want Things To Be
{
sizeof(PIXELFORMATDESCRIPTOR),// Size Of This Pixel Format Descriptor
1,// Version Number
PFD_DRAW_TO_WINDOW |// Format Must Support Window
PFD_SUPPORT_OPENGL |// Format Must Support OpenGL
PFD_DOUBLEBUFFER,// Must Support Double Buffering
PFD_TYPE_RGBA,// Request An RGBA Format
0, // Select Our Color Depth
0, 0, 0, 0, 0, 0,// Color Bits Ignored
0,// No Alpha Buffer
0,// Shift Bit Ignored
0,// No Accumulation Buffer
0, 0, 0, 0,// Accumulation Bits Ignored
16,// 16Bit Z-Buffer (Depth Buffer)
0,// No Stencil Buffer
0,// No Auxiliary Buffer
PFD_MAIN_PLANE,// Main Drawing Layer
0,// Reserved
0, 0, 0// Layer Masks Ignored
};
pfd.cColorBits = bits;

if (!(window2_hDC=GetDC(window2_hWnd)))// Did We Get A Device Context?
{
KillGLWindow2();// Reset The Display
MessageBox(NULL,"Can't Create A GL Device Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE;// Return FALSE
}

if (!(PixelFormat=ChoosePixelFormat(window2_hDC,&pfd)))// Did Windows Find A Matching Pixel Format?
{
KillGLWindow2();// Reset The Display
MessageBox(NULL,"Can't Find A Suitable PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE;// Return FALSE
}

if(!SetPixelFormat(window2_hDC,PixelFormat,&pfd))// Are We Able To Set The Pixel Format?
{
KillGLWindow2();// Reset The Display
MessageBox(NULL,"Can't Set The PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE;// Return FALSE
}

if (!(window2_hglrc=wglCreateContext(window2_hDC)))// Are We Able To Get A Rendering Context?
{
KillGLWindow2();// Reset The Display
MessageBox(NULL,"Can't Create A GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE;// Return FALSE
}

if(!wglMakeCurrent(window2_hDC,window2_hglrc))// Try To Activate The Rendering Context
{
KillGLWindow2();// Reset The Display
MessageBox(NULL,"Can't Activate The GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE;// Return FALSE
}

ShowWindow(window2_hWnd,SW_SHOW);// Show The Window
SetForegroundWindow(window2_hWnd);// Slightly Higher Priority
SetFocus(window2_hWnd);// Sets Keyboard Focus To The Window
ReSizeGLScene(width, height);// Set Up Our Perspective GL Screen

if (!InitGL())// Initialize Our Newly Created GL Window
{
KillGLWindow2();// Reset The Display
MessageBox(NULL,"Initialization Failed.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE;// Return FALSE
}

int x=30,y=30;

//CreateWindow("OpenGL_2" ,NULL,WS_CHILD | WS_VISIBLE,
//x,y,100,100,window2_hWnd,(HMENU)NULL,window2_hInstance,NULL);

return TRUE;// Success
}//------ end CreateGLWindow2 ---------------------------------------------

//================= CreateGLWindow2 ============= end ===========================

//================= Window2_WndProc ============= begin ===========================

LRESULT CALLBACK Window2_WndProc( //--------------- Window2_WndProc ------ creating ------
HWNDthis_hWnd,// Handle For This Window
UINTuMsg,// Message For This Window
WPARAMwParam,// Additional Message Information
LPARAMlParam)// Additional Message Information
{
MSGmsg;
PAINTSTRUCTps;//LOCAL ps:PAINTSTRUCT
//LPPAINTSTRUCT lpps ;
HDCthis_hdc;//LOCAL hdc:HDC
RECTWINRect;


global_hWnd= this_hWnd ;
global_uMsg= uMsg ;
global_wParam= wParam ;
global_lParam= lParam ;


switch (uMsg)// Check For Windows Messages
{
case WM_ACTIVATE:// Watch For Window Activate Message
{
if (!HIWORD(wParam))// Check Minimization State
{
active=TRUE;// Program Is Active
}
else
{
active=FALSE;// Program Is No Longer Active
}

return 0;// Return To The Message Loop
}


case WM_CREATE:
return 0;

case WM_SYSCOMMAND:// Intercept System Commands
{
switch (wParam)// Check System Calls
{
case SC_SCREENSAVE:// Screensaver Trying To Start?
case SC_MONITORPOWER:// Monitor Trying To Enter Powersave?
return 0;// Prevent From Happening
}
break;// Exit
}

case WM_CLOSE:// Did We Receive A Close Message?
{//--------------
PostQuitMessage(0);

return 0;// Jump Back
}

case WM_KEYDOWN:// Is A Key Being Held Down?
{
keys[wParam] = TRUE;// If So, Mark It As TRUE
return 0;// Jump Back
}

case WM_KEYUP:// Has A Key Been Released?
{
keys[wParam] = FALSE;// If So, Mark It As FALSE
return 0;// Jump Back
}

case WM_SIZE:{// Resize The OpenGL Window

GetClientRect( this_hWnd,&WINRect ) ;// invokeGetClientRect,hWin,ADDR WINRect

wglMakeCurrent ( window2_hDC,window2_hglrc );

int t7_wd= LOWORD(lParam) , t7_ht= HIWORD(lParam) ;
GLsizei width = t7_wd , height = t7_ht ;
ReSizeGLScene( width , height ); // LoWord=Width, HiWord=Height
//ReSizeGLScene( t7_wd , t7_ht ); // LoWord=Width, HiWord=Height
//ReSizeGLScene(LOWORD(lParam),HIWORD(lParam)); // LoWord=Width, HiWord=Height
ReSizeGLScene( WINRect.right,WINRect.bottom ); // LoWord=Width, HiWord=Height

DrawGLScene();
DrawGLScene_b_line_xyz() ;// ----
SwapBuffers(window2_hDC);// Swap Buffers (Double Buffering)
return 0;// Jump Back
}//---- end case WM_SIZE:


//--------------- WM_PAINT------------ begin --------------------------

case WM_PAINT:{//.ELSEIF uMsg==WM_PAINT
// --- 프로그램상에서 의도적으로 그림을 그리기 위해서 이루틴을 강제적으로 콜하게 만들면
//---- WM_SIZE lParam 에서와같이 화면의 정보를 얻을수 없으므로 GetClientRect
//---- 로 화면의 크기를 구한다음 화면 크기를 조정할것
//---- DrawGLScene(); SwapBuffers( 만으로는 그림이 안그려진다
//---- 그외의 경우는 DrawGLScene(); SwapBuffers( 만으로도 그려진다
//--- 화면의 겹쳐지는 부분만 갱신하므로 회전,이동...등의 변화를 중지한다 ------
this_hdc =BeginPaint(window2_hWnd,&ps); //invoke BeginPaint,hWin, ADDR ps
//this_hdc =BeginPaint(this_hWnd,&ps); //invoke BeginPaint,hWin, ADDR ps
// mov hdc,eax <-- HDC STDCALL BeginPaint( HWND,LPPAINTSTRUCT);windows.h>WIN.H

wglMakeCurrent ( window2_hDC,window2_hglrc );
//ReSizeGLScene(LOWORD(lParam),HIWORD(lParam)); // LoWord=Width, HiWord=Height
//set_new_camera_poition() ;//-----

//---------- 이루틴을 안더하면 화면이 안보였다. 아마도 갱신을 못하기때문 ---
//GetClientRect( this_hWnd,&WINRect ) ;// invokeGetClientRect,hWin,ADDR WINRect
GetClientRect( window2_hWnd,&WINRect ) ;// invokeGetClientRect,hWin,ADDR WINRect
//---------- 이것 때문에 엄청나게 지저분해졌다 . 무지하게 많이 뜯어고쳤다 ---

//ReSizeGLScene( WINRect.right,WINRect.bottom ); // LoWord=Width, HiWord=Height
set_new_camera_poition( WINRect.right,WINRect.bottom );//-----

DrawGLScene();
DrawGLScene_b_line_xyz() ;// ----
SwapBuffers(window2_hDC);// Swap Buffers (Double Buffering)
SwapBuffers(this_hdc);// Swap Buffers (Double Buffering)

//BOOL STDCALL EndPaint(HWND,CONST PAINTSTRUCT *);windows.h>WIN.H
//EndPaint(this_hWnd,&ps);//invoke EndPaint,hWin, ADDR ps
EndPaint(window2_hWnd,&ps);//invoke EndPaint,hWin, ADDR ps

return 0;// Jump Back
}//----------- end case WM_PAINT:{ ------------

//--------------- WM_PAINT------------ end ----------------------------

}//------- end switch (uMsg) ---------------


winow_mouse_move_dragg_set();//------- button ---
printf( "ms_btn_status= %s ",ms_btn_status ); //---
printf(" ms_btn_dn_xy= %d,%d,%d,%d,%d ,%d,%d,%d,%d fdelta= %f,%f \n ",
ms_btn_dn_xy[0],ms_btn_dn_xy[1],ms_btn_dn_xy[2],
ms_btn_dn_xy[3],ms_btn_dn_xy[4],
ms_btn_dn_xy[5],ms_btn_dn_xy[6],ms_btn_dn_xy[7],ms_btn_dn_xy[7],
ms_btn_dn_float_delta_xy[0],ms_btn_dn_float_delta_xy[1]
);

//InvalidateRect( this_hWnd,NULL,TRUE ) ;// 이루틴은 윈도의 페인트를 콜하게 한다

// Pass All Unhandled Messages To DefWindowProc
//return DefWindowProc(window2_hWnd,uMsg,wParam,lParam);
return DefWindowProc(this_hWnd,uMsg,wParam,lParam);

}//--------- end LRESULT CALLBACK Window2_WndProc(HWNDwindow2_hWnd,-------------

//================= Window2_WndProc ============= end ===========================

// 왼쪽 차일드의 메시지 프로시저
LRESULT CALLBACK ChildLeftProc(HWND hWnd,UINT iMessage,WPARAM wParam,LPARAM lParam)
{
/*
static HWND hList, hEdit;
char str[256];
g_hInst = window2_hInstance ;

switch(iMessage) {
case WM_CREATE:
hList=CreateWindow("listbox",NULL,WS_CHILD | WS_VISIBLE | WS_BORDER |
LBS_NOTIFY | LBS_NOINTEGRALHEIGHT,0,0,0,0,hWnd,(HMENU)0,g_hInst,NULL);
SendMessage(hList,LB_ADDSTRING,0,(LPARAM)"리스트 박스");
hEdit=CreateWindow("edit",NULL,WS_CHILD | WS_VISIBLE | WS_BORDER |
ES_AUTOHSCROLL,
210,10,80,25,hWnd,(HMENU)1,g_hInst,NULL);
CreateWindow("button","Add",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
210,50,80,25,hWnd,(HMENU)2,g_hInst,NULL);
return 0;
case WM_SIZE:
MoveWindow(hList,10,10,190,HIWORD(lParam)-20,TRUE);
return 0;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case 2:
GetWindowText(hEdit,str,256);
SendMessage(hList,LB_ADDSTRING,0,(LPARAM)str);
}
return 0;
}

*/
return(DefWindowProc(hWnd,iMessage,wParam,lParam));
}

int WINAPI WinMain(HINSTANCEthis_hinstance,// Instance
//int WINAPI WinMain(HINSTANCEhInstance,// Instance
HINSTANCEhPrevInstance,// Previous Instance
LPSTRlpCmdLine,// Command Line Parameters
intnCmdShow)// Window Show State
{
MSGmsg;// Windows Message Structure
;BOOLdone=FALSE;// BOOL Variable To Exit Loop


fullscreen=FALSE;// Windowed Mode

// Create Our OpenGL Window
if (!CreateGLWindow1("Opengl test .......",200,200,16,fullscreen))
{
return 0;// Quit If Window Was Not Created
}


if (!CreateGLWindow2("Opengl window 2 ...",200,200,16,fullscreen)){return 0;}//------

//control_window( this_hinstance, hPrevInstance, lpCmdLine , nCmdShow );
control_window2( this_hinstance, hPrevInstance, lpCmdLine , nCmdShow );


while(!done)// Loop That Runs While done=FALSE
{

// invoke UpdateWindow, window1_hWnd
// UpdateWindow( window1_hWnd );

//int eax = PeekMessage(&msg,NULL,0,0,PM_REMOVE) ;
UpdateWindow( window1_hWnd ); // invoke UpdateWindow, window1_hWnd
int eax = GetMessage(&msg,NULL,0,0) ; //invoke GetMessage, ADDR msg,NULL,0,0
// printf ( "JJJLJLK\n" );
//printf ( "eax=%d \n",eax );
if ( eax==0 ){done=TRUE;}
TranslateMessage(&msg);
DispatchMessage(&msg);

//SwapBuffers(window1_hDC);
/*
//if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))// Is There A Message Waiting?
if (GetMessage(&msg,NULL,0,0))// Is There A Message Waiting?
{
if (msg.message==WM_QUIT)
{done=TRUE;}
else
{TranslateMessage(&msg);
DispatchMessage(&msg);
}
}//-------- END if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) -----

else// If There Are No Messages
{// Draw The Scene. Watch For ESC Key And Quit Messages From DrawGLScene()
if ((active && !DrawGLScene()) || keys[VK_ESCAPE])// Active? Was There A Quit Received?
{done=TRUE;}
else// Not Time To Quit, Update Screen
{ //SwapBuffers(window1_hDC);// Swap Buffers (Double Buffering)
}

//if (keys[VK_F1])// Is F1 Being Pressed?
}//----- end else -------------

*/


}//------------ end while(!done) ---------

// Shutdown
KillGLWindow2();// Kill The Window
return (msg.wParam);// Exit The Program
}//-------------- end int WINAPI WinMain(HINSTANCEthis_hinstance -------------

//======================== int WINAPI WinMain ============== end ===============================
//==============================================================================================


//======================== int control_window ============== begin =============================
//==============================================================================================


// control_WndProc LTGRAY_BRUSH GRAY_BRUSH DKGRAY_BRUSH BLACK_BRUSH

int control_window( //------------- 새로 콘트롤 윈도를 만든다 -----------------
HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpszCmdParam,int nCmdShow)
{
HWND hWnd;
MSG Message;
WNDCLASS WndClass;
g_hInst=hInstance;

//Color color7 ;//= Color(244,211,10) ; //RGB(244,211,10) ;
// HBRUSH Background7 ; Background7 = RGB(244,211,10) ;
//int color_int = 244 ;//<< 16 ;//RGB(244,211,10) ;//11 ;

WndClass.cbClsExtra=0;
WndClass.cbWndExtra=0;
WndClass.hbrBackground=(HBRUSH)GetStockObject( LTGRAY_BRUSH );
//WndClass.hbrBackground=CreateSolidBrush(RGB(255,0,0));
WndClass.hCursor=LoadCursor(NULL,IDC_ARROW);
WndClass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
WndClass.hInstance=hInstance;
WndClass.lpfnWndProc=(WNDPROC)control_WndProc;
WndClass.lpszClassName=lpszClass_ctr;
WndClass.lpszMenuName=NULL;
WndClass.style=CS_HREDRAW | CS_VREDRAW;
RegisterClass(&WndClass);

//-------- 이루틴을 첨가하면 화면의 색상은 바뀌지만 버튼으로써의 능력은 상실 ----- begin --
/*WndClass.hbrBackground=CreateSolidBrush(RGB(255,0,0));
WndClass.lpfnWndProc=(WNDPROC)ChildLeftProc;
WndClass.lpszClassName="button" ;
RegisterClass(&WndClass); */
//-------- 이루틴을 첨가하면 화면의 색상은 바뀌지만 버튼으로써의 능력은 상실 ----- end ----


hWnd=CreateWindow(lpszClass_ctr,lpszClass_ctr,WS_OVERLAPPEDWINDOW,
//CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,
35 ,350,411,311,
NULL,(HMENU)NULL,hInstance,NULL);
ShowWindow(hWnd,nCmdShow);

/*
while(GetMessage(&Message,0,0,0)) {
TranslateMessage(&Message);
DispatchMessage(&Message);
}
*/


return Message.wParam;
}//------ end ------------ control_window -----------

//------ scroll bar --- begin -----
#define ID_SCRRED 100 // #define ID_SCRGREEN 101 이렇게 중첩해서 쓰면 에러나온다
#define ID_SCRGREEN 101
#define ID_SCRBLUE 102
#define ID_SCRREDv 103


HWND hwnd_hRed_scroll_bar, hwnd_hGreen_scroll_bar , hwnd_hBlue_scroll_bar ,
hwnd_vRed_scroll_bar ;
intRed,Green,Blue;
HBRUSHMyBrush, OldBrush;
intTempPos;

#define ID_scrb_move_speed 105
HWND hwnd_move_speed_scrb ;
intTempPos2,move_speed=50 , move_speed_max=2000;
//------ scroll bar --- end -------

HBITMAP MakeDDBFromDIB(HDC hdc,char *Path)
{
HANDLE hFile;
DWORD FileSize, dwRead;
BITMAPFILEHEADER *fh;
HBITMAP hBit;
PVOID ih;
BITMAP bit;

hFile=CreateFile(Path,GENERIC_READ,0,NULL,
OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
if (hFile==INVALID_HANDLE_VALUE) {
return NULL;
}

FileSize=GetFileSize(hFile,NULL);

fh=(BITMAPFILEHEADER *)malloc(FileSize);
ReadFile(hFile,fh,FileSize,&dwRead,NULL);
CloseHandle(hFile);

ih=((PBYTE)fh+sizeof(BITMAPFILEHEADER));
// DDB로 변환한다.
hBit=CreateDIBitmap(hdc,(BITMAPINFOHEADER *)ih,CBM_INIT,
(PBYTE)fh+fh->bfOffBits,(BITMAPINFO *)ih,DIB_RGB_COLORS);

// DDB로 변환한 후 래스터 데이터는 따로 설정한다.
//hBit=CreateDIBitmap(hdc,(BITMAPINFOHEADER *)ih,0,NULL,NULL,0);
//GetObject(hBit,sizeof(BITMAP),&bit);
//SetDIBits(NULL,hBit,0,bit.bmHeight,(PBYTE)fh+fh->bfOffBits,(BITMAPINFO *)ih,DIB_RGB_COLORS);
free(fh);
return hBit;
}//-------------------

#define ID_COMBOBOX 200
#define ID_LISTBOX 300
char Items[][25]={"Strawberry","Melon Melon","Apple","Orange","Grape"};
char str[128];
HWND hCombo;
HWND hList;


#define ID_BUTTON0 500
#define ID_BUTTON1 501


HWND check_box1,check_box2,check_box3,check_box4;
BOOL ELLIPSE = FALSE;
#define ID_chkbx1 701 // #define ID_SCRGREEN 101 이렇게 중첩해서 쓰면 에러나온다
#define ID_chkbx2 702
#define ID_chkbx3 703
#define ID_chkbx4 704

#define ID_radio1 101
#define ID_radio2 102
#define ID_radio3 103
#define ID_radio4 104
#define ID_radio5 105
#define ID_radio6 106
HWND hwnd_radio1,hwnd_radio2,hwnd_radio3,hwnd_radio4,hwnd_radio5,hwnd_radio6;
int GRAPH_radio=0; int COLOR_radio=0;

//HBITMAP MyBitmap, OldBitmap;
//HDC MemDC;

HDC hdc;
PAINTSTRUCT ps;
HBITMAP hBit;
char Path[MAX_PATH];

int create_various_menu( HWND hWnd ){//------- 여러가지 형태의 콘트롤박스를 만든다 -----

//WNDCLASS WndClass7;
//WndClass7.hbrBackground=CreateSolidBrush(RGB(255,0,0));
//RegisterClass(&WndClass7);

CreateWindow("button","Click Me",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
20,20,100,25,hWnd,(HMENU)ID_BUTTON0,g_hInst,NULL);
CreateWindow("button","Me Two",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
20,50,100,25,hWnd,(HMENU)ID_BUTTON1,g_hInst,NULL);

hwnd_hRed_scroll_bar=CreateWindow("scrollbar",NULL,WS_CHILD | WS_VISIBLE | SBS_HORZ,
10,10+100,200,20,hWnd,(HMENU)ID_SCRRED,g_hInst,NULL);
hwnd_hGreen_scroll_bar=CreateWindow("scrollbar",NULL,WS_CHILD | WS_VISIBLE | SBS_HORZ,
10,40+100,200,20,hWnd,(HMENU)ID_SCRGREEN,g_hInst,NULL);
hwnd_hBlue_scroll_bar=CreateWindow("scrollbar",NULL,WS_CHILD | WS_VISIBLE | SBS_HORZ,
10,70+100,200,20,hWnd,(HMENU)ID_SCRBLUE,g_hInst,NULL);

hwnd_vRed_scroll_bar=CreateWindow("scrollbar",NULL,WS_CHILD | WS_VISIBLE | SBS_VERT,
220,10+100,10,100,hWnd,(HMENU)ID_SCRREDv,g_hInst,NULL);

SetScrollRange(hwnd_hRed_scroll_bar,SB_CTL,0,255,TRUE);
SetScrollPos(hwnd_hRed_scroll_bar,SB_CTL,0,TRUE);
SetScrollRange(hwnd_hGreen_scroll_bar,SB_CTL,0,255,TRUE);
SetScrollPos(hwnd_hGreen_scroll_bar,SB_CTL,0,TRUE);
SetScrollRange(hwnd_hBlue_scroll_bar,SB_CTL,0,255,TRUE);
SetScrollPos(hwnd_hBlue_scroll_bar,SB_CTL,0,TRUE);

SetScrollRange(hwnd_vRed_scroll_bar,SB_CTL,0,255,TRUE);
SetScrollPos(hwnd_vRed_scroll_bar,SB_CTL,0,TRUE);
//------- 콤봅박스 만들기 시작 ------------
hCombo=CreateWindow("combobox",NULL,WS_CHILD | WS_VISIBLE | CBS_DROPDOWN,
150,10,100,200,hWnd,(HMENU)ID_COMBOBOX,g_hInst,NULL);
int i;char *jjj="fffff" ;
for (i=0;i<5;i++){SendMessage(hCombo,CB_ADDSTRING,0,(LPARAM)Items[i]);}
//i=SendMessage(hCombo, CB_GETCURSEL,0,0);
//SendMessage(hCombo, "kkkkkkkkkk", Null, (LPARAM)jjj );
//SendMessage(hCombo, CB_GETLBTEXT, i, (LPARAM)Items[i]) ;
//SendMessage(hCombo,LB_ADDSTRING,0,(LPARAM)"리스트 박스");
SendMessage(hCombo, CB_SETTOPINDEX, 2, 0 );
//SendMessage(hCombo,CB_GETLBTEXT,i,(LPARAM)"리스트 박스");
//SetWindowText(hWnd, jjj);
//------- 콤봅박스 만들기 끝 --------------

//------- 리스트박스 만들기 시작 ------------

hList=CreateWindow("listbox",NULL,WS_CHILD | WS_VISIBLE | WS_BORDER |
LBS_NOTIFY | WS_VSCROLL ,260,10,100,200,hWnd,(HMENU)ID_LISTBOX,g_hInst,NULL);
for (int j=0;j<5;j++){
for (i=0;i<5;i++){SendMessage(hList,LB_ADDSTRING,0,(LPARAM)Items[i]);}
}
//------- 리스트박스 만들기 끝 --------------

//------- 체크박스 만들기 시작 ------------
check_box1=CreateWindow("button","Draw Ellipse?",WS_CHILD | WS_VISIBLE |
BS_CHECKBOX, 370,20,160,25,hWnd,(HMENU)ID_chkbx1,g_hInst,NULL);
check_box2=CreateWindow("button","Good bye Message?",WS_CHILD | WS_VISIBLE |
BS_AUTOCHECKBOX,370,50,160,25,hWnd,(HMENU)ID_chkbx2 ,g_hInst,NULL);
check_box3=CreateWindow("button","3State",WS_CHILD | WS_VISIBLE | BS_3STATE,
370,80,160,25,hWnd,(HMENU)ID_chkbx3 ,g_hInst,NULL);
check_box4=CreateWindow("button","Auto 3State",WS_CHILD | WS_VISIBLE |
BS_AUTO3STATE, 370,110,160,25,hWnd,(HMENU)ID_chkbx4 ,g_hInst,NULL);
//------- 체크박스 만들기 끝 --------------

//------- 라디오박스 만들기 시작 ------------

int x7=210,y7=210;
CreateWindow("button","Graph",WS_CHILD | WS_VISIBLE |
BS_GROUPBOX,x7+5,y7+5,120,110,hWnd,(HMENU)0,g_hInst,NULL);
CreateWindow("button","Color",WS_CHILD | WS_VISIBLE |
BS_GROUPBOX,x7+145,y7+5,120,110,hWnd,(HMENU)1,g_hInst,NULL);
hwnd_radio1=CreateWindow("button","Rectangle",WS_CHILD | WS_VISIBLE |
BS_AUTORADIOBUTTON | WS_GROUP,
x7+10,y7+20,100,30,hWnd,(HMENU)ID_radio1,g_hInst,NULL);
hwnd_radio2=CreateWindow("button","Ellipse",WS_CHILD | WS_VISIBLE |
BS_AUTORADIOBUTTON,
x7+10,y7+50,100,30,hWnd,(HMENU)ID_radio2,g_hInst,NULL);
hwnd_radio3=CreateWindow("button","Line",WS_CHILD | WS_VISIBLE |
BS_AUTORADIOBUTTON,
x7+10,y7+80,100,30,hWnd,(HMENU)ID_radio3,g_hInst,NULL);
hwnd_radio4=CreateWindow("button","Black",WS_CHILD | WS_VISIBLE |
BS_AUTORADIOBUTTON | WS_GROUP,
x7+150,y7+20,100,30,hWnd,(HMENU)ID_radio4,g_hInst,NULL);
hwnd_radio5=CreateWindow("button","Red",WS_CHILD | WS_VISIBLE |
BS_AUTORADIOBUTTON,
x7+150,y7+50,100,30,hWnd,(HMENU)ID_radio5,g_hInst,NULL);
hwnd_radio6=CreateWindow("button","Blue",WS_CHILD | WS_VISIBLE |
BS_AUTORADIOBUTTON,
x7+150,y7+80,100,30,hWnd,(HMENU)ID_radio6,g_hInst,NULL);
CheckRadioButton(hWnd, ID_radio1, ID_radio3, ID_radio1);//1-3 세개의그룹중에서 일번선택
CheckRadioButton(hWnd, ID_radio4, ID_radio6, ID_radio4);//4-6 세개의그룹중에서 사번선택

//------- 라디오박스 만들기 끝 --------------

//char *bmp7str ="Arches.bmp" ;
//MyBitmap=LoadBitmap(g_hInst, bmp7str );

GetCurrentDirectory(MAX_PATH,Path);
strcat(Path,"\\Arches.bmp" ); //"\\apache24.bmp");
hdc=GetDC(hWnd);
hBit=MakeDDBFromDIB(hdc,Path);
ReleaseDC(hWnd,hdc);


return 0;}//---- end create_various_menu ------------

int rou_for_WM_HSCROLL(void){//----- 수평스크롤 이벤트가 발생했을때 ----------

if ((HWND)global_lParam == hwnd_hRed_scroll_bar) TempPos = Red;
if ((HWND)global_lParam == hwnd_hGreen_scroll_bar) TempPos = Green;
if ((HWND)global_lParam == hwnd_hBlue_scroll_bar) TempPos = Blue;

switch (LOWORD(global_wParam)) {
case SB_LINELEFT:
TempPos=max(0,TempPos-1);
break;
case SB_LINERIGHT:
TempPos=min(255,TempPos+1);
break;
case SB_PAGELEFT:
TempPos=max(0,TempPos-10);
break;
case SB_PAGERIGHT:
TempPos=min(255,TempPos+10);
break;
case SB_THUMBTRACK:
TempPos=HIWORD(global_wParam);
break;
}
if ((HWND)global_lParam == hwnd_hRed_scroll_bar) Red=TempPos;
if ((HWND)global_lParam == hwnd_hGreen_scroll_bar) Green=TempPos;
if ((HWND)global_lParam == hwnd_hBlue_scroll_bar) Blue=TempPos;

return 0;}//---- end rou_for_WM_HSCROLL ------------

int rou_for_WM_VSCROLL(void){//----- 수직스크롤 이벤트가 발생했을때 ----------

if ((HWND)global_lParam == hwnd_vRed_scroll_bar) TempPos = Red;

switch (LOWORD(global_wParam)) {
case SB_LINELEFT:
TempPos=max(0,TempPos-1);
break;
case SB_LINERIGHT:
TempPos=min(255,TempPos+1);
break;
case SB_PAGELEFT:
TempPos=max(0,TempPos-10);
break;
case SB_PAGERIGHT:
TempPos=min(255,TempPos+10);
break;
case SB_THUMBTRACK:
TempPos=HIWORD(global_wParam);
break;
}//----

if ((HWND)global_lParam == hwnd_vRed_scroll_bar){ Red=TempPos;
SetScrollPos(hwnd_hRed_scroll_bar,SB_CTL,Red,TRUE);
}//---

return 0;}//---- end rou_for_WM_VSCROLL ------------

int rou_for_WM_COMMAND(void){//----- 여러콘트롤 박스에서 이벤트가 발생했을때 처리하는 루틴 ----------

int i;
//---------- 버튼 처리 시작 ------
switch(LOWORD(global_wParam)){
case ID_BUTTON0: MessageBox(global_hWnd,"First Button Clicked","Button",MB_OK);break;
case ID_BUTTON1: MessageBox(global_hWnd,"Second Button Clicked","Button",MB_OK);break;
}//--------- 버튼 처리 끝 ------


//---------- 콤보박스 처리 시작 ------------
switch (LOWORD(global_wParam)) {
case ID_COMBOBOX:
switch (HIWORD(global_wParam)) {
case CBN_SELCHANGE:
i=SendMessage(hCombo, CB_GETCURSEL,0,0);
//printf("i=SendMessage %i \n",i);
SendMessage(hCombo, CB_GETLBTEXT, i, (LPARAM)str);
SetWindowText(global_hWnd, str);
//SendMessage(hCombo, CB_SETTOPINDEX, i, 0 );
break;
case CBN_EDITCHANGE:
GetWindowText(hCombo, str, 128);
SetWindowText(global_hWnd,str);
break;
}//--- end switch (HIWORD(global_wParam)) ---
}//---- end switch (LOWORD(global_wParam)) ---
//---------- 콤보박스 처리 끝 --------------

//---------- 리스트박스 처리 시작 ------------
switch (LOWORD(global_wParam)) {
case ID_LISTBOX:
switch (HIWORD(global_wParam)) {
case LBN_SELCHANGE:
i=SendMessage(hList, LB_GETCURSEL,0,0);
SendMessage(hList, LB_GETTEXT, i, (LPARAM)str);
SetWindowText(global_hWnd, str);
break;
}
}//----- end switch (LOWORD(global_wParam)) ----
//---------- 리스트박스 처리 시작 ------------


//---------- 체크박스 처리 시작 ------------
switch(LOWORD(global_wParam)) {
case ID_chkbx1:
if (SendMessage(check_box1,BM_GETCHECK,0,0)==BST_UNCHECKED) {
SendMessage(check_box1,BM_SETCHECK,BST_CHECKED,0);
ELLIPSE = TRUE;
}
else {
SendMessage(check_box1,BM_SETCHECK,BST_UNCHECKED,0);
ELLIPSE = FALSE;
}
InvalidateRect(global_hWnd, NULL, TRUE);
break;
case ID_chkbx3:
if (SendMessage(check_box3,BM_GETCHECK,0,0)==BST_UNCHECKED)
SendMessage(check_box3,BM_SETCHECK,BST_CHECKED,0);
else
if (SendMessage(check_box3,BM_GETCHECK,0,0)==BST_INDETERMINATE)
SendMessage(check_box3,BM_SETCHECK,BST_UNCHECKED,0);
else
SendMessage(check_box3,BM_SETCHECK,BST_INDETERMINATE,0);
break;
}//------------
//---------- 체크박스 처리 끝 ------------

//---------- 라디오박스 처리 시작 ------------
if (HIWORD(global_wParam) == BN_CLICKED) {
switch (LOWORD(global_wParam)) {
case ID_radio1:GRAPH_radio=0;break; //GRAPH_radio 0=Rectangle
case ID_radio2:GRAPH_radio=1;break; //GRAPH_radio 1=Ellipse
case ID_radio3:GRAPH_radio=2;break; //GRAPH_radio 2=MoveToEx
case ID_radio4:COLOR_radio=0;break; //RGB(0,0,0)
case ID_radio5:COLOR_radio=1;break; //RGB(255,0,0)
case ID_radio6:COLOR_radio=2;break; //RGB(0,0,255)
}
InvalidateRect(global_hWnd, NULL, TRUE);//--- 페인트를 콜하게 만든다 ---
}

//---------- 라디오박스 처리 끝 --------------


return 0;}//---- end rou_for_WM_COMMAND ------------


int rou_by_WM_PAINT(void){//----- 페인트 이벤트가 발생했을때 ----------

//global_hDC = BeginPaint( global_hWnd,&global_ps );
MyBrush=CreateSolidBrush(RGB(Red,Green,Blue));
//MyBrush=CreateSolidBrush(RGB(244,211,10));
OldBrush=(HBRUSH)SelectObject( global_hDC,MyBrush );
Rectangle( global_hDC ,10,100+100,210,200+100);
SelectObject( global_hDC ,OldBrush);
DeleteObject(MyBrush);

wsprintf(global_str1," rgb Value is %d %d %d ", Red , Green , Blue );
TextOut( global_hDC, 50,90 , global_str1, strlen(global_str1) );

//---------- 체크박스를 선택했을때 변경되는 그림모양 ---
HPEN MyPen, OldPen;
MyPen = CreatePen(PS_SOLID, 5, RGB(255,0 ,0));
OldPen = (HPEN)SelectObject(global_hDC, MyPen);

//SetPolyFillMode(global_hDC,ALTERNATE ); //WINDING);
//SetROP2(global_hDC,R2_MERGEPEN ); //--- or --
//SetROP2(global_hDC,R2_MASKPEN);//--- and 연산으로 겹치는 부분만 안쪽 채우기가 없다
//SetROP2(global_hDC,R2_NOTXORPEN ); //--- --
//SetBkMode(global_hDC,OPAQUE );

if (ELLIPSE == TRUE)Ellipse(global_hDC,200,100,400,200);
else Rectangle(global_hDC,200,100,400,200);
SelectObject(global_hDC, OldPen);
DeleteObject(MyPen);


//---------- 라디오박스를 선택했을때 변경되는 그림모양 시작 --------
int x7=210,y7=130;
switch (COLOR_radio) {
case 0:MyBrush=CreateSolidBrush(RGB(0,0,0));break;
case 1:MyBrush=CreateSolidBrush(RGB(255,0,0));break;
case 2:MyBrush=CreateSolidBrush(RGB(0,0,255));break;
}
OldBrush=(HBRUSH)SelectObject(global_hDC,MyBrush);
switch (GRAPH_radio) {
case 0:Rectangle(global_hDC,x7+10,y7+200,x7+200,y7+300);break;
case 1:Ellipse(global_hDC,x7+10,y7+200,x7+200,y7+300);break;
case 2:MoveToEx(global_hDC,x7+10,y7+200,NULL);LineTo(global_hDC,x7+200,y7+300);break;
}
SelectObject(global_hDC,OldBrush);DeleteObject(MyBrush);
//---------- 라디오박스를 선택했을때 변경되는 그림모양 끝 --------

//---------- 그림을 그린다 -------------------
/*
//HDC MemDC;
MemDC=CreateCompatibleDC(global_hDC);
//MyBitmap=LoadBitmap(g_hInst, MAKEINTRESOURCE(IDB_BITMAP1));//--앞에서 콘트롤 박스를 만들때 같이생성
OldBitmap=(HBITMAP)SelectObject(MemDC, MyBitmap);
//BitBlt(global_hDC, 0,0,123,160,MemDC,0,0,SRCCOPY);
StretchBlt(global_hDC,0,0,246,320,MemDC,0,0,123,160,SRCCOPY);
SelectObject(MemDC,OldBitmap);
DeleteObject(MyBitmap);
DeleteDC(MemDC);
*/


//EndPaint( global_hWnd, &global_ps );

return 0;}//---- end rou_by_WM_PAINT ------------

void DrawBitmap(HDC hdc,int x,int y,HBITMAP hBit)
{
HDC MemDC;
HBITMAP OldBitmap;
int bx,by;
BITMAP bit;

MemDC=CreateCompatibleDC(hdc);
OldBitmap=(HBITMAP)SelectObject(MemDC, hBit);

GetObject(hBit,sizeof(BITMAP),&bit);
bx=bit.bmWidth;
by=bit.bmHeight;

BitBlt(hdc,0,0,bx,by,MemDC,0,0,SRCCOPY);

SelectObject(MemDC,OldBitmap);
DeleteDC(MemDC);
}//---------


LRESULT CALLBACK control_WndProc(HWND hWnd,UINT iMessage,WPARAM wParam,LPARAM lParam)
{

global_hWnd= hWnd;
global_uMsg= iMessage ; //uMsg ;
global_wParam= wParam ;
global_lParam= lParam ;

int i;
switch(iMessage) {

case WM_CREATE:
create_various_menu( hWnd );//------
return 0;

case WM_HSCROLL:
rou_for_WM_HSCROLL(); //----- 수평스크롤 이벤트가 발생했을때 ----------
SetScrollPos((HWND)lParam,SB_CTL,TempPos,TRUE);
InvalidateRect(hWnd,NULL,FALSE);
return 0;

case WM_VSCROLL:
rou_for_WM_VSCROLL(); //----- 수직스크롤 이벤트가 발생했을때 ----------
SetScrollPos((HWND)lParam,SB_CTL,TempPos,TRUE);
InvalidateRect(hWnd,NULL,FALSE);
return 0;


case WM_COMMAND:
rou_for_WM_COMMAND(); //----- 여러콘트롤 박스에서 이벤트가 발생했을때 처리하는 루틴 ----------

return 0;

case WM_PAINT:
global_hDC = BeginPaint( global_hWnd,&global_ps );//--- 안그리더라도 이것이있어야 된다

rou_by_WM_PAINT(); //----- 페인트 이벤트가 발생했을때 ----------

DrawBitmap(global_hDC,0,0,hBit);

EndPaint( global_hWnd, &global_ps );
return 0;


case WM_DESTROY:
if (SendMessage( check_box2,BM_GETCHECK,0,0)==BST_CHECKED)
MessageBox(hWnd,"Good bye","Check",MB_OK);
PostQuitMessage(0);
return 0;
}
return(DefWindowProc(hWnd,iMessage,wParam,lParam));
}//---------- end ----

//======================== int control_window ============== end ===============================
//==============================================================================================

int end_of_making_multiple3_window(void){//---######## 콘트롤 윈도우1 만들기 끝 #################
return 0;}//---- end end_of_making_multiple3_window ----


int create_various2_menu( HWND hWnd ){//------- 여러가지 형태의 콘트롤박스2를 만든다 -----

int x7=0,y7=0;
CreateWindow("button","view move",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
x7+20,y7+20,100,25,hWnd,(HMENU)ID_BUTTON0,g_hInst,NULL);
CreateWindow("button","view rotate",WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
x7+20,y7+50,100,25,hWnd,(HMENU)ID_BUTTON1,g_hInst,NULL);

//------- 체크박스 만들기 시작 ------------
check_box1=CreateWindow("button","hide triangle",WS_CHILD | WS_VISIBLE |
BS_CHECKBOX, x7+20,y7+80,130,25,hWnd,(HMENU)ID_chkbx1,g_hInst,NULL);
//check_box2=CreateWindow("button","Good bye Message?",WS_CHILD | WS_VISIBLE |
//BS_AUTOCHECKBOX,x7+20,y7+50,160,25,hWnd,(HMENU)ID_chkbx2 ,g_hInst,NULL);
//------- 체크박스 만들기 끝 --------------

//------- 스크롤박스 만들기 시작 ------------
hwnd_move_speed_scrb=CreateWindow("scrollbar",NULL,WS_CHILD | WS_VISIBLE | SBS_HORZ,
x7+20,y7+130,150,10,hWnd,(HMENU)ID_scrb_move_speed,g_hInst,NULL);
SetScrollRange(hwnd_move_speed_scrb,SB_CTL,0,move_speed_max,TRUE);
SetScrollPos(hwnd_move_speed_scrb,SB_CTL,50,TRUE);
//------- 스크롤박스 만들기 끝 --------------

return 0;}//---- end create_various2_menu ------------

int rou_for_WM2_HSCROLL(void){//----- 수평스크롤 이벤트가 발생했을때 ------ 콘트롤박스 2 -------

if ((HWND)global_lParam == hwnd_move_speed_scrb) TempPos2 = move_speed;

switch (LOWORD(global_wParam)) {
case SB_LINELEFT:
TempPos2=max(0,TempPos2-1);
break;
case SB_LINERIGHT:
TempPos2=min(move_speed_max,TempPos2+1);
break;
case SB_PAGELEFT:
TempPos2=max(0,TempPos2-10);
break;
case SB_PAGERIGHT:
TempPos2=min(move_speed_max,TempPos2+10);
break;
case SB_THUMBTRACK:
TempPos2=HIWORD(global_wParam);
break;
}
if ((HWND)global_lParam == hwnd_move_speed_scrb) move_speed=TempPos2;
//printf("rou_for_WM2_HSCROLL 이벤트가 발생했음--------------------\n ");

return 0;}//---- end rou_for_WM2_HSCROLL ------------


int rou_for_WM2_COMMAND(void){//----- 여러콘트롤 박스에서 이벤트가 발생했을때 처리하는 루틴 -- 콘트롤박스 2 -------

global_hDC =GetDC(global_hWnd); //invoke BeginPaint,hWin, ADDR ps

int i;
//---------- 버튼 처리 시작 ------
switch(LOWORD(global_wParam)){
case ID_BUTTON0: //MessageBox(global_hWnd,"First Button Clicked","Button",MB_OK);
controle_now = 1 ;
wsprintf(controle_now_str,"controle now : view move" );
//global_str1 copy_string(String &s);
//*global_str1 = "controle now : view move");
TextOut( global_hDC, 150,20 , controle_now_str, strlen(controle_now_str) );
break;
case ID_BUTTON1: //MessageBox(global_hWnd,"Second Button Clicked","Button",MB_OK);
controle_now = 2 ;
wsprintf(controle_now_str,"controle now : view rotate" );//global_str1="controle now : view move");
TextOut( global_hDC, 150,20 , controle_now_str, strlen(controle_now_str) );
break;
}//--------- 버튼 처리 끝 ------

//---------- 체크박스 처리 시작 ------------
switch(LOWORD(global_wParam)) {
case ID_chkbx1:
if (SendMessage(check_box1,BM_GETCHECK,0,0)==BST_UNCHECKED) {
SendMessage(check_box1,BM_SETCHECK,BST_CHECKED,0);
hide_triangle=1 ;
}
else {
SendMessage(check_box1,BM_SETCHECK,BST_UNCHECKED,0);
hide_triangle=0 ;
}
//InvalidateRect(global_hWnd, NULL, TRUE);
break;
/*case ID_chkbx3:
if (SendMessage(check_box3,BM_GETCHECK,0,0)==BST_UNCHECKED)
SendMessage(check_box3,BM_SETCHECK,BST_CHECKED,0);
else
if (SendMessage(check_box3,BM_GETCHECK,0,0)==BST_INDETERMINATE)
SendMessage(check_box3,BM_SETCHECK,BST_UNCHECKED,0);
else
SendMessage(check_box3,BM_SETCHECK,BST_INDETERMINATE,0);
break;*/
}//------ end switch(LOWORD(global_wParam)) ------
//---------- 체크박스 처리 끝 ------------

return 0;}//---- end rou_for_WM2_COMMAND ------------


int rou_by_WM2_PAINT(void){//----- 페인트 이벤트가 발생했을때 ----- 콘트롤박스 2 ------

//global_hDC = BeginPaint( global_hWnd,&global_ps );

if ( controle_now==1 ){wsprintf(controle_now_str,"controle now : view move" );}
else{ wsprintf(controle_now_str,"controle now : view rotate" ); } //-----
TextOut( global_hDC, 150,20 , controle_now_str, strlen(controle_now_str) );

wsprintf(global_str1," rgb Value is %d %d %d ", Red , Green , Blue );
TextOut( global_hDC, 150,40 , global_str1, strlen(global_str1) );

wsprintf(global_str1," move speed = ", move_speed );
TextOut( global_hDC, 20,110, global_str1, strlen(global_str1) );
wsprintf(global_str1," move speed = %d ", move_speed );
TextOut( global_hDC, 20,110, global_str1, strlen(global_str1) );

return 0;}//---- end rou_by_WM2_PAINT ------------


//======================= 새로 콘트롤 윈도2를 만든다 시작 ===================================

int control_window2( //------------- 새로 콘트롤 윈도2를 만든다 ------ 콘트롤박스 2 --------------
HINSTANCE hInstance_ctr_w2,HINSTANCE hPrevInstance,LPSTR lpszCmdParam,int nCmdShow)
{
HWND hWnd;
MSG Message;
WNDCLASS WndClass;
g_hInst=hInstance_ctr_w2;

//Color color7 ;//= Color(244,211,10) ; //RGB(244,211,10) ;
// HBRUSH Background7 ; Background7 = RGB(244,211,10) ;
//int color_int = 244 ;//<< 16 ;//RGB(244,211,10) ;//11 ;

WndClass.cbClsExtra=0;
WndClass.cbWndExtra=0;
WndClass.hbrBackground=(HBRUSH)GetStockObject( LTGRAY_BRUSH );
//WndClass.hbrBackground=CreateSolidBrush(RGB(255,0,0));
WndClass.hCursor=LoadCursor(NULL,IDC_ARROW);
WndClass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
WndClass.hInstance=hInstance_ctr_w2;
WndClass.lpfnWndProc=(WNDPROC)control_WndProc2;
WndClass.lpszClassName=lpszClass_ctr2;
WndClass.lpszMenuName=NULL;
WndClass.style=CS_HREDRAW | CS_VREDRAW;
RegisterClass(&WndClass);

//-------- 이루틴을 첨가하면 화면의 색상은 바뀌지만 버튼으로써의 능력은 상실 ----- begin --
/*WndClass.hbrBackground=CreateSolidBrush(RGB(255,0,0));
WndClass.lpfnWndProc=(WNDPROC)ChildLeftProc;
WndClass.lpszClassName="button" ;
RegisterClass(&WndClass); */
//-------- 이루틴을 첨가하면 화면의 색상은 바뀌지만 버튼으로써의 능력은 상실 ----- end ----


hWnd=CreateWindow(lpszClass_ctr2,lpszClass_ctr2,WS_OVERLAPPEDWINDOW,
//CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,
85 ,400,411,311, //-- 35 ,350,411,311, -- control window1 ----
NULL,(HMENU)NULL,hInstance_ctr_w2,NULL);
ShowWindow(hWnd,nCmdShow);

/*
while(GetMessage(&Message,0,0,0)) {
TranslateMessage(&Message);
DispatchMessage(&Message);
}
*/


return Message.wParam;
}//------ end ------------ control_window2 -----------


LRESULT CALLBACK control_WndProc2( //-------- 새로 콘트롤 윈도2의 실행 루틴 -----------------
HWND hWnd,UINT iMessage,WPARAM wParam,LPARAM lParam){

global_hWnd= hWnd;
global_uMsg= iMessage ; //uMsg ;
global_wParam= wParam ;
global_lParam= lParam ;

int i;
switch(iMessage) {

case WM_CREATE:
create_various2_menu( hWnd );//------
return 0;

case WM_HSCROLL:
rou_for_WM2_HSCROLL(); //----- 수평스크롤 이벤트가 발생했을때 ----------
SetScrollPos((HWND)lParam,SB_CTL,TempPos2,TRUE);
//SetScrollPos((HWND)lParam,SB_CTL,111,TRUE);
float ft7= (1.0f / 50.0f ) * (move_speed/ 50.0f) ;
ms_move_to_gl_move_ratio = ft7 ;
InvalidateRect(hWnd,NULL,FALSE);
return 0;

case WM_VSCROLL:
//rou_for_WM_VSCROLL(); //----- 수직스크롤 이벤트가 발생했을때 ----------
//SetScrollPos((HWND)lParam,SB_CTL,TempPos2,TRUE);
//InvalidateRect(hWnd,NULL,FALSE);
return 0;


case WM_COMMAND:
rou_for_WM2_COMMAND(); //----- 여러콘트롤 박스에서 이벤트가 발생했을때 처리하는 루틴 ----------

return 0;

case WM_PAINT:
global_hDC = BeginPaint( global_hWnd,&global_ps );//--- 안그리더라도 이것이있어야 된다

rou_by_WM2_PAINT(); //----- 페인트 이벤트가 발생했을때 ----------

//DrawBitmap(global_hDC,0,0,hBit);

EndPaint( global_hWnd, &global_ps );
return 0;


case WM_DESTROY:
//if (SendMessage( check_box2,BM_GETCHECK,0,0)==BST_CHECKED)
//MessageBox(hWnd,"Good bye","Check",MB_OK);
PostQuitMessage(0);
return 0;
}
return(DefWindowProc(hWnd,iMessage,wParam,lParam));
}//---------- end control_WndProc2 --------------------------

//======================= 새로 콘트롤 윈도2를 만든다 끝 =====================================

int end_of_making_multiple2_window(void){//----------- 여러윈도우 만들기 끝 -----------------------

return 0;}//---- end end_of_making_multiple2_window ----


//================== rot_xyz_and_translate_xyz_and_go_now ======== begin =========================

int rot_xyz_and_translate_xyz_and_go_now(void){//-----

float feax,febx,fecx,fedx,feex , phi ;
phi = 3.1415927f/180.0f ;//
new_point_of_xyz_rotated[0]=point_of_3d_xyz_rot[0];
new_point_of_xyz_rotated[1]=point_of_3d_xyz_rot[1];
new_point_of_xyz_rotated[2]=point_of_3d_xyz_rot[2];

//;--------------- x rot ----------- 카메라보기 회전 --------- begin -------------------------------------
// Math.sin(angle*3.1415927/180);
// newy=(y)*cos[phi]-(z)*sin[phi]);
// newz=(y)*sin[phi]+(z)*cos[phi]);
feax = cos( point_of_3d_xyz_rot[3] * phi) ; // delta x*3.1415927/180
febx = sin( point_of_3d_xyz_rot[3] * phi) ; //

fecx = point_of_3d_xyz_rot[1] ; // y
fedx = point_of_3d_xyz_rot[2] ; // z
new_point_of_xyz_rotated[1]= fecx*feax - fedx*febx ;
new_point_of_xyz_rotated[2]= fecx*febx + fedx*feax ;


//;--------------- y rot ----------- 카메라보기 회전 --------- begin -------------------------------------
// Math.sin(angle*3.1415927/180);
// centerx = kat+24 , centerZ = kat+40 , x =kat , z= kat+16 , angle = delta x = ms_btn_dn_xy+20
// newx=(x)*cos[phi]-(z)*sin[phi]);
// newz=(x)*sin[phi]+(z)*cos[phi]);
feax = cos( point_of_3d_xyz_rot[4] * phi) ;
febx = sin( point_of_3d_xyz_rot[4] * phi) ; //

fecx = point_of_3d_xyz_rot[0] ; // x
fedx = point_of_3d_xyz_rot[2] ; // z
new_point_of_xyz_rotated[0]= fecx*feax - fedx*febx;
new_point_of_xyz_rotated[2]= fecx*febx + fedx*feax;


/*
//;--------------- z rot ----------- 카메라보기 회전 --------- begin -------------------------------------
// newx=(x)*cos[phi]-(y)*sin[phi]);
// newy=(x)*sin[phi]+(y)*cos[phi]);
feax = cos( point_of_3d_xyz_rot[5] * phi) ;
febx = sin( point_of_3d_xyz_rot[5] * phi) ; //


fecx = point_of_3d_xyz_rot[0] ; // x
fedx = point_of_3d_xyz_rot[1] ; // y
new_point_of_xyz_rotated[0]= fecx*feax - fedx*febx;
new_point_of_xyz_rotated[1]= fecx*febx + fedx*feax;

*/


//----------------- translate ----- begin ---------------------------
new_point_of_xyz_rotated[3] = new_point_of_xyz_rotated[0] + point_of_3d_xyz_rot[6] ;
new_point_of_xyz_rotated[4] = new_point_of_xyz_rotated[1] + point_of_3d_xyz_rot[7] ;
new_point_of_xyz_rotated[5] = new_point_of_xyz_rotated[2] + point_of_3d_xyz_rot[8] ;

printf("new_point_of_xyz_rotated[0]= %f , %f , %f \n,",
new_point_of_xyz_rotated[0],new_point_of_xyz_rotated[1],new_point_of_xyz_rotated[2]);
//----------------- translated point transfer data to now and old ------------------------
LookAt_position_now[0] = point_of_3d_xyz_rot[6] ;// translate value x,y,z
LookAt_position_now[1] = point_of_3d_xyz_rot[7] ;// to // 카메라위치
LookAt_position_now[2] = point_of_3d_xyz_rot[8] ;

LookAt_position_now[3] = new_point_of_xyz_rotated[3] ;// rotated and translated point x,y,z
LookAt_position_now[4] = new_point_of_xyz_rotated[4] ;// to 카메라방향
LookAt_position_now[5] = new_point_of_xyz_rotated[5] ;

//----------------- data to old ------------------
LookAt_position_old[0] = point_of_3d_xyz_rot[6] ;// translate value x,y,z
LookAt_position_old[1] = point_of_3d_xyz_rot[7] ;// to // 카메라위치
LookAt_position_old[2] = point_of_3d_xyz_rot[8] ;

LookAt_position_old[3] = new_point_of_xyz_rotated[3] ;// rotated and translated point x,y,z
LookAt_position_old[4] = new_point_of_xyz_rotated[4] ;// to 카메라방향
LookAt_position_old[5] = new_point_of_xyz_rotated[5] ;

printf("LookAt_position_now[0]= %f , %f , %f \n,",
LookAt_position_now[0],LookAt_position_now[1],LookAt_position_now[2]);


return 0;}//---- end rot_xyz_and_translate_xyz_and_go_now ----

//================== rot_xyz_and_translate_xyz_and_go_now ======== end ===========================

int program_called_paint_rou(void){//----
MSGmsg;
PAINTSTRUCTps;//LOCAL ps:PAINTSTRUCT
//HDCthis_hdc;//LOCAL hdc:HDC
RECTWINRect;

wglMakeCurrent ( window1_hDC,window1_hglrc );
//this_hdc =BeginPaint(window1_hWnd,&ps); //invoke BeginPaint,hWin, ADDR ps
window1_hDC =BeginPaint(window1_hWnd,&ps); //invoke BeginPaint,hWin, ADDR ps

//---------- 이루틴을 안더하면 화면이 안보였다. 아마도 갱신을 못하기때문 ---
//GetClientRect( this_hWnd,&WINRect ) ;// invokeGetClientRect,hWin,ADDR WINRect
GetClientRect( window1_hWnd,&WINRect ) ;// invokeGetClientRect,hWin,ADDR WINRect
//---------- 이것 때문에 엄청나게 지저분해졌다 . 무지하게 많이 뜯어고쳤다 ---

ReSizeGLScene( WINRect.right,WINRect.bottom ); // LoWord=Width, HiWord=Height
//set_new_camera_poition( WINRect.right,WINRect.bottom );//-----

DrawGLScene();
DrawGLScene_b_line_xyz() ;// ----
SwapBuffers(window1_hDC);// Swap Buffers (Double Buffering)
//SwapBuffers(this_hdc);// Swap Buffers (Double Buffering)

EndPaint(window1_hWnd,&ps);//invoke EndPaint,hWin, ADDR ps

printf("---program_called_paint_rou ------\n");

return 0;}//---- end int program_called_paint_rou -----


int program_called_paint2_rou(void){//----
// MSGmsg;
//PAINTSTRUCTps;//LOCAL ps:PAINTSTRUCT
//HDCthis_hdc;//LOCAL hdc:HDC
RECTWINRect;

wglMakeCurrent ( window1_hDC,window1_hglrc );
// window1_hDC =BeginPaint(window1_hWnd,&ps); //invoke BeginPaint,hWin, ADDR ps
window1_hDC =GetDC(window1_hWnd); //invoke BeginPaint,hWin, ADDR ps
//this_hdc =GetDC(window1_hWnd); //invoke BeginPaint,hWin, ADDR ps


//---------- 이루틴을 안더하면 화면이 안보였다. 아마도 갱신을 못하기때문 ---
//GetClientRect( this_hWnd,&WINRect ) ;// invokeGetClientRect,hWin,ADDR WINRect
GetClientRect( window1_hWnd,&WINRect ) ;// invokeGetClientRect,hWin,ADDR WINRect
//---------- 이것 때문에 엄청나게 지저분해졌다 . 무지하게 많이 뜯어고쳤다 ---

//ReSizeGLScene( WINRect.right,WINRect.bottom ); // LoWord=Width, HiWord=Height
set_new_camera_poition( WINRect.right,WINRect.bottom );//-----

DrawGLScene();
DrawGLScene_b_line_xyz() ;// ----
SwapBuffers(window1_hDC);// Swap Buffers (Double Buffering)
//SwapBuffers(this_hdc);// Swap Buffers (Double Buffering)

printf("---program_called_paint2_rou ------\n");

return 0;}//---- end int program_called_paint2_rou -----

int set_new_camera_poition( GLsizei width, GLsizei height ){//-----

if (height==0)// Prevent A Divide By Zero By
{height=1;}// Making Height Equal One

//glViewport(0,0,width,height);// Reset The Current Viewport

glMatrixMode(GL_PROJECTION);// Select The Projection Matrix
glLoadIdentity();// Reset The Projection Matrix

// Calculate The Aspect Ratio Of The Window
gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,700.0f);


gluLookAt ( LookAt_position_now[0],LookAt_position_now[1],LookAt_position_now[2],
LookAt_position_now[3],LookAt_position_now[4],LookAt_position_now[5],
LookAt_position_now[6],LookAt_position_now[7],LookAt_position_now[8] ) ;

//--- gluPerspective , gluLookAt 가 한쌍으로 표현해야 그림이 보인다 ------------


glMatrixMode(GL_MODELVIEW);// Select The Modelview Matrix
glLoadIdentity();// Reset The Modelview Matrix

//SwapBuffers(window1_hDC);// Swap Buffers (Double Buffering)


return 0;}//---- end int set_new_camera_poition -----


int clear_LookAt_position_delta(void){//-----
LookAt_position_delta[0]=0.0f; LookAt_position_delta[1]=0.0f;LookAt_position_delta[2]=0.0f;
LookAt_position_delta[3]=0.0f; LookAt_position_delta[4]=0.0f;LookAt_position_delta[5]=0.0f;
LookAt_position_delta[6]=0.0f; LookAt_position_delta[7]=0.0f;LookAt_position_delta[8]=0.0f;
return 0;}//---- end int clear_LookAt_position_delta --


int camera_now_of_old_plus_delta(void){//-----

LookAt_position_now[0] = LookAt_position_old[0] + LookAt_position_delta[0] ;
LookAt_position_now[1] = LookAt_position_old[1] + LookAt_position_delta[1] ;
LookAt_position_now[2] = LookAt_position_old[2] + LookAt_position_delta[2] ;
LookAt_position_now[3] = LookAt_position_old[3] + LookAt_position_delta[3] ;
LookAt_position_now[4] = LookAt_position_old[4] + LookAt_position_delta[4] ;
LookAt_position_now[5] = LookAt_position_old[5] + LookAt_position_delta[5] ;
LookAt_position_now[6] = LookAt_position_old[6] + LookAt_position_delta[6] ;
LookAt_position_now[7] = LookAt_position_old[7] + LookAt_position_delta[7] ;
LookAt_position_now[8] = LookAt_position_old[8] + LookAt_position_delta[8] ;

return 0;}//---- end int camera_now_of_old_plus_delta -----

int camera_data_move_now_to_old(void){//-----
/*
//-------- for ---------- rot_xyz_and_translate_xyz_and_go_now -------------
point_of_3d_xyz_rot_old[6] =
point_of_3d_xyz_rot_old[6] + ms_btn_dn_float_delta_xy[0] ; //x <--- delta x

point_of_3d_xyz_rot_old[8] =
point_of_3d_xyz_rot_old[8] + ms_btn_dn_float_delta_xy[1] ; //z <--- delta y
//-------- for ---------- rot_xyz_and_translate_xyz_and_go_now -------------
*/


LookAt_position_old[0] = LookAt_position_now[0] ;
LookAt_position_old[1] = LookAt_position_now[1] ;
LookAt_position_old[2] = LookAt_position_now[2] ;
LookAt_position_old[3] = LookAt_position_now[3] ;
LookAt_position_old[4] = LookAt_position_now[4] ;
LookAt_position_old[5] = LookAt_position_now[5] ;
LookAt_position_old[6] = LookAt_position_now[6] ;
LookAt_position_old[7] = LookAt_position_now[7] ;
LookAt_position_old[8] = LookAt_position_now[8] ;

//button_down_first_point_set();//--- init --

ms_btn_dn_xy[0]=0.0f ;ms_btn_dn_xy[1]=0.0f ;ms_btn_dn_xy[2]=0.0f ;
ms_btn_dn_xy[3]=0.0f ;ms_btn_dn_xy[4]=0.0f ;ms_btn_dn_xy[5]=0.0f ;
ms_btn_dn_xy[5]=0.0f; //delta x
ms_btn_dn_xy[6]=0.0f; //delta y
ms_btn_dn_float_delta_xy[0] = 0.0f ;
ms_btn_dn_float_delta_xy[1] = 0.0f ;

clear_LookAt_position_delta();//-----

return 0;}//---- end int program_called_paint_rou -----

int ms_wheel_camera_rotate(void){//-----
clear_LookAt_position_delta();//-----
float feax = LookAt_position_now[0] - LookAt_position_now[3];// x-centerx
float febx = LookAt_position_now[2] - LookAt_position_now[5];// z-centerz
float fecx = LookAt_position_now[1] - LookAt_position_now[4];// y-centery

if ( feax < 0 ){feax=feax*-1.0; }
if ( febx < 0 ){febx=febx*-1.0; }
if ( fecx < 0 ){fecx=fecx*-1.0; }//--- |y|

float dist_x = sqrt(feax*feax + febx*febx );
float oblique_side = sqrt( dist_x * dist_x + fecx * fecx ); //z
float angle_rad = asin( fecx / oblique_side ); //y/z
//float angle_rad = asin( 1.1f / 1.1f );
float angle_dec = (angle_rad*180)/3.1415927 ;
printf("feax=%f , %f, %f , %f , %f\n ",feax,fecx,dist_x,angle_rad,angle_dec );

float change_angle = 5 ,dir =1.0f ;
if ( ms_btn_status[4] =='b' ){ dir=dir * -1.0f; }
change_angle = change_angle* dir ;

angle_dec =angle_dec + change_angle ;
if ( angle_dec > 85 ){ angle_dec = 85; }
if ( angle_dec < 5 ){ angle_dec = 5; }
angle_rad = angle_dec * 3.14159270/180 ;

float new_y = sin( angle_rad );
new_y = (new_y * dist_x ) - fecx ;
printf(" change_angle ,new_y=%f , %f \n ",angle_dec,new_y );

//---- poke new camera 방향 y
LookAt_position_delta[4]= new_y ;

camera_now_of_old_plus_delta();//-----
program_called_paint2_rou();//------
camera_data_move_now_to_old();//-----

return 0;}//---- end int ms_wheel_camera_rotate -----


int move_camera_ms_up_down_or_rotate(void){//-----
//--- 주의 --> 어셈블리의 ; 과 c 컴파일러의 // 을 아주잘 구분해서 사용할것
//---- 두개이 언어를 사용하다보면 혼돈해서 쓸때도 있고 때로는 의도대로 움직이지 않고
//---- 이사소한 실수인것 같아도 로지털 에러로 시간을 많이 잡아먹었다 -----




LookAt_position_delta[0] = 0.0f ; //ms_btn_dn_float_delta_xy[0] ; //x <--- delta x
LookAt_position_delta[3] = 0.0f ; //ms_btn_dn_float_delta_xy[0] ; //x <--- delta x

LookAt_position_delta[1] = -ms_btn_dn_float_delta_xy[1] ; //y <--- delta y
LookAt_position_delta[4] = -ms_btn_dn_float_delta_xy[1] ; //y <--- delta y

camera_now_of_old_plus_delta();//-----

//;-------------------------- 카메라 위치 회전 --------- begin -------------------------------------
// Math.sin(angle*3.1415927/180);
// centerx = kat+24 , centerZ = kat+40 , x =kat , z= kat+16 , angle = delta x = ms_btn_dn_xy+20
// newx=(int)(((x-centerx)*cos[phi]-(z-centerz)*sin[phi])+centerX);
// newz=(int)(((x-centerx)*sin[phi]+(z-centerz)*cos[phi])+centerz); instead y

float feax = LookAt_position_now[0] - LookAt_position_now[3];// x-centerx
float febx = LookAt_position_now[2] - LookAt_position_now[5];// z-centerz
float fecx = cos( ms_btn_dn_xy[5]* 3.1415927f/180.0f) ; // delta x*3.1415927/180
float fedx = sin( ms_btn_dn_xy[5]* 3.1415927f/180.0f) ; // delta x*3.1415927/180

double deax = LookAt_position_now[0] - LookAt_position_now[3];// x-centerx
double debx = LookAt_position_now[2] - LookAt_position_now[5];// z-centerz
double decx = cos( ms_btn_dn_xy[5]* 3.1415927/180.0) ; // delta x*3.1415927/180
double dedx = sin( ms_btn_dn_xy[5]* 3.1415927/180.0) ; // delta x*3.1415927/180

// newx=(int)(((x-centerx)*cos[phi]-(z-centerz)*sin[phi])+centerX);
LookAt_position_now[0] = feax*fecx - febx*fedx + LookAt_position_now[3] ; //x <--- delta x
// newz=(int)(((x-centerx)*sin[phi]+(z-centerz)*cos[phi])+centerz); instead y
LookAt_position_now[2] = feax*fedx + febx*fecx + LookAt_position_now[5]; //z <--- delta x

return 0;}//---- end int move_camera_right_left_go_back -----


int move_camera_ms_up_down_or_rotate_upgrade2(void){//-----

point_of_3d_xyz_rot[7] =
point_of_3d_xyz_rot_old[7] - ms_btn_dn_float_delta_xy[1] ; //z <--- delta y

point_of_3d_xyz_rot[4] =
point_of_3d_xyz_rot_old[4] + ms_btn_dn_xy[5] ; //z <--- delta x

rot_xyz_and_translate_xyz_and_go_now() ;//-----

return 0;}//---- end int move_camera_ms_up_down_or_rotate_upgrade2 ---

int move_camera_right_left_go_back_upgrade2(void){//----// rot x,y,z and translate x,y,z 에의한 변환 ----
// rot x,y,z and translate x,y,z 에의한 변환 ---
point_of_3d_xyz_rot[6] =
point_of_3d_xyz_rot_old[6] + ms_btn_dn_float_delta_xy[0] ; //x <--- delta x

point_of_3d_xyz_rot[8] =
point_of_3d_xyz_rot_old[8] + ms_btn_dn_float_delta_xy[1] ; //z <--- delta y

//LookAt_position_delta[2] = ms_btn_dn_float_delta_xy[1] ; //z <--- delta y

//camera_now_of_old_plus_delta();//-----
rot_xyz_and_translate_xyz_and_go_now() ;//-----

return 0;}//---- end int move_camera_right_left_go_back_upgrade2 -----

int move_camera_right_left_go_back(void){//-----

LookAt_position_delta[0] = ms_btn_dn_float_delta_xy[0] ; //x <--- delta x
LookAt_position_delta[3] = ms_btn_dn_float_delta_xy[0] ; //x <--- delta x

LookAt_position_delta[2] = ms_btn_dn_float_delta_xy[1] ; //z <--- delta y
LookAt_position_delta[5] = ms_btn_dn_float_delta_xy[1] ; //z <--- delta y

camera_now_of_old_plus_delta();//-----

return 0;}//---- end int move_camera_right_left_go_back -----


//------------------- 새롭게 개선된 회전 이동 회전 --- 루틴시작 ----------------------------

int move_camera_ms_up_down_or_rotate_upgrade3(void){//-----
//----- 관찰자의 위치를 중심으로 회전 ---
point_of_3d_xyz_rot[4] = ms_btn_dn_xy[5] ; //y <--- delta x
point_of_3d_xyz_rot[7] = -ms_btn_dn_float_delta_xy[1] ; //y <--- delta y

//transform_upgrade3() ;//-----
return 0;}//---- end int move_camera_ms_up_down_or_rotate_upgrade2 ---

int move_camera_right_left_go_back_upgrade3(void){//----// rot x,y,z and translate x,y,z 에의한 변환 ----
// rot x,y,z and translate x,y,z 에의한 변환 ---
point_of_3d_xyz_rot[6] = ms_btn_dn_float_delta_xy[0] ; //x <--- delta x
point_of_3d_xyz_rot[8] = ms_btn_dn_float_delta_xy[1] ; //z <--- delta y

//transform_upgrade3() ;//-----
return 0;}//---- end int move_camera_right_left_go_back_upgrade2 -----


int move_camera_up_down_and_camera_direction_centered_rotate(void){//-----
//----- 카메라의 방향을 포인트를 중심으로 회전 ----

point_of_3d_xyz_rot[10] = ms_btn_dn_xy[5] ; //y <--- delta x
point_of_3d_xyz_rot[7] = -ms_btn_dn_float_delta_xy[1] ; //y <--- delta y
//printf ( "카메라의 방향을 포인트를 중심으로 회전 %f \n",point_of_3d_xyz_rot[10] );

return 0;}//---- end int move_camera_right_left_go_back -----


int button_up_plus_to_old_and_init(void){//-----------------
int ii=0 , jj=0 ;
//for (int j=0;j<5;j++){
for ( ii=0 ;ii<16 ;ii++ )
{ point_of_3d_xyz_rot_old[ii] = point_of_3d_xyz_rot_old[ii]+ point_of_3d_xyz_rot[ii]; };
for ( jj=0 ;jj<16 ;jj++ ) { point_of_3d_xyz_rot[jj] = 0.0f; };

return 0;}//---- end create_various2_menu ------------

int transform_upgrade3(void){//----------- 새롭게 업그레이드 된 좌표변환 루틴 ------

//-- 일차변환 --------- 관찰자의 위치를 중심으로 회전 ----
// x rot -- y rot <-- int rot_xyz_and_translate_xyz_and_go_now(void)//-----
//new_point_of_xyz_rotated[0] x new_point_of_xyz_rotated[1] y new_point_of_xyz_rotated[2] z
//-- 이차변환 ------
// x move , y move , z move <-- int rot_xyz_and_translate_xyz_and_go_now(void)//-----
//-- 삼차변환 --------- 카메라의 방향을 포인트를 중심으로 회전 ----
// y rot <-- move_camera_ms_up_down_or_rotate(void) //-----
// 변환 끝 ---------

int ii=0 ;
for ( ii=0 ;ii<13 ;ii++ )
{ new_point_of_xyz_rotated[ii] = point_of_3d_xyz_rot_old[ii]+ point_of_3d_xyz_rot[ii];
}//---
printf ( "added vrctor = %f, %f ,%f \n ",new_point_of_xyz_rotated[ 0 ],new_point_of_xyz_rotated[ 1],new_point_of_xyz_rotated[ 2] ) ;
printf ( "added vrctor = %f, %f ,%f \n ",new_point_of_xyz_rotated[ 3 ],new_point_of_xyz_rotated[ 4],new_point_of_xyz_rotated[ 5] ) ;
printf ( "added vrctor = %f, %f ,%f \n",new_point_of_xyz_rotated[ 6 ],new_point_of_xyz_rotated[ 7],new_point_of_xyz_rotated[ 8] ) ;
printf ( "added vrctor = %f, %f ,%f \n",new_point_of_xyz_rotated[ 9 ],new_point_of_xyz_rotated[10],new_point_of_xyz_rotated[11] ) ;
printf ( "added vrctor = \n " ) ;


//----------- 일차변환 --------- 관찰자의 위치를 중심으로 회전 -------------------------------------
// x rot -- y rot <-- int rot_xyz_and_translate_xyz_and_go_now(void)//-----
//new_point_of_xyz_rotated[0] x new_point_of_xyz_rotated[1] y new_point_of_xyz_rotated[2] z

float feax,febx,fecx,fedx,feex , phi ;
phi = 3.1415927f/180.0f ;//

//;--------------- x rot ----------- 카메라보기 회전 --------- begin -------------------------
// Math.sin(angle*3.1415927/180);
// newy=(y)*cos[phi]-(z)*sin[phi]);
// newz=(y)*sin[phi]+(z)*cos[phi]);
feax = cos( new_point_of_xyz_rotated[3] * phi) ; // delta x*3.1415927/180
febx = sin( new_point_of_xyz_rotated[3] * phi) ; //

fecx = new_point_of_xyz_rotated[1] ; // y
fedx = new_point_of_xyz_rotated[2] ; // z
new_point_of_xyz_rotated[1]= fecx*feax - fedx*febx ;
new_point_of_xyz_rotated[2]= fecx*febx + fedx*feax ;


//;--------------- y rot ----------- 카메라보기 회전 --------- begin --------------------------
// Math.sin(angle*3.1415927/180);
// centerx = kat+24 , centerZ = kat+40 , x =kat , z= kat+16 , angle = delta x = ms_btn_dn_xy+20
// newx=(x)*cos[phi]-(z)*sin[phi]);
// newz=(x)*sin[phi]+(z)*cos[phi]);
feax = cos( new_point_of_xyz_rotated[4] * phi) ;
febx = sin( new_point_of_xyz_rotated[4] * phi) ; //

fecx = new_point_of_xyz_rotated[0] ; // x
fedx = new_point_of_xyz_rotated[2] ; // z
new_point_of_xyz_rotated[0]= fecx*feax - fedx*febx;
new_point_of_xyz_rotated[2]= fecx*febx + fedx*feax;


/*
//;--------------- z rot ----------- 카메라보기 회전 --------- begin -------------------------------------
// newx=(x)*cos[phi]-(y)*sin[phi]);
// newy=(x)*sin[phi]+(y)*cos[phi]);
feax = cos( new_point_of_xyz_rotated[5] * phi) ;
febx = sin( new_point_of_xyz_rotated[5] * phi) ; //


fecx = new_point_of_xyz_rotated[0] ; // x
fedx = new_point_of_xyz_rotated[1] ; // y
new_point_of_xyz_rotated[0]= fecx*feax - fedx*febx;
new_point_of_xyz_rotated[1]= fecx*febx + fedx*feax;

*/

//------------------ 이차변환 ---------------------------------------------------------------------
// x move , y move , z move <-- int rot_xyz_and_translate_xyz_and_go_now(void)//-----

//----------------- translate ----- begin ---------------------------
new_point_of_xyz_rotated[0] = new_point_of_xyz_rotated[0] + new_point_of_xyz_rotated[6] ;
new_point_of_xyz_rotated[1] = new_point_of_xyz_rotated[1] + new_point_of_xyz_rotated[7] ;
new_point_of_xyz_rotated[2] = new_point_of_xyz_rotated[2] + new_point_of_xyz_rotated[8] ;

//printf("new_point_of_xyz_rotated[0]= %f , %f , %f \n,",
//new_point_of_xyz_rotated[0],new_point_of_xyz_rotated[1],new_point_of_xyz_rotated[2]);


LookAt_position_now[0]= new_point_of_xyz_rotated[6];// 카메라위치
LookAt_position_now[1]= new_point_of_xyz_rotated[7];
LookAt_position_now[2]= new_point_of_xyz_rotated[8];

LookAt_position_now[3]= new_point_of_xyz_rotated[0];// 카메라방향 ,
LookAt_position_now[4]= new_point_of_xyz_rotated[1];
LookAt_position_now[5]= new_point_of_xyz_rotated[2];

//-- 삼차변환 --------- 카메라의 방향을 포인트를 중심으로 회전 ------ begin ------------------------
// y rot <-- move_camera_ms_up_down_or_rotate(void) //-----
// Math.sin(angle*3.1415927/180);
// centerx = kat+24 , centerZ = kat+40 , x =kat , z= kat+16 , angle = delta x = ms_btn_dn_xy+20
// newx=(int)(((x-centerx)*cos[phi]-(z-centerz)*sin[phi])+centerX);
// newz=(int)(((x-centerx)*sin[phi]+(z-centerz)*cos[phi])+centerz); instead y

feax = LookAt_position_now[0] - LookAt_position_now[3];// x-centerx
febx = LookAt_position_now[2] - LookAt_position_now[5];// z-centerz
fecx = cos( new_point_of_xyz_rotated[10]* 3.1415927f/180.0f) ; // delta x*3.1415927/180
fedx = sin( new_point_of_xyz_rotated[10]* 3.1415927f/180.0f) ; // delta x*3.1415927/180
//float fecx = cos( ms_btn_dn_xy[5]* 3.1415927f/180.0f) ; // delta x*3.1415927/180
//float fedx = sin( ms_btn_dn_xy[5]* 3.1415927f/180.0f) ; // delta x*3.1415927/180

double deax = LookAt_position_now[0] - LookAt_position_now[3];// x-centerx
double debx = LookAt_position_now[2] - LookAt_position_now[5];// z-centerz
double decx = cos( new_point_of_xyz_rotated[10]* 3.1415927/180.0) ; // delta x*3.1415927/180
double dedx = sin( new_point_of_xyz_rotated[10]* 3.1415927/180.0) ; // delta x*3.1415927/180
//float fecx = cos( ms_btn_dn_xy[5]* 3.1415927f/180.0f) ; // delta x*3.1415927/180
//float fedx = sin( ms_btn_dn_xy[5]* 3.1415927f/180.0f) ; // delta x*3.1415927/180

// newx=(int)(((x-centerx)*cos[phi]-(z-centerz)*sin[phi])+centerX);
LookAt_position_now[0] = feax*fecx - febx*fedx + LookAt_position_now[3] ; //x <--- delta x
// newz=(int)(((x-centerx)*sin[phi]+(z-centerz)*cos[phi])+centerz); instead y
LookAt_position_now[2] = feax*fedx + febx*fecx + LookAt_position_now[5]; //z <--- delta x


printf ( "added 2rctor = %f, %f ,%f \n ",LookAt_position_now[ 0 ],LookAt_position_now[ 1],LookAt_position_now[ 2] ) ;
printf ( "added 2rctor = %f, %f ,%f \n ",LookAt_position_now[ 3 ],LookAt_position_now[ 4],LookAt_position_now[ 5] ) ;
printf ( "added 2rctor = %f, %f ,%f \n",LookAt_position_now[ 6 ],LookAt_position_now[ 7],LookAt_position_now[ 8] ) ;
//printf ( "added 2rctor = %f, %f ,%f \n",LookAt_position_now[ 9 ],LookAt_position_now[10],new_point_of_xyz_rotated[11] ) ;
//printf ( "added 2rctor = %df \n",ms_btn_dn_xy[5] );
int jj=0 ;
//for ( jj=0 ;jj<12 ;jj++ ) { point_of_3d_xyz_rot[jj] = 0.0f; };

return 0;}//---- end transform_upgrade3 ------------

//------------------- 새롭게 개선된 회전 이동 회전 --- 루틴끝 -------------------------------


//------------------- 새롭게 개선된 회전 이동 회전 회전 4 --- 루틴시작 ----------------------------

//-- 일차변환 --------- 관찰자의 위치를 중심으로 회전 --- 초기 설정값으로 이후변경불가 -
// x rot -- y rot <-- int rot_xyz_and_translate_xyz_and_go_now(void)//-----
//new_point_of_xyz_rotated[0] x new_point_of_xyz_rotated[1] y new_point_of_xyz_rotated[2] z
//-- 이차변환 ------
// x move , y move , z move <-- int rot_xyz_and_translate_xyz_and_go_now(void)//-----
//-- 삼차변환 --------- 카메라의 방향을 포인트를 중심으로 회전 ----
// y rot <-- move_camera_ms_up_down_or_rotate(void) //-----
//-- 사차변환 --------- 관찰자의 위치를 중심으로 회전 --- 오직 y축을 중심으로 회전 ------
// y rot <-- int rot_xyz_and_translate_xyz_and_go_now(void)//-----
// 변환 끝 ---------

int move_camera_ms_up_down_or_rotate_upgrade4(void){//-----
//----- 관찰자의 위치를 중심으로 회전 ---
point_of_3d_xyz_rot[13] = ms_btn_dn_xy[5] ; //y <--- delta x
point_of_3d_xyz_rot[7] = -ms_btn_dn_float_delta_xy[1] ; //y <--- delta y

//transform_upgrade4() ;//-----
return 0;}//---- end int move_camera_ms_up_down_or_rotate_upgrade2 ---

int move_camera_right_left_go_back_upgrade4(void){//----// rot x,y,z and translate x,y,z 에의한 변환 ----
// rot x,y,z and translate x,y,z 에의한 변환 ---
point_of_3d_xyz_rot[6] = ms_btn_dn_float_delta_xy[0] ; //x <--- delta x
point_of_3d_xyz_rot[8] = ms_btn_dn_float_delta_xy[1] ; //z <--- delta y

//transform_upgrade4() ;//-----
return 0;}//---- end int move_camera_right_left_go_back_upgrade2 -----


int move_camera_up_down_and_camera_direction_centered_rotate4(void){//-----
//----- 카메라의 방향을 포인트를 중심으로 회전 ----

point_of_3d_xyz_rot[10] = ms_btn_dn_xy[5] ; //y <--- delta x
point_of_3d_xyz_rot[7] = -ms_btn_dn_float_delta_xy[1] ; //y <--- delta y
//printf ( "카메라의 방향을 포인트를 중심으로 회전 %f \n",point_of_3d_xyz_rot[10] );

return 0;}//---- end int move_camera_right_left_go_back -----


int button_up_plus_to_old_and_init4(void){//-----------------
int ii=0 , jj=0 ;
//for (int j=0;j<5;j++){
for ( ii=0 ;ii<16 ;ii++ )
{ point_of_3d_xyz_rot_old[ii] = point_of_3d_xyz_rot_old[ii]+ point_of_3d_xyz_rot[ii]; };
for ( jj=0 ;jj<16 ;jj++ ) { point_of_3d_xyz_rot[jj] = 0.0f; };

return 0;}//---- button_up_plus_to_old_and_init4 ------------

int transform_upgrade4(void){//----------- 새롭게 업그레이드 된 좌표변환 루틴 4 ------

//-- 일차변환 --------- 관찰자의 위치를 중심으로 회전 ----
// x rot -- y rot <-- int rot_xyz_and_translate_xyz_and_go_now(void)//-----
//new_point_of_xyz_rotated[0] x new_point_of_xyz_rotated[1] y new_point_of_xyz_rotated[2] z
//-- 이차변환 ------
// x move , y move , z move <-- int rot_xyz_and_translate_xyz_and_go_now(void)//-----
//-- 삼차변환 --------- 카메라의 방향을 포인트를 중심으로 회전 ----
// y rot <-- move_camera_ms_up_down_or_rotate(void) //-----
//-- 사차변환 --------- 관찰자의 위치를 중심으로 회전 --- 오직 y축을 중심으로 회전 ------
// y rot <-- int rot_xyz_and_translate_xyz_and_go_now(void)//-----
// 변환 끝 ---------

int ii=0 ;
for ( ii=0 ;ii<16 ;ii++ )
{ new_point_of_xyz_rotated[ii] = point_of_3d_xyz_rot_old[ii]+ point_of_3d_xyz_rot[ii];
}//---


//----------- 일차변환 --------- 관찰자의 위치를 중심으로 회전 -------------------------------------
// x rot -- y rot <-- int rot_xyz_and_translate_xyz_and_go_now(void)//-----
//new_point_of_xyz_rotated[0] x new_point_of_xyz_rotated[1] y new_point_of_xyz_rotated[2] z

float feax,febx,fecx,fedx,feex , phi ;
phi = 3.1415927f/180.0f ;//

//;--------------- x rot ----------- 카메라보기 회전 --------- begin -------------------------
// Math.sin(angle*3.1415927/180);
// newy=(y)*cos[phi]-(z)*sin[phi]);
// newz=(y)*sin[phi]+(z)*cos[phi]);
feax = cos( new_point_of_xyz_rotated[3] * phi) ; // delta x*3.1415927/180
febx = sin( new_point_of_xyz_rotated[3] * phi) ; //

fecx = new_point_of_xyz_rotated[1] ; // y
fedx = new_point_of_xyz_rotated[2] ; // z
new_point_of_xyz_rotated[1]= fecx*feax - fedx*febx ;
new_point_of_xyz_rotated[2]= fecx*febx + fedx*feax ;


//;--------------- y rot ----------- 카메라보기 회전 --------- begin --------------------------
// Math.sin(angle*3.1415927/180);
// centerx = kat+24 , centerZ = kat+40 , x =kat , z= kat+16 , angle = delta x = ms_btn_dn_xy+20
// newx=(x)*cos[phi]-(z)*sin[phi]);
// newz=(x)*sin[phi]+(z)*cos[phi]);
feax = cos( new_point_of_xyz_rotated[4] * phi) ;
febx = sin( new_point_of_xyz_rotated[4] * phi) ; //

fecx = new_point_of_xyz_rotated[0] ; // x
fedx = new_point_of_xyz_rotated[2] ; // z
new_point_of_xyz_rotated[0]= fecx*feax - fedx*febx;
new_point_of_xyz_rotated[2]= fecx*febx + fedx*feax;


/*
//;--------------- z rot ----------- 카메라보기 회전 --------- begin -------------------------------------
// newx=(x)*cos[phi]-(y)*sin[phi]);
// newy=(x)*sin[phi]+(y)*cos[phi]);
feax = cos( new_point_of_xyz_rotated[5] * phi) ;
febx = sin( new_point_of_xyz_rotated[5] * phi) ; //


fecx = new_point_of_xyz_rotated[0] ; // x
fedx = new_point_of_xyz_rotated[1] ; // y
new_point_of_xyz_rotated[0]= fecx*feax - fedx*febx;
new_point_of_xyz_rotated[1]= fecx*febx + fedx*feax;

*/

//------------------ 이차변환 ---------------------------------------------------------------------
// x move , y move , z move <-- int rot_xyz_and_translate_xyz_and_go_now(void)//-----

//----------------- translate ----- begin ---------------------------
new_point_of_xyz_rotated[0] = new_point_of_xyz_rotated[0] + new_point_of_xyz_rotated[6] ;
new_point_of_xyz_rotated[1] = new_point_of_xyz_rotated[1] + new_point_of_xyz_rotated[7] ;
new_point_of_xyz_rotated[2] = new_point_of_xyz_rotated[2] + new_point_of_xyz_rotated[8] ;

//printf("new_point_of_xyz_rotated[0]= %f , %f , %f \n,",
//new_point_of_xyz_rotated[0],new_point_of_xyz_rotated[1],new_point_of_xyz_rotated[2]);


LookAt_position_now[0]= new_point_of_xyz_rotated[6];// 카메라위치
LookAt_position_now[1]= new_point_of_xyz_rotated[7];
LookAt_position_now[2]= new_point_of_xyz_rotated[8];

LookAt_position_now[3]= new_point_of_xyz_rotated[0];// 카메라방향 ,
LookAt_position_now[4]= new_point_of_xyz_rotated[1];
LookAt_position_now[5]= new_point_of_xyz_rotated[2];

//-- 삼차변환 --------- 카메라의 방향을 포인트를 중심으로 회전 ------ begin ------------------------
// y rot <-- move_camera_ms_up_down_or_rotate(void) //-----
// Math.sin(angle*3.1415927/180);
// centerx = kat+24 , centerZ = kat+40 , x =kat , z= kat+16 , angle = delta x = ms_btn_dn_xy+20
// newx=(int)(((x-centerx)*cos[phi]-(z-centerz)*sin[phi])+centerX);
// newz=(int)(((x-centerx)*sin[phi]+(z-centerz)*cos[phi])+centerz); instead y

feax = LookAt_position_now[0] - LookAt_position_now[3];// x-centerx
febx = LookAt_position_now[2] - LookAt_position_now[5];// z-centerz
fecx = cos( new_point_of_xyz_rotated[10]* 3.1415927f/180.0f) ; // delta x*3.1415927/180
fedx = sin( new_point_of_xyz_rotated[10]* 3.1415927f/180.0f) ; // delta x*3.1415927/180

// newx=(int)(((x-centerx)*cos[phi]-(z-centerz)*sin[phi])+centerX);
LookAt_position_now[0] = feax*fecx - febx*fedx + LookAt_position_now[3] ; //x <--- delta x
// newz=(int)(((x-centerx)*sin[phi]+(z-centerz)*cos[phi])+centerz); instead y
LookAt_position_now[2] = feax*fedx + febx*fecx + LookAt_position_now[5]; //z <--- delta x

//--------------- 삼차까지 변환한 값의 카메라의 위치값의 정보를 버페에 저장한다 --------------------
int ij =0;for ( ij=0;ij<6 ;ij++ ){
point_of_3d_xyz_rot_stage3[ij]= LookAt_position_now[ij] ;}

//----------------------------------------------------------------------------

//-- 사차변환 --------- 관찰자의 위치를 중심으로 회전 --- 오직 y축을 중심으로 회전 ------
// y rot <-- int rot_xyz_and_translate_xyz_and_go_now(void)//-----
// y rot <-- move_camera_ms_up_down_or_rotate(void) //-----
// Math.sin(angle*3.1415927/180);
// centerx = kat+24 , centerZ = kat+40 , x =kat , z= kat+16 , angle = delta x = ms_btn_dn_xy+20
// newx=(int)(((x-centerx)*cos[phi]-(z-centerz)*sin[phi])+centerX);
// newz=(int)(((x-centerx)*sin[phi]+(z-centerz)*cos[phi])+centerz); instead y

// feax = LookAt_position_now[0] - LookAt_position_now[3];// x-centerx
// febx = LookAt_position_now[2] - LookAt_position_now[5];// z-centerz
feax = LookAt_position_now[3] - LookAt_position_now[0];// centerx - x
febx = LookAt_position_now[5] - LookAt_position_now[2];// centerz - z

fecx = cos( new_point_of_xyz_rotated[13]* 3.1415927f/180.0f) ; // delta x*3.1415927/180
fedx = sin( new_point_of_xyz_rotated[13]* 3.1415927f/180.0f) ; // delta x*3.1415927/180

// newx=(int)(((x-centerx)*cos[phi]-(z-centerz)*sin[phi])+centerX);
LookAt_position_now[3] = feax*fecx - febx*fedx + LookAt_position_now[0] ; //x <--- delta x
// newz=(int)(((x-centerx)*sin[phi]+(z-centerz)*cos[phi])+centerz); instead y
LookAt_position_now[5] = feax*fedx + febx*fecx + LookAt_position_now[2]; //z <--- delta x

return 0;}//---- end transform_upgrade4 ------------

//------------------- 새롭게 개선된 회전 이동 회전 회전 4 --- 루틴끝 ----------------------------

int move_camera(void){//-------- 마우스에 의한 이동포인트를 세팅한다 ------

//char *str7 = "uuu" ; 이두개의 문자열들은 아래의 어레이가 한쪽만 전해줘도 양쪽다 똑같은 문자열이된다
//char *str8 = "uuu"; 또 문자열비교도 안된다 , 심각한에러 , 아주골치 아펐음
//str7[0]=ms_btn_status[0] ;//+ms_btn_status[1];
//str7[1]=ms_btn_status[1] ;str7[2]=ms_btn_status[2] ;
//printf(" str7 = %s , %s \n",str7,str8);
// 한쪽만 문자열을 주었는데도 양쪽다 똑같은 문자열을 갖는다 , 해결책 찾지 못했음
//if ( str7 == str8 ){ printf("- camera not action - \n");return 0; }
//if ( strcmp( str7 , str8 )==0 ) { printf("- camera not action - \n");return 0; }

//--- 새롭개 대체된 루틴 ---------------
if ( (ms_btn_status[6] == 'u') && (ms_btn_status[7] == 'u') && (ms_btn_status[8] == 'u') )
{ printf("- camera not action - \n");return 0; }

printf("----- camera move action begin ------ \n");

//if ( ms_btn_status[6] == 'd' ){ move_camera_right_left_go_back(); }//--- button1 --
if ( (ms_btn_status[6] == 'd') && (ms_btn_status[7] == 'u') && (ms_btn_status[8] == 'u')
&& ( controle_now==1 )
){ //move_camera_right_left_go_back_upgrade2();
// move_camera_right_left_go_back_upgrade3();
move_camera_right_left_go_back_upgrade4();
}//--- button1 --

if ( (ms_btn_status[6] == 'd') && (ms_btn_status[7] == 'u') && (ms_btn_status[8] == 'u')
&& ( controle_now==2 )
){ // move_camera_right_left_go_back_upgrade2();
//move_camera_right_left_go_back_upgrade3();
move_camera_right_left_go_back_upgrade4();
}//--- button1 --

//if ( (ms_btn_status[6] == 'd') && (ms_btn_status[7] == 'u') && (ms_btn_status[8] == 'd')
//){ move_camera_ms_up_down_or_rotate_upgrade2(); }//--- button 1 3 --

if ( ms_btn_status[6] == 'u' && (ms_btn_status[7] == 'u') && (ms_btn_status[8] == 'd')
&& ( controle_now==1 ) //----- 카메라의 방향을 포인트를 중심으로 회전 ----
){ // move_camera_ms_up_down_or_rotate();
// move_camera_up_down_and_camera_direction_centered_rotate();//-----
move_camera_up_down_and_camera_direction_centered_rotate4();//-----
}//--- button3 --
if ( ms_btn_status[6] == 'u' && (ms_btn_status[7] == 'u') && (ms_btn_status[8] == 'd')
&& ( controle_now==2 ) //----- 관찰자의 위치를 중심으로 회전 ----
){ // move_camera_ms_up_down_or_rotate_upgrade2();
// move_camera_ms_up_down_or_rotate_upgrade3();
move_camera_ms_up_down_or_rotate_upgrade4();
}//--- button3 --

//if ( ms_btn_status[8] == 'd'){ move_camera_ms_up_down_or_rotate_upgrade2(); }//--- button3 --
//set_new_camera_poition(); //-----


//transform_upgrade3();//---- 회전,이동,회전 데이타로부터 삼차원좌표를 구한다 -----------
transform_upgrade4();//---- 회전,이동,회전 데이타로부터 삼차원좌표를 구한다 -----------

//move_camera_right_left_go_back();
//program_called_paint_rou();//---- 밖에서의 그림은 안그려진다 ---
program_called_paint2_rou();//------

return 0;}//---- end int move_camera -----


int button_down_first_point_set(void){//-----


int eax = global_lParam ;//-- mov eax,mrmy_lParam
int ebx = eax & 0xffff ;//-- and eax,0ffffh
ms_btn_dn_xy[0]=ebx ;//mov ms_btn_dn_xy,eax ; x
ms_btn_dn_xy[3]=ebx ;

eax = global_lParam ;//-- mov eax,mrmy_lParam
ebx = eax >> 16 ;//-- shr eax,16
ms_btn_dn_xy[1]=ebx;//mov ms_btn_dn_xy+4,eax ; x
ms_btn_dn_xy[4]=ebx ;

//callms_btn_status_to_scr


return 0;}//---- end int button_down_first_point_set ----


int MOUSEMOVE_now_point_set(void){//---
int eax =0 , ebx =0 ;

//left button status read ---
eax = global_wParam ;//-- mov eax,wParam
if ( (eax & MK_LBUTTON) == 0 ) { ms_btn_status[6] ='u'; }
else{ ms_btn_status[6] ='d'; }

if ( (eax & MK_MBUTTON) == 0 ) { ms_btn_status[7] ='u'; }
else{ ms_btn_status[7] ='d'; }

if ( (eax & MK_RBUTTON) == 0 ) { ms_btn_status[8] ='u'; }
else{ ms_btn_status[8] ='d'; }

if ( (ms_btn_status[6] == 'u') && (ms_btn_status[7] == 'u') && (ms_btn_status[8] == 'u') )
{ printf("- all button up - \n");return 0; }

//---- now point set -----------
eax = global_lParam ;//-- mov eax,mrmy_lParam
ebx = eax & 0xffff ;//-- and eax,0ffffh
ms_btn_dn_xy[3]=ebx ;//mov ms_btn_dn_xy+12,eax ; x

eax = global_lParam ;//-- mov eax,mrmy_lParam
ebx = eax >> 16 ;//-- shr eax,16
ms_btn_dn_xy[4]=ebx;//mov ms_btn_dn_xy+16,eax ; x


//delta set ----
//--- 마우스의 위치가 쇼트형이기때문에 인트형으로 계산을 하면 크게벗어난다 ---
//eax = ms_btn_dn_xy[3] ;//mov eax,ms_btn_dn_xy+12 ; x
//eax= eax - ms_btn_dn_xy[0] ;// x
//ms_btn_dn_xy[5]=eax; //delta x
short seax = ms_btn_dn_xy[3] ;//mov eax,ms_btn_dn_xy+12 ; x
short sebx= ms_btn_dn_xy[0] ;// x
seax= seax - sebx ;// x
ms_btn_dn_xy[5]=seax ; //delta x


//--- 마우스의 위치가 쇼트형이기때문에 인트형으로 계산을 하면 크게벗어난다 ---
//eax = ms_btn_dn_xy[4] ;//; y
//eax= eax - ms_btn_dn_xy[1] ;// y
//ms_btn_dn_xy[6]=eax; //delta y
seax = ms_btn_dn_xy[4] ;//mov eax,ms_btn_dn_xy+12 ; x
sebx= ms_btn_dn_xy[1] ;// x
seax= seax - sebx ;// y
ms_btn_dn_xy[6]=seax ; //delta y


//-- // 마우스의 델타를 gl 델타로 변환한다 ---
eax = ms_btn_dn_xy[5]; //delta x
float feax = eax * ms_move_to_gl_move_ratio ;
ms_btn_dn_float_delta_xy[0] = feax ;

eax = ms_btn_dn_xy[6]; //delta y
feax = eax * ms_move_to_gl_move_ratio ;
ms_btn_dn_float_delta_xy[1] = feax ;

move_camera();//-----

return 0;}//---- end int MOUSEMOVE_now_point_set -----


int winow_mouse_move_dragg_set(void){//------- button ---
//
//int *str_adr = &ms_btn_status;
// global_uMsg= uMsg ;
//ms_btn_status[4] ='b';

switch ( global_uMsg )
{
case WM_LBUTTONDOWN:{//---------
printf( "window 1 action test\n" ); //---
ms_btn_status[0] ='d';
SetCapture(global_hWnd);
button_down_first_point_set();//-----
return 0;}//-----
case WM_LBUTTONUP:{//---------
ms_btn_status[0] ='u';
ReleaseCapture();
button_up_plus_to_old_and_init();//------
/*
//-------- for ---------- rot_xyz_and_translate_xyz_and_go_now -------------
point_of_3d_xyz_rot_old[6] =
point_of_3d_xyz_rot_old[6] + ms_btn_dn_float_delta_xy[0] ; //x <--- delta x

point_of_3d_xyz_rot_old[8] =
point_of_3d_xyz_rot_old[8] + ms_btn_dn_float_delta_xy[1] ; //z <--- delta y
//-------- for ---------- rot_xyz_and_translate_xyz_and_go_now -------------
camera_data_move_now_to_old();//-----
*/
return 0; }//-----

case WM_MBUTTONDOWN:{//---------
button_down_first_point_set();//-----
ms_btn_status[1] ='d';
return 0;}//-----
case WM_MBUTTONUP:{//---------
ms_btn_status[1] ='u';
//-------- for ---------- rot_xyz_and_translate_xyz_and_go_now -------------
point_of_3d_xyz_rot_old[7] =
point_of_3d_xyz_rot_old[7] - ms_btn_dn_float_delta_xy[1] ; //z <--- delta y

point_of_3d_xyz_rot_old[4] =
point_of_3d_xyz_rot_old[4] + ms_btn_dn_xy[5] ; //z <--- delta x
//-------- for ---------- rot_xyz_and_translate_xyz_and_go_now -------------
camera_data_move_now_to_old();//-----
return 0; }//-----

case WM_RBUTTONDOWN:{//---------
ms_btn_status[2] ='d';
SetCapture(global_hWnd);
button_down_first_point_set();//-----
return 0;}//-----
case WM_RBUTTONUP:{//---------
ms_btn_status[2] ='u';
ReleaseCapture();
button_up_plus_to_old_and_init();//------
/*
//-------- for ---------- rot_xyz_and_translate_xyz_and_go_now -------------
point_of_3d_xyz_rot_old[7] =
point_of_3d_xyz_rot_old[7] - ms_btn_dn_float_delta_xy[1] ; //z <--- delta y

point_of_3d_xyz_rot_old[4] =
point_of_3d_xyz_rot_old[4] + ms_btn_dn_xy[5] ; //z <--- delta x
//-------- for ---------- rot_xyz_and_translate_xyz_and_go_now -------------
camera_data_move_now_to_old();//-----
*/
return 0; }//-----

case WM_MOUSELEAVE:{//---------
printf( "WM_MOUSELEAVE test\n" ); //---
ms_btn_status[5] ='O';
return 0;}//-----

case WM_MOUSEACTIVATE:{//---------
printf( "WM_MOUSEACTIVATE test\n" ); //---
ms_btn_status[5] ='A';
return 0;}//-----

case MOUSEEVENTF_LEFTDOWN:{//---------
printf( "MOUSEEVENTF_LEFTDOWN test\n" ); //---
ms_btn_status[5] ='L';
return 0;}//-----

case MOUSEEVENTF_LEFTUP:{//---------
printf( "MOUSEEVENTF_LEFTUP test\n" ); //---
ms_btn_status[5] ='l';
return 0;}//-----

case WM_MOUSEWHEEL:{//---------
printf( "WM_MOUSEWHEEL test\n" ); //---
ms_wheel_camera_rotate();//-----
int eax = global_wParam ;
int ebx = global_wParam >> 16 ;
if ( ebx > 60000 ){ms_btn_status[4] ='f';}
if ( ebx < 60000 ){ms_btn_status[4] ='b';}

return 0;}//-----

case WM_MOUSEMOVE:{//---------
MOUSEMOVE_now_point_set();//---
//move_camera();//-----
return 0;}//-----


}//----- end switch ( global_uMsg )----


return 0;

}//--------- end int winow_mouse_move_dragg_set --------

//-------------------- end of file -----------------------------

Posted by 최명환7
,