Portal    Foro    Buscar    FAQ    Registrarse    Conectarse


Publicar nuevo tema  Responder al tema 
Página 1 de 1
 
 
OpenGL A Traves De Las LIBRERIAS EXTERNAS EN C
Autor Mensaje
Responder citando   Descargar mensaje  
Mensaje OpenGL A Traves De Las LIBRERIAS EXTERNAS EN C 
 
Este codice es del gran topo Vuott, alguien lo pudo hacer funcionar?

Estoy intentando usar OpenGL pero no a través del componente INCOMPLETO de gambas, sino directamente con las librerías. Me pregunto si es posible. He hecho la consulta ne la lista internacional sin respuestas.

' (se necesita tener instaladas las librerias: libglut.so.3.9.0 - libGL.so - libGLU.so.1.3.1)
Private anguloCuboX As Single   ' angulo del cubo
Private anguloCuboY As Single   '       "
Private anguloEsfera As Single  '       "
Private hazPerspectiva As Integer


Library "libglut:3.9.0"

Private Const GLUT_RGB As Integer = 0
Private Const GLUT_DOUBLE As Integer = 2

' void glutInit(int *argcp, char **argv)
' Initialize the GLUT library.
Private Extern glutInit(pargc As Pointer, argv As Pointer)

' void glutInitDisplayMode(unsigned int mode)
' Sets the initial display mode.
Private Extern glutInitDisplayMode(mode As Integer)

' void glutInitWindowPosition(int x, int y)
' Sets the initial window position.
Private Extern glutInitWindowPosition(x As Integer, y As Integer)

' void glutInitWindowSize(int width, int height)
' Sets the initial window size.
Private Extern glutInitWindowSize(width As Integer, height As Integer)

' int glutCreateWindow(char *name)
' Creates a top-level window.
Private Extern glutCreateWindow(name As String) As Integer

' void glutWireSphere( GLdouble radius, GLint slices, GLint stacks )
' Renders a solid or wireframe sphere respectively.
Private Extern glutWireSphere(radius As Float, slices As Integer, stacks As Integer)

' void glutSwapBuffers(void)
' Swaps the buffers of the current window if double buffered.
Private Extern glutSwapBuffers()


Library "libGL"

Private Const GL_DEPTH_TEST As Integer = &0B71
Private Const GL_COLOR_BUFFER_BIT As Integer = &4000
Private Const GL_DEPTH_BUFFER_BIT As Integer = &100
Private Const GL_QUADS As Integer = 7
Private Const GL_PROJECTION As Integer = &1701
Private Const GL_MODELVIEW As Integer = &1700

' void glClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha )
' Specify clear values for the color buffers.
Private Extern glClearColor(red As Single, green As Single, blue As Single, alpha As Single)

' void glEnable( GLenum cap )
' Enable or disable server-side GL capabilities.
Private Extern glEnable(cap As Integer)

' void glClear(         GLbitfield mask)
' Clear buffers to preset values.
Private Extern glClear(mask As Integer)

' void glLoadIdentity( void )
' Replace the current matrix with the identity matrix.
Private Extern glLoadIdentity()

' void glTranslatef( GLfloat x, GLfloat y, GLfloat z )
' Multiply the current matrix by a translation matrix.
Private Extern glTranslatef(x As Single, y As Single, z As Single)

' void glRotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z )
' Multiply the current matrix by a rotation matrix.
Private Extern glRotatef(GLangle As Single, x As Single, y As Single, z As Single)

' void glColor3f( GLfloat red, GLfloat green, GLfloat blue )
' Sets the current color.
Private Extern glColor3f(red As Single, green As Single, blue As Single)

' void glBegin( GLenum mode)
' Delimits the vertices of a primitive or a group of like primitives.
Private Extern glBegin(mode As Integer)

' void glVertex3f( GLfloat x, GLfloat y, GLfloat z )
' Specify a vertex.
Private Extern glVertex3f(x As Single, y As Single, z As Single)

' void glEnd( void )
' Delimit the vertices of a primitive or a group of like primitives.
Private Extern glEnd()

' void glFlush( void )
' Force execution of GL commands in finite time.
Private Extern glFlush()

' void glViewport( GLint x, GLint y, GLsizei width, GLsizei height )
' Set the viewport.
Private Extern glViewport(x As Integer, y As Integer, width As Integer, height As Integer)

' void glMatrixMode( GLenum mode )
' Specify which matrix is the current matrix.
Private Extern glMatrixMode(mode As Integer)

' void glOrtho( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val )
' Multiply the current matrix with an orthographic matrix.
Private Extern glOrtho(GLleft As Float, GLright As Float, bottom As Float, top As Float, near_val As Float, far_val As Float)


Library "libGLU:1.3.1"

' void gluPerspective (GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar)
' Set up a perspective projection matrix.
Private Extern gluPerspective(fovy As Float, aspect As Float, zNear As Float, zFar As Float)



