Создать ответ 
 
Рейтинг темы:
  • Голосов: 0 - Средняя оценка: 0
  • 1
  • 2
  • 3
  • 4
  • 5
swat помоги может быть будушему програмисту,pliz
Автор Сообщение
HELION Не на форуме
Продвинутый
***

Сообщений: 286
Зарегистрирован: 27.05.2005
Рейтинг: 0
Сказал спасибо: 0
Поблагодарили 2 раз(а) в 2 сообщ.
Сообщение: #21
swat помоги может быть будушему програмисту,pliz
ну вот оно:blink:(как делать рамку CODE?) енто SWAT програмка ту что скачал я DEV C++ только вот библиотека там только OpenGL,а SDL чегото не нахожу:blink:

Код:
/*
   Name: GLSAMPLE
   Author: Blaine Hodge
   Description: OpenGL sample. Read the file Include\Gl\ReadMe.txt
                for informations on using OpenGL.
   Date: -
   Copyright: Public domain
*/

// Includes

#include <windows.h>
#include <gl/gl.h>

// Function Declarations

LRESULT CALLBACK
WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
VOID EnableOpenGL(HWND hWnd, HDC * hDC, HGLRC * hRC);
VOID DisableOpenGL(HWND hWnd, HDC hDC, HGLRC hRC);

// WinMain

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
                   LPSTR lpCmdLine, int iCmdShow)
{
  WNDCLASS wc;
  HWND hWnd;
  HDC hDC;
  HGLRC hRC;    
  MSG msg;
  BOOL bQuit = FALSE;
  float theta = 0.0f;

  // register window class
  wc.style = CS_OWNDC;
  wc.lpfnWndProc = WndProc;
  wc.cbClsExtra = 0;
  wc.cbWndExtra = 0;
  wc.hInstance = hInstance;
  wc.hIcon = LoadIcon( NULL, IDI_APPLICATION );
  wc.hCursor = LoadCursor( NULL, IDC_ARROW );
  wc.hbrBackground = (HBRUSH)GetStockObject( BLACK_BRUSH );
  wc.lpszMenuName = NULL;
  wc.lpszClassName = "GLSample";
  RegisterClass( &amp;wc );

  // create main window
  hWnd = CreateWindow(
  "GLSample", "OpenGL Sample",
  WS_CAPTION | WS_POPUPWINDOW | WS_VISIBLE,
  0, 0, 256, 256,
  NULL, NULL, hInstance, NULL);

  // enable OpenGL for the window
  EnableOpenGL( hWnd, &amp;hDC, &amp;hRC );

  // program main loop
  while (!bQuit)
    {
      // check for messages
      if (PeekMessage(&amp;msg, NULL, 0, 0, PM_REMOVE))
        {
          // handle or dispatch messages
          if (msg.message == WM_QUIT)
            {
              bQuit = TRUE;
            }
          else
            {
              TranslateMessage(&amp;msg);
              DispatchMessage(&amp;msg);
            }

         }
      else
        {
          // OpenGL animation code goes here

          glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
          glClear(GL_COLOR_BUFFER_BIT);

          glPushMatrix();
          glRotatef(theta, 1.0f, 1.0f, 1.0f);
          glBegin(GL_TRIANGLES);
          glColor3f( 1.0f, 0.0f, 0.0f ); glVertex2f( 0.0f, 1.0f );
          glColor3f( 0.0f, 1.0f, 0.0f ); glVertex2f( 0.87f, -0.5f );
          glColor3f( 0.0f, 0.0f, 1.0f ); glVertex2f( -0.87f, -0.5f );
          glEnd();
          glPopMatrix();
          SwapBuffers( hDC );

          theta += 1.0f;

        }
  }
  // shutdown OpenGL
  DisableOpenGL( hWnd, hDC, hRC );
  // destroy the window explicitly
  DestroyWindow( hWnd );
  return msg.wParam;
}

// Window Procedure

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
  switch (message)
    {
      case WM_CREATE:
        return 0;

      case WM_CLOSE:
        PostQuitMessage( 0 );
        return 0;

      case WM_DESTROY:
        return 0;

      case WM_KEYDOWN:
        switch (wParam)
        {
          case VK_ESCAPE:
            PostQuitMessage( 0 );
            return 0;
        }
        return 0;

        default:
          return DefWindowProc(hWnd, message, wParam, lParam);
  }
}

// Enable OpenGL

VOID EnableOpenGL( HWND hWnd, HDC * hDC, HGLRC * hRC )
{
  PIXELFORMATDESCRIPTOR pfd;
  int iFormat;

  // get the device context (DC)
  *hDC = GetDC( hWnd );

  // set the pixel format for the DC
  ZeroMemory( &amp;pfd, sizeof( pfd ) );
  pfd.nSize = sizeof( pfd );
  pfd.nVersion = 1;
  pfd.dwFlags = PFD_DRAW_TO_WINDOW |
  PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
  pfd.iPixelType = PFD_TYPE_RGBA;
  pfd.cColorBits = 24;
  pfd.cDepthBits = 16;
  pfd.iLayerType = PFD_MAIN_PLANE;
  iFormat = ChoosePixelFormat( *hDC, &amp;pfd );
  SetPixelFormat( *hDC, iFormat, &amp;pfd );

  // create and enable the render context (RC)
  *hRC = wglCreateContext( *hDC );
  wglMakeCurrent( *hDC, *hRC );
}

// Disable OpenGL

VOID DisableOpenGL( HWND hWnd, HDC hDC, HGLRC hRC )
{
  wglMakeCurrent( NULL, NULL );
  wglDeleteContext( hRC );
  ReleaseDC( hWnd, hDC );
}

восприятие определяет реальность
(Последний раз сообщение было отредактировано 15.10.2005 в 00:12, отредактировал пользователь SWAT.)
14.10.2005 15:53
Вебсайт Найти все сообщения Цитировать это сообщение
Создать ответ 


Сообщения в этой теме
swat помоги может быть будушему програмисту,pliz - HELION - 14.10.2005 15:53

Похожие темы
Тема: Автор Ответов: Просмотров: Посл. сообщение
  SH4 Disassemblers and Official bin utils Pack v1.0 by SWAT Renji-kun 13 38460 28.08.2013 02:57
Посл. сообщение: kof888
  GUI/Shell for Universal PVR Extractor/Patcher v1.3 by SWAT P@S@f 3 16422 27.08.2011 23:59
Посл. сообщение: P@S@f
  sdfs lib by SWAT? alex 4 15894 19.07.2010 07:26
Посл. сообщение: SWAT
  Swat Guest 4 15571 14.01.2006 17:01
Посл. сообщение: SWAT
  2 SWAT Guest 2 9315 17.06.2005 22:07
Посл. сообщение: SWAT

Переход:


Пользователи просматривают эту тему: 3 Гость(ей)