gitsunekei1445 / GameEngineV.1

Main repository my team project .
1 stars 0 forks source link

Funtion Data : Create GUI on screen #19

Open gitsunekei1445 opened 3 years ago

gitsunekei1445 commented 3 years ago

Python

import glfw
from OpenGL.GL import *

# initializing glfw library
if not glfw.init():
    raise Exception("glfw can not be initialized!")

# Configure the OpenGL context.
# If we are planning to use anything above 2.1 we must at least
# request a 3.3 core context to make this work across platforms.
glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, 3)
glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, 3)
glfw.window_hint(glfw.OPENGL_PROFILE, glfw.OPENGL_CORE_PROFILE)
glfw.window_hint(glfw.OPENGL_FORWARD_COMPAT, True)
# 4 MSAA is a good default with wide support
glfw.window_hint(glfw.SAMPLES, 4)

# creating the window
window = glfw.create_window(1280, 720, "My OpenGL window", None, None)

# check if window was created
if not window:
    glfw.terminate()
    raise Exception("glfw window can not be created!")

# Query the actual framebuffer size so we can set the right viewport later
# -> glViewport(0, 0, framebuffer_size[0], framebuffer_size[1])
framebuffer_size = glfw.get_framebuffer_size(window)

# set window's position
glfw.set_window_pos(window, 400, 200)

# make the context current
glfw.make_context_current(window)

# the main application loop
while not glfw.window_should_close(window):
    glfw.poll_events()
    glfw.swap_buffers(window)

# terminate glfw, free up allocated resources
glfw.terminate()

https://github.com/totex/Learn-OpenGL-in-python/blob/master/ep01_glfw_window.py

gitsunekei1445 commented 3 years ago

Python on Module

    def gui_create(self, width, height, title):
        if width < 1 and height < 1:
            raise Exception('Enter your Width or Height > 0 ')
        else:
            self.width = width
            self.height = height
            self.title = title
            self.gui = create_window(self.width, self.height, self.title, self.fullscreen, self.share)

            if not self.gui:
                raise Exception(" GLFW Cen not Create gui !")
            # self.icon = Image.open('icon.png')
            # set_window_icon(self.gui, 1, self.icon)
            set_window_pos(self.gui,self.position_X,self.position_Y)
            make_context_current(self.gui)

            return self.gui