Public Sub Main()

  Dim argcp As Pointer

    glutInit(VarPtr(argcp), 0)
    glutInitDisplayMode(GLUT_DOUBLE Or GLUT_RGB)
    glutInitWindowPosition(100, 100)
    glutInitWindowSize(400, 400)
    glutCreateWindow("Cubo")
    
    glClearColor(0, 0, 0, 0)
    glEnable(GL_DEPTH_TEST)

    While True
      Display()
      Reshape(400, 400)
    Wend

End


Private Procedure Display()

  glClear(GL_COLOR_BUFFER_BIT Or GL_DEPTH_BUFFER_BIT)
  
  glLoadIdentity()
  
  glTranslatef(0.0, 0.0, -5.0)
  
  glRotatef(anguloCuboX, 1.0, 0.0, 0.0)
  glRotatef(anguloCuboY, 0.0, 1.0, 0.0)
  
  drawCube()
  
  glLoadIdentity()
  
  glTranslatef(0.0, 0.0, -5.0)
  glRotatef(anguloEsfera, 0.0, 1.0, 0.0)
  glTranslatef(3.0, 0.0, 0.0)
  
  glColor3f(1.0, 1.0, 1.0)
  glutWireSphere(0.5, 8, 8)
  
  glFlush()
  glutSwapBuffers()
  
  anguloCuboX += 0.1
  anguloCuboY += 0.1
  anguloEsfera += 0.2
  
End


Private Procedure drawCube()
  
  glColor3f(1.0, 0.0, 0.0)
  glBegin(GL_QUADS)             ' cara frontal
  glVertex3f(-1.0, -1.0, 1.0)
  glVertex3f(1.0, -1.0, 1.0)
  glVertex3f(1.0, 1.0, 1.0)
  glVertex3f(-1.0, 1.0, 1.0)
  glEnd()

  glColor3f(0.0, 1.0, 0.0)
  glBegin(GL_QUADS)             ' cara trasera
  glVertex3f(1.0, -1.0, -1.0)
  glVertex3f(-1.0, -1.0, -1.0)
  glVertex3f(-1.0, 1.0, -1.0)
  glVertex3f(1.0, 1.0, -1.0)
  glEnd()

  glColor3f(0.0, 0.0, 1.0)
  glBegin(GL_QUADS)              ' cara lateral izq
  glVertex3f(-1.0, -1.0, -1.0)
  glVertex3f(-1.0, -1.0, 1.0)
  glVertex3f(-1.0, 1.0, 1.0)
  glVertex3f(-1.0, 1.0, -1.0)
  glEnd()

  glColor3f(1.0, 1.0, 0.0)
  glBegin(GL_QUADS)               ' cara lateral dcha
  glVertex3f(1.0, -1.0, 1.0)
  glVertex3f(1.0, -1.0, -1.0)
  glVertex3f(1.0, 1.0, -1.0)
  glVertex3f(1.0, 1.0, 1.0)
  glEnd()

  glColor3f(0.0, 1.0, 1.0)
  glBegin(GL_QUADS)               ' cara arriba
  glVertex3f(-1.0, 1.0, 1.0)
  glVertex3f(1.0, 1.0, 1.0)
  glVertex3f(1.0, 1.0, -1.0)
  glVertex3f(-1.0, 1.0, -1.0)
  glEnd()

  glColor3f(1.0, 0.0, 1.0)
  glBegin(GL_QUADS)               ' cara abajo
  glVertex3f(1.0, -1.0, -1.0)
  glVertex3f(1.0, -1.0, 1.0)
  glVertex3f(-1.0, -1.0, 1.0)
  glVertex3f(-1.0, -1.0, -1.0)
  glEnd()
  
End


Private Procedure Reshape(width As Integer, height As Integer)
  
  glViewport(0, 0, width, height)
  glMatrixMode(GL_PROJECTION)
  glLoadIdentity()
    
  If hazPerspectiva Then
    gluPerspective(60.0, CSingle(width) / CSingle(height), 1.0, 20.0)
  Else
    glOrtho(-4, 4, -4, 4, 1, 10)
  Endif

  glMatrixMode(GL_MODELVIEW)
  glLoadIdentity()
  
End


'' Referencias:
' https://www.opengl.org/documentation/specs/glut/spec3/spec3.html
' https://www.opengl.org/sdk/docs/man/html/indexflat.php
' http://sabia.tic.udc.es/gc/Tutorial%20OpenGL/index.htm

 




===================
"Los IF son mas rápidos" - autor anónimo
 
tercoIDE - Ver perfil del usuarioEnviar mensaje privado 
Volver arribaPágina inferior
Responder citando   Descargar mensaje  
Mensaje Re: OpenGL A Traves De Las LIBRERIAS EXTERNAS EN C 
 
tercoIDE escribió: [Ver mensaje]
Este codice es del gran topo Vuott, alguien lo pudo hacer funcionar?


Qué extrañas son las lenguas: la palabra "topo" en italiano significa "ratón".  



tercoIDE escribió: [Ver mensaje]
Este codice es del gran topo Vuott

No, no me parece sea al mio.  



tercoIDE escribió: [Ver mensaje]
alguien lo pudo hacer funcionar?

A mi funciona aquel codigo.
 



 
vuott - Ver perfil del usuarioEnviar mensaje privado 
Volver arribaPágina inferior
Responder citando   Descargar mensaje  
Mensaje Re: OpenGL A Traves De Las LIBRERIAS EXTERNAS EN C 
 
Citar:

Qué extrañas son las lenguas: la palabra "topo" en italiano significa "ratón".  


sudlc75fc3r3mp6whtf4juwdxsub44jux7pfcjf_n9r3cig-g3oacyuheuqi2if0rpwonoaeyilairsxe-mc1gw1uwemp_zs3t5c8qi70a

Citar:

No, no me parece sea al mio.  



es tuyo, o prestado

https://foro.gambas-es.org/viewtopic.php?f=1&t=5040&start=0
 




===================
"Los IF son mas rápidos" - autor anónimo
 
tercoIDE - Ver perfil del usuarioEnviar mensaje privado 
Volver arribaPágina inferior
Responder citando   Descargar mensaje  
Mensaje Re: OpenGL A Traves De Las LIBRERIAS EXTERNAS EN C 
 
tercoIDE escribió: [Ver mensaje]
es tuyo, o prestado

https://foro.gambas-es.org/viewtopic.php?f=1&t=5040&start=0


Ah, ...ok.
 



 
vuott - Ver perfil del usuarioEnviar mensaje privado 
Volver arribaPágina inferior
Responder citando   Descargar mensaje  
Mensaje Re: OpenGL A Traves De Las LIBRERIAS EXTERNAS EN C 
 
tercoIDE escribió: [Ver mensaje]
alguien lo pudo hacer funcionar?


Desculpa, a ti no funciona aquel codigo ?
Y porqué ?
 



 
vuott - Ver perfil del usuarioEnviar mensaje privado 
Volver arribaPágina inferior
Responder citando   Descargar mensaje  
Mensaje Re: OpenGL A Traves De Las LIBRERIAS EXTERNAS EN C 
 
Ahora funciona, el aquel momento no lo hizo

captura_de_pantalla_de_2020_05_17_16_56_07


crees que sera posible usar este método para dibujar en una ImageView de una ventana? o sea, prescindir por completo del componente  qb.OpenGL y del control GLArea
 




===================
"Los IF son mas rápidos" - autor anónimo
 
tercoIDE - Ver perfil del usuarioEnviar mensaje privado 
Volver arribaPágina inferior
Responder citando   Descargar mensaje  
Mensaje Re: OpenGL A Traves De Las LIBRERIAS EXTERNAS EN C 
 
Si esta "ImageView" es el objeto de gambas, no se como; es decir "que" (handle) pasarle.  


De todos modos fijate que yo no tengo bastante conocimiento del sistema OpenGL.

 



 
vuott - Ver perfil del usuarioEnviar mensaje privado 
Volver arribaPágina inferior
Responder citando   Descargar mensaje  
Mensaje Re: OpenGL A Traves De Las LIBRERIAS EXTERNAS EN C 
 
no te vayas, todavía hay comida
 




===================
"Los IF son mas rápidos" - autor anónimo
 
tercoIDE - Ver perfil del usuarioEnviar mensaje privado 
Volver arribaPágina inferior
Mostrar mensajes anteriores:    
 
OcultarTemas parecidos
Tema Autor Foro Respuestas último mensaje
No hay nuevos mensajes SQLite - Conectarse A Traves De Una Red Lo... abarzuaf Bases de Datos 6 Jueves, 16 Septiembre 2010, 19:32 Ver último mensaje
ahtonio
No hay nuevos mensajes Configurar Wifi A Traves De Código Gambas3 nikito General 2 Lunes, 16 Septiembre 2013, 04:21 Ver último mensaje
vicr
No hay nuevos mensajes [OpenGL] Introduction To OpenGL Graphics ... Shell Programación en otros lenguajes 0 Sabado, 09 Marzo 2019, 14:48 Ver último mensaje
Shell
No hay nuevos mensajes Acceso Mixto A Librerias EXTERNAS En C tercoIDE Controles/Librerías/Componentes 7 Lunes, 18 May 2020, 01:10 Ver último mensaje
vuott
 

Publicar nuevo tema  Responder al tema  Página 1 de 1
 

Usuarios navegando en este tema: 0 registrados, 0 ocultos y 1 invitado
Usuarios registrados conectados: Ninguno


 
Lista de permisos
No puede crear mensajes
No puede responder temas
No puede editar sus mensajes
No puede borrar sus mensajes
No puede votar en encuestas
No puede adjuntar archivos
Puede descargar archivos
No puede publicar eventos en el calendario



  

 

cron